我试图弄清楚如何从用户的相机胶卷中获取图像并在其上运行一些核心图像操作(检测面部)。我能够成功地将图像加载到 uiimageview 中,但由于某种原因,我无法使用该图像来使用核心图像检测人脸。有问题的数组是代码的最后一点,这个数组应该包含 CIFaceFeatures,但它一直是空的。我尝试过使用不同的图像,但仍然无法正常工作。有任何想法吗?
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:nil];
UIImage *image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
self.facePicture.image = image;
CIImage* image = [CIImage imageWithCGImage:self.facePicture.image.CGImage];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
NSArray* features = [detector featuresInImage:image]; //***features array is empty
NSLog(@"array count is %i",features.count); //returns 0
//Code continues with face detection stuff
}