使用以下方法检测图像中的人脸:
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。
如何配置面部检测以正确检测微笑?
发布于 2015-04-20 19:19:20
在"CIFaceDetector hasSmile“上快速搜索google可以在iOS 7中的笑脸和闪烁检测上获得这个链接。
看起来您需要使用不同形式的ciDetector.featuresInImage调用。Objective中的代码如下所示:
NSDictionary *options = @{ CIDetectorSmile: @(YES), CIDetectorEyeBlink: @(YES),};
NSArray *features = [detector featuresInImage:image options:options];在Swift中,应该是这样的:
let options: [NSObject: AnyObject] =
[CIDetectorSmile: true, CIDetectorEyeBlink, true]
var features = ciDetector.featuresInImage(ciImage, options: options)https://stackoverflow.com/questions/29756283
复制相似问题