меня captured image
в то время как scanning QRCode
, как это:
1) Во-первых добавить свойство AVCaptureStillImageOutput's
@property (strong, nonatomic) AVCaptureStillImageOutput *stillImageOutput;
2) Добавить сеанс предустановку в AVCaptureSession
после инициализации его
[self.session setSessionPreset:AVCaptureSessionPreset640x480];
3) Теперь добавьте AVCaptureStillImageOutput's
в качестве выходного сигнала в AVCaptureSession
// Prepare an output for snapshotting
self.stillImageOutput = [AVCaptureStillImageOutput new];
[self.session addOutput:self.stillImageOutput];
self.stillImageOutput.outputSettings = @{AVVideoCodecKey: AVVideoCodecJPEG};
4) Марка добавить ниже код для захвата отсканированного изображения в методе делегата captureOutput:didOutputMetadataObjects:fromConnection:connection
__block UIImage *scannedImg = nil;
// Take an image of the face and pass to CoreImage for detection
AVCaptureConnection *stillConnection = [self.stillImageOutput connectionWithMediaType:AVMediaTypeVideo];
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:stillConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if(error) {
NSLog(@"There was a problem");
return;
}
NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
scannedImg = [UIImage imageWithData:jpegData];
NSLog(@"scannedImg : %@",scannedImg);
}];
Для ссылки использования CodeScanViewController
Thats it @Enjoy