我使用zbar扫描任何条形码,此时此API扫描条形码也扫描图像。 任何人请帮我这样做...假设我的瓶子里有一个Mazza瓶条码就在那里但是特殊的条形码是在橙色塑料上。我当时扫描任何条形码图像zbar扫描橙色条形码...所以我只想记住条形码而不是条形码以外的任何其他部分。
- (void)viewDidLoad
{
[super viewDidLoad];
reader = [ZBarReaderViewController new];
capture = [ZBarCaptureReader new];
capture.captureDelegate = self;
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
label.text = symbol.data;
imageView.image = [info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissViewControllerAnimated:YES completion:^{}];
}
答案 0 :(得分:1)
zbar不会为您修饰图像。它可以为您提供无需修改即可扫描的图像。
您可以获得裁剪后的图像(扫描仪视图矩形中的图像)
- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *img = info[UIImagePickerControllerOriginalImage];
ZBarImage *cropped = [[ZBarImage alloc] initWithCGImage:img.CGImage crop:((ZBarReaderViewController*)imagePicker).scanCrop size:img.size];
//...
}