Changeset 58 for foam/trunk
- Timestamp:
- 04/15/2009 09:31:03 AM (12 years ago)
- Location:
- foam/trunk/simple-faceident
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
foam/trunk/simple-faceident/Makefile
r32 r58 1 1 CC = g++ 2 CFLAGS = `pkg-config --cflags opencv` -ggdb -Wall -O3 -ffast-math -Wno-unused3 2 CXXFLAGS = `pkg-config --cflags opencv` -ggdb -Wall -O3 -ffast-math -Wno-unused 4 3 LDFLAGS = `pkg-config --libs opencv` -lYARP_dev -lYARP_sig -lYARP_OS -lACE -
foam/trunk/simple-faceident/src/FaceBank.h
r14 r58 18 18 #include <map> 19 19 #include <assert.h> 20 21 20 #include "cv.h" 22 21 -
foam/trunk/simple-faceident/src/main.cpp
r32 r58 19 19 #include "cv.h" 20 20 #include "highgui.h" 21 #include <yarp/os/all.h> 21 22 22 23 #include <stdio.h> … … 35 36 36 37 using namespace std; 38 using namespace yarp::os; 37 39 38 40 #ifdef _EiC … … 68 70 int facenum=0; 69 71 int framenum=0; 72 73 BufferedPort<Bottle> ctrlport; 70 74 71 75 ////////////////////////////////////////////////////////// … … 85 89 const char* input_name = 0; 86 90 91 ///////////////////////// 92 // yarp bit, would like to move this somewhere else 93 94 ctrlport.open("/faceident-ctrl"); 95 96 ///////////////////////// 97 87 98 for( i = 1; i < argc; i++ ) 88 99 { … … 150 161 IPL_DEPTH_8U, frame->nChannels ); 151 162 if( frame->origin == IPL_ORIGIN_TL ) 152 //cvResize(frame, frame_copy, CV_INTER_LINEAR );153 163 cvCopy( frame, frame_copy, 0 ); 154 164 else … … 214 224 }; 215 225 216 IplImage * gray, *small_img;226 IplImage *small_img; 217 227 int j; 218 CvSize imgsize = cvGetSize(img); 219 220 gray = cvCreateImage( cvSize(img->width,img->height), 8, 1 ); 228 221 229 small_img = cvCreateImage( cvSize( cvRound (img->width/scale), 222 cvRound (img->height/scale)), 8, 1 ); 223 224 cvCvtColor( img, gray, CV_BGR2GRAY ); 225 cvResize( gray, small_img, CV_INTER_LINEAR ); 226 cvEqualizeHist( small_img, small_img ); 230 cvRound (img->height/scale)), 8, 3 ); 231 CvSize imgsize = cvGetSize(small_img); 232 cvResize( img, small_img, CV_INTER_LINEAR ); 227 233 cvClearMemStorage( storage ); 228 234 … … 264 270 }*/ 265 271 272 /////////////////////////////////// 273 // dispatch from input 266 274 267 275 int key=cvWaitKey(10); … … 282 290 case 'c': facebank.Clear(); break; 283 291 } 284 285 292 293 /////////////////////////////////// 294 // read from yarp 295 296 Bottle *b=ctrlport.read(false); 297 if (b!=NULL) 298 { 299 cerr<<"got bottle "<<b->toString().c_str()<<endl; 300 if (b->get(0).asString()=="train") 301 { 302 facenum=b->get(1).asInt(); 303 learn=true; 304 } 305 else if (b->get(0).asString()=="clear") 306 { 307 facebank.Clear(); 308 } 309 else if (b->get(0).asString()=="detect") 310 { 311 learn=false; 312 } 313 } 314 315 /////////////////////////////////// 316 286 317 for(int i = 0; i < (faces ? faces->total : 0); i++ ) 287 318 { … … 292 323 float confidence=0; 293 324 // get the face area as a sub image 294 IplImage *face = SubImage( img, *r);325 IplImage *face = SubImage(small_img, *r); 295 326 // pass it into the face bank 296 327 if (learn) … … 312 343 char s[32]; 313 344 sprintf(s,"%d %0.2f",ID,confidence); 314 cvPutText( img, s, cvPoint(r->x,r->y+25), &font, color);345 cvPutText(small_img, s, cvPoint(r->x,r->y+25), &font, color); 315 346 int x=(facebank.GetFaceWidth()+1)*ID; 316 347 int y=imgsize.height-facebank.GetFaceHeight(); 317 cvLine( img, cvPoint(r->x+r->width/2,r->y+r->height/2),348 cvLine(small_img, cvPoint(r->x+r->width/2,r->y+r->height/2), 318 349 cvPoint(x+facebank.GetFaceWidth()/2,y), color); 319 350 … … 324 355 } 325 356 326 cvRectangle( img, cvPoint(r->x,r->y), cvPoint(r->x+r->width,r->y+r->height), color);357 cvRectangle(small_img, cvPoint(r->x,r->y), cvPoint(r->x+r->width,r->y+r->height), color); 327 358 } 328 359 } … … 339 370 snprintf(info,256,"detecting faces"); 340 371 } 341 cvPutText( img, info, cvPoint(20,30), &infofont, CV_RGB(0,0,0));372 cvPutText(small_img, info, cvPoint(20,30), &infofont, CV_RGB(0,0,0)); 342 373 343 374 snprintf(info,256,"keys:"); 344 cvPutText( img, info, cvPoint(20,50), &helpfont, CV_RGB(0,0,0));375 cvPutText(small_img, info, cvPoint(20,50), &helpfont, CV_RGB(0,0,0)); 345 376 snprintf(info,256,"number key 0-9 : learn face"); 346 cvPutText( img, info, cvPoint(20,60), &helpfont, CV_RGB(0,0,0));377 cvPutText(small_img, info, cvPoint(20,60), &helpfont, CV_RGB(0,0,0)); 347 378 snprintf(info,256,"'d' : face detect mode"); 348 cvPutText( img, info, cvPoint(20,70), &helpfont, CV_RGB(0,0,0));379 cvPutText(small_img, info, cvPoint(20,70), &helpfont, CV_RGB(0,0,0)); 349 380 snprintf(info,256,"'c' : clear all faces"); 350 cvPutText( img, info, cvPoint(20,80), &helpfont, CV_RGB(0,0,0));381 cvPutText(small_img, info, cvPoint(20,80), &helpfont, CV_RGB(0,0,0)); 351 382 352 383 #ifdef SHOW_FACES … … 356 387 int x=(facebank.GetFaceWidth()+1)*ii->first; 357 388 int y=imgsize.height-facebank.GetFaceHeight(); 358 BlitImage(ii->second->m_Image, img,cvPoint(x,y));389 BlitImage(ii->second->m_Image,small_img,cvPoint(x,y)); 359 390 } 360 391 #endif 361 392 362 cvShowImage( "result", img );393 cvShowImage( "result", small_img ); 363 394 364 395 #ifdef SAVE_FRAMES 365 396 char name[256]; 366 397 sprintf(name,"out-%0.4d.jpg",framenum); 367 cvSaveImage(name, img);398 cvSaveImage(name,small_img); 368 399 #endif 369 400 370 cvReleaseImage( &gray );371 401 cvReleaseImage( &small_img ); 372 402 }
Note: See TracChangeset
for help on using the changeset viewer.