Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CIFaceFeature points incorrect

this is just some pretty standard code I have tried. What I am trying to do is place two eyeballs and a mouth on a very stable portrait image. Here is what I have tried:

 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;
    }
}

The problem is my images do translate their center, but to a very awkward position (AKA not the right position)! Although they do appear in a correct distance relation, except mouth is at top. What this means is that there is:

A mouth on top, a few centimeters below there are two eyeballs which are a few centimeters apart. So they are scaled correctly according to the image view, they are just in the wrong plac

like image 400
MCKapur Avatar asked Jun 15 '12 11:06

MCKapur


1 Answers

CIImage and UIImage coordinate systems are inverse, so you have to translate the coordinates. For example:

CGPoint ciMmouthCenter = faceFeature.mouthPosition;
CGPoint uiMmouthCenter;
uiMouthCenter.x = tim.image.size.width - ciMouthCenter.x;
uiMouthCenter.y = tim.image.size.height - ciMouthCenter.y;
like image 151
Rok Jarc Avatar answered Sep 30 '22 06:09

Rok Jarc