在a tutorial from iTunes U上学习如何进行人脸检测(教程只在视频中提供,并不是在线写的,所以我不能直接发布链接)。基本上,我已经让人脸检测起作用了,但前提是手机处于LandscapeLeft模式。
你知道为什么它是这样工作的吗?
发布于 2012-06-20 07:21:19
如果不看你的代码,很难说,但我猜你没有设置CIDetectorImageOrientation?当图像方向和探测器方向设置为不匹配时,我遇到过检测失败。
下面的一些代码--不是剪切粘贴,而是一个粗略的例子。
- (void)detectFacialFeatures:(UIImage *)image withHighAccuracy:(BOOL) highAccuracy
{
CIImage* ciImage = [CIImage imageWithCGImage:sourceImage.CGImage];
if (ciImage == nil){
printf("ugh \n");
// bail
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *accuracy = highAccuracy ? CIDetectorAccuracyHigh : CIDetectorAccuracyLow;
NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
CIDetectorAccuracyHigh, CIDetectorAccuracy,
orientation, CIDetectorImageOrientation,
nil];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:options];
NSArray *features = [detector featuresInImage:ciImage];
NSLog(@"features %@", features);
});
}https://stackoverflow.com/questions/11110276
复制相似问题