Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundingBox has wrong values #129

Open
criistii opened this issue Jul 21, 2022 · 8 comments
Open

BoundingBox has wrong values #129

criistii opened this issue Jul 21, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@criistii
Copy link
Contributor

criistii commented Jul 21, 2022

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 criistii added the bug Something isn't working label Jul 21, 2022
@tomahutbui
Copy link

@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

@criistii
Copy link
Contributor Author

criistii commented Dec 1, 2022

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

@kebabmestarn
Copy link

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?

@criistii
Copy link
Contributor Author

@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]

@JimmyPun610
Copy link
Owner

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.

@pulmuone
Copy link

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

@adrianotrentim
Copy link

Any solutions to this?

@Sashi13
Copy link

Sashi13 commented Aug 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants