mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.17k stars 1.05k forks source link

❓ How to get cornerPoints of scanned QR #2076

Closed yukta357 closed 9 months ago

yukta357 commented 10 months ago

Question

So far, I've been using ExpoBarcodeScanner, which returns cornerPoints with each result.

I see that Vision Camera returns a frames object, which contains origin coordinates and box dimensions. However, for our use case, this is insufficient. We need all 4 corner points in order to calculate the QRs position in 3D space.

So how would one get corner points with Vision Camera?

Use a frame-processor and let it run for only a single frame whenever a qr is scanned? Or switch to a frame processor entirely, replacing native scanning on ios? Or am I missing something perhaps? :p

What I tried

No response

VisionCamera Version

v3

Additional information

mrousavy commented 10 months ago

Hey!

So the CodeScanner API is a simple, separate lightweight output for the Camera.

The Apple docs suggest that there are two values, .bounds and .corners.

Currently I am using bounds. Is corners what you need?

Same for Android: [boundingBox](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getBoundingBox()) and [cornerPoints](https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getCornerPoints())

yukta357 commented 10 months ago

Yes, indeed, corners is what I need.

On Wed, Oct 25, 2023 at 1:44 PM Marc Rousavy @.***> wrote:

Hey!

So the CodeScanner API is a simple, separate lightweight output for the Camera.

The Apple docs suggest that there are two values, .bounds https://developer.apple.com/documentation/avfoundation/avmetadataobject/1386043-bounds and .corners https://developer.apple.com/documentation/avfoundation/avmetadatamachinereadablecodeobject/2926566-corners .

Currently I am using bounds. Is corners what you need?

Same for Android: boundingBox https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getBoundingBox() and cornerPoints https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getCornerPoints()

— Reply to this email directly, view it on GitHub https://github.com/mrousavy/react-native-vision-camera/issues/2076#issuecomment-1779085171, or unsubscribe https://github.com/notifications/unsubscribe-auth/BARRA63KZEOC75PEMFGXMFTYBD3RVAVCNFSM6AAAAAA6N2UIXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZZGA4DKMJXGE . You are receiving this because you authored the thread.Message ID: @.***>

mrousavy commented 10 months ago

Cool, I think this takes me roughly 3 hours to implement. If you want to sponsor the development of this project, consider sponsoring me on GitHub, usually those rates are $100/h 😄

only1chi commented 10 months ago

@mrousavy I have the same problem and need corners points of the QR code like @yukta357. Can it be derived from the bounds object you provide?

metrix-hu commented 9 months ago

@mrousavy @yukta357 I will try to do a PR on this.

yukta357 commented 9 months ago

Wow, that's great @metrix-hu!