我不知道为什么我得到的CIFaceFeature总是返回零矩形:
import Cocoa
import QuartzCore
let url = NSURL(string:"http://cs620522.vk.me/v620522149/12b59/ijvZ6XJWrw0.jpg");
let ciimg:CIImage = CIImage(contentsOfURL:url);
let cid:CIDetector = CIDetector(ofType:CIDetectorTypeFace, context:nil, options:[CIDetectorAccuracy: CIDetectorAccuracyHigh]);
let results:NSArray = cid.featuresInImage(ciimg, options: NSDictionary());
for r in results {
let face:CIFaceFeature = r as CIFaceFeature;
NSLog("Face found at (%f,%f) of dimensions %fx%f", face.bounds.origin.x, face.bounds.origin.y, face.bounds.width, face.bounds.height);
}

根据NSLogs的数量,CIDetector.featuresInImage似乎可以工作。
发布于 2014-12-08 17:31:09
您应该使用println来记录信息。或者你可以使用以下方法,
NSLog("%@ face", face.bounds.origin.x.description)发布于 2015-01-27 10:37:48
以下几个问题可能会给出一个答案:
https://stackoverflow.com/questions/27363172
复制相似问题