gpt4 book ai didi

iphone - RedLaser 设置事件区域 iPhone

转载 作者:行者123 更新时间:2023-11-29 04:48:23 25 4
gpt4 key购买 nike

我目前正处于完成使用 RedLaser API 的条形码扫描应用程序的最后阶段。但存在一个挑战,因为我无法设置图像中应识别条形码的区域。它从完整图像中识别条形码,而不是我设置的 ActiveRegion。

我面前没有确切的代码,但它实际上是此 source 的副本:

(void) setPortraitLayout
{
// Set portrait
self.parentPicker.orientation = UIImageOrientationUp;

// Set the active scanning region for portrait mode
[self.parentPicker setActiveRegion:CGRectMake(0, 100, 320, 250)];

// Animate the UI changes
CGAffineTransform transform = CGAffineTransformMakeRotation(0);

[UIView beginAnimations:@"rotateToPortrait" context:nil]; // Tell UIView we're ready to start animations.
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve: UIViewAnimationCurveLinear ];
[UIView setAnimationDuration: 0.5];

redlaserLogo.transform = transform;

//A visible frame to aim with
[self setActiveRegionFrame];

[UIView commitAnimations]; // Animate!
}

(void) setActiveRegionFrame
{
//this just draws up a visible rectangle slightly smaller than supposed ActiveRegion
[_rectLayer setFrame:CGRectMake(self.parentPicker.activeRegion.origin.x - 50, self.parentPicker.activeRegion.origin.y - 50, self.parentPicker.activeRegion.size.width - 50, self.parentPicker.activeRegion.size.height - 50)];
CGPathRef path = [self newRectPathInRect:_rectLayer.bounds];
[_rectLayer setPath:path];
CGPathRelease(path);
[_rectLayer needsLayout];
}

有人有使用手动 ActiveRegion 设置 RedLaser 的经验吗?我正在使用 3.1.0 iPhone 库(还尝试了最新的 3.2.4,以防之前出现错误)。

最佳答案

我在 RedLaser 工作,所以我可以提供帮助。我还建议您引用我们的 SDK zip 中的“使用 RedLaser SDK”文件。

简短回答:ActiveRegions 已被弃用。请改用 BarcodeResult 类。说明第 6-9 页

更长的答案:BarcodeResult 类包含所有扫描的条形码的位置(NSValues 的 NSArray)。您可以告诉您的应用忽略返回值不在您所需区域内的所有结果。

PDF 中的相关文本:

Finally, each barcode will have a NSArray of NSValues, where each NSValue is a CGPoint, indicating where we located the barcode. The coordinates of the points will be in the same coordinate system as the BarcodePickerController's bounds. The first point in the array will be the top left of the barcode, and the second will be the top right of the barcode. Note that if a barcode is recognized 'upside down', these points will be in the lower right and lower left when viewed onscreen. Also, because the preview is mirrored when using a device's front camera for recognizing, the points aren't necessarily in clockwise winding order either. The array will usually contain 4 points, but it could contain more or fewer.

The path produced from these points may not cover the entire barcode, and may be only one pixel high or wide. The barcode location is only updated on frames where the barcode is actually recognized, so the longer it's been since mostRecentScanTime, the less likely it is that the barcode is still at that position in the camera preview. Barcodes recognized by the partial recognition method (used for some long barcodes, allowing the user to point the camera at each part of the barcode and piece the full code together) will only have recognition information on the most recent part of the barcode to be scanned.

如有其他问题,请通过http://support.redlaser.com/询问-- 我们的响应时间相当快。

关于iphone - RedLaser 设置事件区域 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9268498/

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