ios – 面部追踪器找到眼睛iphone

前端之家收集整理的这篇文章主要介绍了ios – 面部追踪器找到眼睛iphone前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我用 the code from here找到了Face.我试图画出眼睛和脸.
但我只能根据我先写的哪个陈述来显示眼睛或脸部.这该怎么做?
// 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,cv::Size(30,30));

这里eyes.size()= 0.如果我互换两个语句的位置,我得到eyes.size()= 2和faces.size()= 0

解决方法

如果您的目标是检索iOS上的面部和眼睛位置,为什么不使用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
}

它不使用OpenCV,但你可以免费获得口位.

原文链接:https://www.f2er.com/iOS/330293.html

猜你在找的iOS相关文章