首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CIFaceFeature hasSmile总是错误的

CIFaceFeature hasSmile总是错误的
EN

Stack Overflow用户
提问于 2015-04-20 19:05:24
回答 1查看 1.9K关注 0票数 4

使用以下方法检测图像中的人脸:

代码语言:javascript
复制
var ciImage  = CIImage(CGImage:imageView.image!.CGImage)
var ciDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil,
  options: [
    CIDetectorAccuracy: CIDetectorAccuracyHigh,
    CIDetectorSmile: true,
    CIDetectorEyeBlink: true
  ])

var features = ciDetector.featuresInImage(ciImage)

for feature:CIFaceFeature in (features as! [CIFaceFeature]) {
   println("has smile: \(feature.hasSmile)")
}

我在许多图像上运行了以前的代码。hasSmile总是返回false。

如何配置面部检测以正确检测微笑?

EN

回答 1

Stack Overflow用户

发布于 2015-04-20 19:19:20

在"CIFaceDetector hasSmile“上快速搜索google可以在iOS 7中的笑脸和闪烁检测上获得这个链接。

看起来您需要使用不同形式的ciDetector.featuresInImage调用。Objective中的代码如下所示:

代码语言:javascript
复制
NSDictionary *options = @{ CIDetectorSmile: @(YES), CIDetectorEyeBlink: @(YES),};
NSArray *features = [detector featuresInImage:image options:options];

在Swift中,应该是这样的:

代码语言:javascript
复制
let options: [NSObject: AnyObject] = 
  [CIDetectorSmile: true, CIDetectorEyeBlink, true]
var features = ciDetector.featuresInImage(ciImage, options: options)
票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29756283

复制
相关文章

相似问题

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