这只是我尝试过的一些非常标准的代码。我要做的是将两个眼球和一张嘴放在一个非常稳定的肖像图像上。这是我尝试过的:
CIImage *image = [CIImage imageWithCGImage: [tim.image CGImage]];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options: [NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey: CIDetectorAccuracy]];
NSArray *feats = [detector featuresInImage: image];
for (CIFaceFeature *faceFeature in feats) {
if (faceFeature.hasLeftEyePosition) {
eyeLeft.center = faceFeature.leftEyePosition;
}
if (faceFeature.hasRightEyePosition) {
eyeRight.center = faceFeature.rightEyePosition;
}
if (faceFeature.hasMouthPosition) {
moth.center = faceFeature.mouthPosition;
}
}
问题是我的图像确实翻译了它们的中心,但是到了一个非常尴尬的位置(AKA 不是正确的位置)!尽管它们确实以正确的距离关系出现,但嘴在顶部。这意味着有:
上面有一张嘴,下面几厘米有两个相隔几厘米的眼球。所以它们根据图像视图正确缩放,它们只是在错误的地方