昨日は、AVFoundationを使ってカメラ画面を起動する方法を書きました。
今日は、引き続き、AVFoundationを使ってカメラ撮影をするプログラムを書きたいと思います。
AVCaptureConnection *stillImageConnection = [stillImageOutput connectionWithMediaType:AVMediaTypeVideo];
AVCaptureVideoOrientation avcaptureOrientation = AVCaptureVideoOrientationPortrait;
[stillImageConnection setVideoOrientation:avcaptureOrientation];
[stillImageConnection setVideoScaleAndCropFactor:1];
[stillImageOutput setOutputSettings:[NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey]];
[stillImageOutput
captureStillImageAsynchronouslyFromConnection:stillImageConnection
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (error) {
}
NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
}
];
最後の [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]でNSDataを取得すれば、もうこっちのものです。前回のプログラムとあわせて利用すると便利かなと。
0 コメント:
コメントを投稿