【发布时间】: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