私は現在、RedLaser APIを利用したバーコードスキャンアプリを完成させる最終段階に入っています。しかし、イメージ内で領域を設定してバーコードを識別する場所を設定することができないという難点が1つあります。これは、完全なイメージからバーコードを識別し、私が設定したActiveRegionではないことを示します。RedLaser SetActiveRegion iPhone
は、私は私の正確なコードのインフロントを持っていないが、それは事実上、この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];
}
誰でもマニュアル活性領域とRedLaserを設定した経験がありますか?私は3.1.0のiPhoneライブラリを使用しています(また、バグがあった場合に備えて最新の3.2.4も試しました)。
これは正しい道に私を導きます、ありがとう。その他のヘルパーコードは次のとおりです。 BOOL barcodeWithinRegion = true; for([foundCode barcodeLocation]のNSValue *キー){// // CGPointValuesの配列 \t CGPointポイント= [キーCGPointValue]; \t if(point.x <0 || point.x> 320) \t \t barcodeWithinRegion = false; \t if(point.y <50 || point.y> 200) \t \t barcodeWithinRegion = false; } (foundCode && barcodeWithinRegion){... – Wollan