我使用以下代码从图像中检测人脸:
-(void)markFaces:(UIImageView *)imagePick {
CIImage* image = [CIImage imageWithCGImage:imagePick.image.CGImage];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
NSDictionary* imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6] forKey:CIDetectorImageOrientation];
NSLog(@"imageOptions %@",imageOptions);
NSArray* features = [detector featuresInImage:image options:imageOptions];
if([features count] > 0)
{
NSLog(@"Face Found");
}
else
{
NSLog(@"Face not Found");
}
}
如果我从横向模式单击快照,此算法将不起作用。为什么?任何帮助,将不胜感激。
提前致谢