我想将脸部检测添加到我的应用程序,并且我添加的代码给了我一个CGRect,它与脸部无关。iOS,人脸检测,检测远离脸部的位置
下面的代码
CIImage *cIImage = [CIImage imageWithCGImage:self.imageView.image.CGImage];
CIDetector* faceDetector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:[NSDictionary
dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
NSArray *features = [faceDetector featuresInImage:cIImage];
for(CIFaceFeature* faceObject in features)
{
FaceLocation.x = faceObject.bounds.origin.x;
FaceLocation.y = faceObject.bounds.origin.y;
}// Here face location is far off away form the actual face
但这个代码给我一个位置远离实际的脸,我究竟做错了什么?
什么关于边界的大小?你为什么不看完整的界限?当然,原点将在角落。这就是为什么它被称为起源而不是中心 –