BarcodeScanner.Mobile icon indicating copy to clipboard operation
BarcodeScanner.Mobile copied to clipboard

BoundingBox has wrong values

Open criistii opened this issue 3 years ago • 8 comments

The BoundingBox property does not return values in the coordinates of the view. My goal is to determine what barcode is closest to the center of the screen when multiple barcodes are present.

Also, note that using a Rect may not be the best idea for a BoundingBox, since the barcode can be at any angle. I think that an array of 4 points would describe it better.

criistii avatar Jul 21 '22 14:07 criistii

@criistii He use data from Android which is property BoundingBox (left, top, right, bottom). And mapped to Microsoft.Maui.Graphics.Rect with contructor (X, Y, Width, Height). That wrong

I fix to use: obj[i].BoundingBox = new Microsoft.Maui.Graphics.Rect( obj[i].BoundingBox.X, obj[i].BoundingBox.Y, obj[i].BoundingBox.Width - obj[i].BoundingBox.X, obj[i].BoundingBox.Height - `obj[i].BoundingBox.Y);

image

tomahutbui avatar Nov 03 '22 03:11 tomahutbui

First of all sorry for the really late response. Did not manage to get back to this issue earlier.

@tomahutbui you are right that your code correctly converts to a Maui Rectangle. Even so, I noticed that the bounding box is highly inaccurate when drawn on screen.

PS: IMO Microsoft.Maui.Graphics.Rect should not be used since the app should work on Forms as well

criistii avatar Dec 01 '22 12:12 criistii

Anyone got a solution for this issue? Been trying to get a working solution for identifying the location of the BoundingBox property but I can't seem to get it working. Is it even possible?

kebabmestarn avatar Dec 23 '22 09:12 kebabmestarn

@kebabmestarn I used tomahutbui's solution and it still was buggy. I ended up verifying just the Y coordinate to get an idea if the barcode is centered. Works reasonably. IMO Any rect is a bad idea to represent barcodes since they can be at an angle. Native barcodes are returned as Point[4]

criistii avatar Dec 28 '22 16:12 criistii

For the bounding box location, it is because the native libraries (Google MLKit) return the native coordination, I tried to use the density to cover it back to Xamarin Forms but it still not quite accurate.

JimmyPun610 avatar Jan 03 '23 15:01 JimmyPun610

Anyone got a solution for this issue? Been trying to get a working solution for identifying the location of the BoundingBox property but I can't seem to get it working. Is it even possible?

https://github.com/tmoncorp/Xamarin.Barcode good luck

pulmuone avatar Mar 29 '23 14:03 pulmuone

Any solutions to this?

adrianotrentim avatar Jul 18 '23 21:07 adrianotrentim

Anyone got a solution for this issue? Been trying to get a working solution for identifying the location of the BoundingBox property but I can't seem to get it working. Is it even possible?

https://github.com/tmoncorp/Xamarin.Barcode good luck

this is perfect

Sashi13 avatar Aug 16 '23 07:08 Sashi13