Decoding a set of QR images

I've followed Holger's excellent tutorial on decoding a QR code, using an anonymous callback method to retrieve the result string. This works perfectly on a single QR code.

My app has a folder containing hundreds of QR code jpg images which I need to scan through and decode. How do I keep track of which file corresponds to which returned string when the callbacks are asynchronous?

I was hoping there might be a way to pass the filename as a parameter to the callback routine so it could return it as well as the result string, but the compiler doesn't like that.

I could try waiting for each async call to return before processing the next image file using a semaphore like system, but that feels inefficient and clunky.

Please let me know how I should approach this problem.

Best regards,

Adam

Hi,

This is currently not possible from the component itself. We'll need to investigate if the underlying library that returns the decoded result asynchronously supports something like this or not.

Hi,

Thanks for the reply.

Another thought, I could track the order of the QR images I've submitted and assign the results to the correct files, IF (and only IF) the async callbacks return their results in the same order as the Decode requests were made. It makes sense that the callbacks SHOULD come back in the same order as the requests were made, but it's async so maybe that logic doesn't work.

Any thoughts?

Regards.

Adam

Hi,

The ImageData is retrieved asynchronously. There is a chance the callback will return in the same order if the images are the same size but this can never be guaranteed.

However, we've investigated further and it's possible to extend the component with a method that is capable of passing along a file name. It's not yet clear when we can allocate time to implement it, but we've put it on our list.

Hi,

Thanks for letting me know about the potential development path. I've implemented the semaphore method as a workaround, but if you were able to implement this change at some point, that would be great.

Regards,

Adam