iOS Face Detection Issue

前端 未结 4 1160
囚心锁ツ
囚心锁ツ 2021-02-08 10:43

I am trying to use CoreImage\'s face detection in iOS 5 but it is not detecting anything. I am trying to detect faces in an image that was just captured by the camera using thi

4条回答
  •  天涯浪人
    2021-02-08 11:12

    OK, it's always helpful to read the documentation CAREFULLY. In the UIImage docs, under the CIImage property it says: "If the UIImage object was initialized using a CGImageRef, the value of the property is nil." Apparently, the UIImagePickerController does initialize the image from a CGImageRef because this property is indeed nil. To make the above code work, you need to add:

    CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
    

    and change this line:

    NSArray *features = [faceDetector featuresInImage:ciImage];
    

    Another BIG thing I noticed is that face detection from a still image does not really work on the low-res image from the front camera! It works every time when I use the back, high-res camera. Perhaps the algorithm is tuned for high-res...

提交回复
热议问题