*****EDIT******
I was just doing some testing to see if I was missing something and it turns out the imgHolder.image is returning null but it is displaying an image. I am calling this on [void viewDidLoad].
*****EDIT******
I'm creating a simple application that you take a picture with, then it passes that image to another view controller and tries detecting your face in the image. I've tried using many tutorials, and googling the problem but I have no found a solution. The problem is that it will not detect any features no matter how many times I change the code or try another picture. A few of the tutorials I've tried are listed below along with my code.
CIImage* image = [CIImage imageWithCGImage:imgHolder.image.CGImage];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
NSDictionary *imageOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:6]
forKey:CIDetectorImageOrientation];
NSArray* features = [detector featuresInImage:image options:imageOptions];
for(CIFaceFeature* feature in features)
{
UIView* face = [[UIView alloc] initWithFrame:feature.bounds];
[face setBackgroundColor:[[UIColor yellowColor] colorWithAlphaComponent:0.4]];
[self.view.window addSubview:face];
if(feature.hasLeftEyePosition)
{
UIView* eye = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
[eye setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.2]];
[eye setCenter:feature.leftEyePosition];
[self.view.window addSubview:eye];
}
if(feature.hasRightEyePosition)
{
UIView* eye = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
[eye setBackgroundColor:[[UIColor redColor] colorWithAlphaComponent:0.2]];
[eye setCenter:feature.rightEyePosition];
[self.view.window addSubview:eye];
}
if(feature.hasMouthPosition)
{
UIView* mouth = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
[mouth setBackgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.2]];
[mouth setCenter:feature.mouthPosition];
[self.view.window addSubview:mouth];
}
}
NSLog(@"%d", features.count);
http://www.tokbox.com/blog/fun-with-core-graphics-in-ios/ http://b2cloud.com.au/how-to-guides/face-detection-in-ios-5 CIDetector and UIImagePickerController