我想將臉部檢測添加到我的應用程序,並且我添加的代碼給了我一個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
但這個代碼給我一個位置遠離實際的臉,我究竟做錯了什麼?
什麼關於邊界的大小?你爲什麼不看完整的界限?當然,原點將在角落。這就是爲什麼它被稱爲起源而不是中心 –