Face eye tracker iphone

I used the code here to find Face. I try to draw both eyes and face. But I can only show my eyes or face, depending on which statements I write first. How to do it?

// Detect faces std::vector faces; _faceCascade.detectMultiScale(mat, faces, 1.1, 2, kHaarOptions, cv::Size(60, 60)); //Detect eyes std::vector eyes; _eyesCascade.detectMultiScale(mat, eyes, 1.1, 2, kHaarOptions, cv::Size(30, 30)); 

Here eyes.size () = 0. If I change the position of the two statements, I get eye.size () = 2 and faces.size () = 0

+6
source share
3 answers

If your goal is to restore the position of the face and eyes in iOS, why don’t you use the capabilities of CoreImage?

 CIImage *image = [CIImage imageWithContentsOfURL:[NSURL fileURLWithPath:@"image.jpg"]]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:CIDetectorAccuracyHigh, CIDetectorAccuracy, nil]; CIDetector *faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:options]; NSArray *features = [faceDetector featuresInImage:image]; for(CIFaceFeature* faceFeature in features) { CGRect faceSize = faceFeature.bounds.size; PointF leftEyePosition; PointF rightEyePosition; PointF mouthPosition; if(faceFeature.hasLeftEyePosition) leftEyePosition = faceFeature.leftEyePosition; //do the same for right eye and mouth } 

It does not use OpenCV, but you get a free oral cavity.

+14
source

It is logical to simply copy the general input parameters, i.e. copy the mat into mat2, and use it as a second input.

0
source

A variable mat is an array and is passed by value. Inside the function, the values ​​inside the mat change, and so, whatever operator you put first is executed properly, what kind of mat changes for the second operator. Therefore, create a deep copy of the mat variable before any of the statements and use the mat-copy variable instead of mat in the second expression.

0
source

All Articles