Ios7 从图像库ios 7扫描条形码
我想扫描ios 7中照片库中的条形码或二维码图像。在ios 7中,我们可以使用摄像头扫描条形码图像,但我没有找到任何方法从UIImagePickerController中选择条形码图像并进行扫描。AVFoundation框架中是否有可用的方法?Ios7 从图像库ios 7扫描条形码,ios7,avfoundation,barcode-scanner,avcapturesession,Ios7,Avfoundation,Barcode Scanner,Avcapturesession,我想扫描ios 7中照片库中的条形码或二维码图像。在ios 7中,我们可以使用摄像头扫描条形码图像,但我没有找到任何方法从UIImagePickerController中选择条形码图像并进行扫描。AVFoundation框架中是否有可用的方法? 帮助我..有许多API可用于条形码扫描:- Softek条形码阅读器SDK ZBar条形码阅读器 精明的 红色激光 中兴 如果您只想使用AVfoundation framework,以下是本教程的链接。。 这是开始读取条形码的代码 - (BOOL)s
帮助我..有许多API可用于条形码扫描:- Softek条形码阅读器SDK ZBar条形码阅读器 精明的 红色激光 中兴 如果您只想使用AVfoundation framework,以下是本教程的链接。。 这是开始读取条形码的代码
- (BOOL)startReading {
NSError *error;
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (!input) {
NSLog(@"%@", [error localizedDescription]);
return NO;
}
_captureSession = [[AVCaptureSession alloc] init];
[_captureSession addInput:input];
AVCaptureMetadataOutput *captureMetadataOutput = [[AVCaptureMetadataOutput alloc] init];
[_captureSession addOutput:captureMetadataOutput];
dispatch_queue_t dispatchQueue;
dispatchQueue = dispatch_queue_create("myQueue", NULL);
[captureMetadataOutput setMetadataObjectsDelegate:self queue:dispatchQueue];
[captureMetadataOutput setMetadataObjectTypes:[NSArray arrayWithObject:AVMetadataObjectTypeQRCode]];
_videoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
[_videoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[_videoPreviewLayer setFrame:_viewPreview.layer.bounds];
[_viewPreview.layer addSublayer:_videoPreviewLayer];
[_captureSession startRunning];
return YES;
}
并阻止它
-(void)stopReading{
[_captureSession stopRunning];
_captureSession = nil;
[_videoPreviewLayer removeFromSuperlayer];
}
我也有同样的问题,由于支持arm64的体系结构要求,大多数曾经完美运行的32位条形码SDK都被7.1破坏了。Zbar受到影响,ZXing完全退出了iOS平台,剩下的是商业软件包。我尝试了其中一种叫做海牛的方法,它可以工作,但它会从输出中截断条形码的第一个字符。目前,您最好的选择是使用IOS 7.1的商业SDK,或者返回到7.0或6.1并使用Zbar @Stark提出的AVfoundation解决方案可以很好地与摄像头捕获配合使用。我对其进行了一些修改,以识别PDF417、AztecCodes和6个左右的1D条形码,但示例应用程序中的代码无法处理媒体库中的现有图像。我深入搜索,最近的赌注是CoreImage检测,它对图像进行面部识别,不幸的是,目前还没有条形码检测选项