以下のように 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];
}];
}