1

私はiOSプログラミングに不慣れで、コア画像のリンク、回答、チュートリアルをたくさん検索しましたが、それでも正確には理解できません。私はボタン、簡単なものを持っているテストアプリを持っています、私がいくつかのフィルターボタンを押すとそれがフィルターを作ってそれを表示する画像を持っています。

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

今、私は目と口を検出し、その周りに長方形や円を描くボタンが欲しいのですが、何色でも何でも構いません。私はまで来ました

- (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){}
}

そして今、私は問題を抱えています(そしてこれが正しいスタートであるかどうかはわかりません)。次に何をすべきか知りたいので助けてください..事前にありがとう

4

1 に答える 1

1

どうですか(コンパイルしていませんが、近いはずです):

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

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context, 1.0);

    CGContextAddRect(context, faceRect);
    CGContextDrawPath(context, kCGPathStroke);
}
于 2013-03-26T13:52:22.607 に答える