1

以下のように AVFoundation で静止画像を撮影していますが、captureImage (UIImage) を使用して別のビュー コントローラーに表示しようとしていますが、その画像を試しても、captureImage はどこにも表示されません。私の質問は、そのcaptureImageをそのまま使用すると、どこでも使用および表示できる完全な画像ですか? 私は AVFoundation カメラ バッファーについて多くのことを見てきましたが、そのイメージをバッファーから実際の UIImage に変換する必要があるかどうかはわかりません。

- (void) captureStillImage
{
    AVCaptureConnection *videoConnection = nil;
    for (AVCaptureConnection *connection in [[self stillImageOutput] connections]) {
        for (AVCaptureInputPort *port in [connection inputPorts]) {
            if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
                videoConnection = connection;
                break;
            }
        }
        if (videoConnection) {
            break;
        }
    }
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection
                                                         completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
                                                            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
                                                            captureImage = [[UIImage alloc] initWithData:imageData];

                                                             [[NSNotificationCenter defaultCenter] postNotificationName: @"photoTaken" object:nil userInfo:nil];
    }];
}
4

1 に答える 1

1

キャプチャ時に画像を出力するためだけに静止画をキャプチャします。AVCaptureVideoPreviewLayer を使用して、AVCam コードのように表示します

于 2013-11-07T01:13:58.627 に答える