我不知道为什么CIFaceFeature总是返回零Rectangle:
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可以工作。
答案 0 :(得分:2)
您应该使用println
来记录信息。或者您可以使用以下内容,
NSLog("%@ face", face.bounds.origin.x.description)
答案 1 :(得分:0)
可能会给出答案的几个问题: