Минимальный код (работающий) для тестирования нового API распознавания лиц iOS 5
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CIImage *ciImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"IMG_0056.JPG"]];
NSLog(@"showing image now");
//[imageView setImage:image];
if (ciImage == nil)
NSLog(@"CIImage is nil");
//imageView.image = [UIImage imageWithCGImage:[context createCGImage:ciImage fromRect:ciImage.extent]];
[imageView setImage:[UIImage imageNamed:@"IMG_0056.JPG"]];
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
@"CIDetectorAccuracy", @"CIDetectorAccuracyHigh",nil];
CIDetector *ciDetector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil
options:options];
NSArray *features = [ciDetector featuresInImage:ciImage];
NSLog(@"no of face detected: %d", [features count]);
NSString *myString = [[NSString alloc] initWithFormat:@"%d face(s) detected\n",[features count]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Face detection" message:myString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}