【问题标题】:RedLaser SetActiveRegion iPhoneRedLaser SetActiveRegion iPhone
【发布时间】:2012-03-05 07:49:08
【问题描述】:

我目前正处于完成使用 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,以防之前出现错误)。

【问题讨论】:

    标签: iphone objective-c ios barcode barcode-scanner


    【解决方案1】:

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

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

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

    PDF 中的相关文本:

    最后,每个条码都会有一个由 NSValues 组成的 NSArray,其中每个 NSValue 都是一个 CGPoint,表示我们定位条码的位置。点的坐标将与 BarcodePickerController 的边界在同一坐标系中。数组中的第一个点是条形码的左上角,第二个点是条形码的右上角。请注意,如果条形码被识别为“上下颠倒”,则在屏幕上查看时,这些点将位于右下角和左下角。此外,由于在使用设备的前置摄像头进行识别时预览是镜像的,因此这些点也不一定按顺时针缠绕顺序。该数组通常包含 4 个点,但它可以包含更多或更少。

    从这些点产生的路径可能不会覆盖整个条形码,并且可能只有一个像素高或宽。条形码位置仅在实际识别条形码的帧上更新,因此距离 mostRecentScanTime 时间越长,条形码仍然在相机预览中的该位置的可能性就越小。部分识别方式识别的条码(用于一些长条码,允许用户将摄像头对准条码的各个部分,将完整的条码拼凑在一起)只会对要扫描的条码最近的部分有识别信息.

    如果您有其他问题,请通过http://support.redlaser.com/ 提问——我们的回复时间非常快。

    【讨论】:

    • 这引导我走上正确的道路,谢谢。这是其他人的一些帮助代码: BOOLbarcodeWithinRegion = true; for (NSValue *key in [foundCodebarcodeLocation]) { //CGPointValues 数组 CGPoint point = [key CGPointValue];如果(point.x 320)barcodeWithinRegion = false;如果(point.y 200)barcodeWithinRegion = false; } If (foundCode && 条码WithinRegion) { …
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 2014-11-09
    相关资源
    最近更新 更多