gpt4 book ai didi

ios - 从图像 ZBar 扫描条形码

转载 作者:行者123 更新时间:2023-11-29 03:10:53 26 4
gpt4 key购买 nike

我当时使用 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:^{}];

}

最佳答案

zbar 不会为您修图。它会为您提供未经修改的扫描图像。

你可以得到裁剪后的图像(扫描仪 View 矩形中的那个)

- (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];
//...
}

关于ios - 从图像 ZBar 扫描条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22267960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com