In your face!

Using OpenCV and the small class in C + + to manipulate the missile ( go ), I created a face detector in Visual C + + to automatically provide to the missile launcher a target position.

First I show you some results and then I’ll explain how I did it.

Face detector
Face detector
Face detector
Face detector

What you see there, is the output of OpenCV program. The face detector has a margin of error, if the target covers his face or the face is not in front, the system lose the target, however it’s quite robust, even with glasses and a considerable distance aim the target very well.

I’ve distorted the histogram of the video to alter the contrast and quality, I added nonsense texts to decorate and of course, tintered red. T-800 style.

The code for this purpose isn’t very complicated to understand ( frame_copy is a webcam image in an instant of time and frameSizeImg is a completely red png image):

// Effects
// Histogram / contrast
IplImage *out = cvCreateImage ( cvGetSize(frame_copy),IPL_DEPTH_8U,1);
cvConvertImage(frame_copy,out);
cvEqualizeHist(out,out);
 
// Red filter (in Memoriam of Arnold)
cvConvertImage(out, frame_copy);
cvSetImageROI(frame_copy, cvRect(0,0,frame_copy->width,frame_copy->height));
cvAddWeighted(frame_copy, 1, frameSizeImg, 1, -100, frame_copy);
cvResetImageROI(frame_copy);
 
// Text
cvPutText (frame_copy,"ALL DEFENSE SYSTEMS",cvPoint(20,150), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"ACTIVE STATUS 3583A",cvPoint(20,170), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"I/O LEVELS AT MAX",cvPoint(20,180), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"-------------------",cvPoint(20,186), &font, cvScalar(255,255,255));
cvPutText (frame_copy,actionStr,cvPoint(20,198), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"DEVICE LOADED",cvPoint(20,220), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"CHECKSUM: 4390",cvPoint(500,210), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"SEARCH AND DESTROY MODE",cvPoint(426,240), &font, cvScalar(255,255,255));
cvPutText (frame_copy,"FULL ISO LEVELS",cvPoint(500,250), &font, cvScalar(255,255,255));
cvPutText (frame_copy,acquireStr,cvPoint(frame_copy->width/2 - 140,frame_copy->height - 40), &font2, cvScalar(255,255,255));

For face detection I used the Viola-Jones method.
OpenCV automates the process of face recognition to the point where just 4 or 5 lines of code are needed to implement something standard. The core of the project is this line:

CvSeq* faces = cvHaarDetectObjects( img, cascade, storage,
                                    2, 2, CV_HAAR_DO_CANNY_PRUNING,
                                    cvSize(40, 40) );

Where img is an image of the camera at time of face detection and cascade the object that has the information of HaarCascades . The other parameters are options to alter the detection as desired.

Video of gift:

This entry was tagged as , , ,

Leave a Reply

Your email address will not be published.