문제

i am new to iOS programming, and i have searched a lot of core image links, answers and tutorials but i still don’t understand exactly. I have a test app who have buttons, easy stuff, i have image when i press some filter button it makes filters and show it.

CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"pic1.JPG"]];
    CIFilter *colorControls = [CIFilter filterWithName:@"CIColorControls"];
    [colorControls setValue:inputImage forKey:@"inputImage"];
    [colorControls setValue:[NSNumber numberWithFloat:0.5f] forKey:@"inputSaturation"];
    [colorControls setValue:[NSNumber numberWithFloat:0.8f] forKey:@"inputContrast"];
    [colorControls setValue:[NSNumber numberWithFloat:0.4f] forKey:@"inputBrightness"];
    CIImage *outputImage = [colorControls valueForKey:@"outputImage"];
    CIContext *context = [CIContext contextWithOptions:nil];
    theImageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];

now i would like to have a button who would detect eyes and mouth and draw rectangles or circles around it, it doesn’t matter what and what color. i have come until

- (IBAction)detectFace:(id)sender
{
    CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"pic1.JPG"]];
    CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                              context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
    NSArray* features = [detector featuresInImage:inputImage];
   for (CIFaceFeature *faceFeature in features){}
}

and now i have a problem (and i am not sure if this is right start). Please help i would like to know what to do next..thank you in advance

도움이 되었습니까?

해결책

How about (haven't compiled it, but should be close):

for (CIFaceFeature *faceFeature in features){
        CGRect faceRect = faceFeature.bounds;

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context, 1.0);

    CGContextAddRect(context, faceRect);
    CGContextDrawPath(context, kCGPathStroke);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top