piderman314 / bardecoder

Detect and decode QR Codes, written in 100% Rust.
MIT License
268 stars 34 forks source link

Retrieve projection matrix? #45

Closed stephanemagnenat closed 1 year ago

stephanemagnenat commented 1 year ago

In some application (e.g. robotics, augmented reality, computer vision, etc.), one might want to use a QR code in order to locate a physical plane and retrieve the matrix between that plane and the camera image. As far as I've seen, bardecoder does not provide a way to retrieve that projection matrix.

It would be helpful to have some support to do so. For example, if bardecoder would return the position of the corners or some key points (with their identity) of the QR code in image coordinate, the caller could construct such a matrix. Can we imagine to add such a feature?

piderman314 commented 1 year ago

Well I think you might manage to do this by using the "advanced mode" as specified in the readme. The "detect" step of the process will return the location of the QR code in the image, which will then get passed to the "qr" step. Probably the easiest is to write a wrapper around bardecoder::detect::LineScan if you want to keep the default implementation.

If all else fails you could also create your own version of the decode function as specified in https://github.com/piderman314/bardecoder/blob/151faab532c443123e89be18e3f49aa947c38d6d/src/decoder.rs#L26-L49 .

I don't think I'll build this into the default implementation but hopefully this will give you some pointers how to get the info, albeit in a bit of a roundabout way :)

stephanemagnenat commented 1 year ago

Thank you for the quick answer!

stephanemagnenat commented 1 year ago

This works, now the issue is that codes in images with perspective transformations are not detected properly (see #48).