beeware/toga

Add QR code scanning API

Opened this issue · 0 comments

What is the problem or limitation you are having?

Toga has a camera API, implemented on iOS, Android and macOS. However, this interface is focussed on taking photographs, using an external camera panel/app.

Another common use case for cameras is to scan QR codes. Toga should have an API for capturing QR codes.

Describe the solution you'd like

An API, similar to await app.camera.take_photo to capture QR codes. await app.camera.capture_qr_code would be an obvious starting point.

Calling the API would display a full-page live camera view (with a QR code "target" square); when a QR code is seen, the window would be dismissed, and the coroutine return the captured QR code.

As part of implementing this, it may be necessary to add a "live camera view" widget. That widget would allow the user to define a box that will display a view of the live camera. That widget should then have a async def take_photo() API, and handler for on_qr_code() that is invoked whenever a QR code is "seen". If a on_qr_code handler is provided, the camera view would be displayed with a target.

Describe alternatives you've considered

Leave QR code implementations to the user to implement.

Additional context

User @ezzygarmyz has implemented a QR scanner for Android in this project. This demonstrates how Android QR code APIs can be invoked to capture

iOS/macOS implementations will need to use AVCaptureSession APIs; there are many examples of usage online (e.g., this one and this one)