首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CIFaceFeature只能在LandscapeLeft中运行

CIFaceFeature只能在LandscapeLeft中运行
EN

Stack Overflow用户
提问于 2012-06-20 06:14:19
回答 1查看 488关注 0票数 0

a tutorial from iTunes U上学习如何进行人脸检测(教程只在视频中提供,并不是在线写的,所以我不能直接发布链接)。基本上,我已经让人脸检测起作用了,但前提是手机处于LandscapeLeft模式。

你知道为什么它是这样工作的吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-20 07:21:19

如果不看你的代码,很难说,但我猜你没有设置CIDetectorImageOrientation?当图像方向和探测器方向设置为不匹配时,我遇到过检测失败。

下面的一些代码--不是剪切粘贴,而是一个粗略的例子。

代码语言:javascript
复制
- (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);

});
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11110276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档