tauri-apps / tauri-apps/plugins-workspace

feature request: QR code streaming

Open
#2,793 0 comments 0 reactions 0 assignees View on GitHub
plugin: barcode-scanner type: feature request
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

I'm following specifications building my app and those require me to us a specific, ad-hoc protocol for animated QR code.
You can find the standard here: https://developer.blockchaincommons.com/ur/

It looks something like this:

Image

but animated

The issue is that because your impl doesn't know about my standard for qrcode streaming, I have to do the following:
```js
async function startScaningCodes() {
const decoder = new URDecoder();

do {
// Scan the part from a QRCode
// the part should look like this:
// ur:bytes/1-9/lpadascfadaxcywenbpljkhdcahkadaemejtswhhylkepmykhhtsytsnoyoyaxaedsuttydmmhhpktpmsrjtdkgslpgh
const part = await scanQRCode();

// register the new part with the decoder
decoder.receivePart(part);

const x = decoder.estimatedPercentComplete();
scanResult = x.toString();
// check if all the necessary parts have been received to successfully decode the message
} while (!decoder.isComplete());

// If no error has been found
if (decoder.isSuccess()) {
// Get the UR representation of the message
const ur = decoder.resultUR();

// Decode the CBOR message to a Buffer
const decoded = ur.decodeCBOR();

// get the original message, assuming it was a JSON object
const originalMessage = JSON.parse(decoded.toString());
scanResult = originalMessage;
} else {
// log and handle the error
const error = decoder.resultError();
console.log("Error found while decoding", error);
}
}

async function scanQRCode() {
try {
const permission = await checkPermissions();
if (permission == "granted") {
return await uncheckedScanQrCode();
} else {
const permission = await requestPermissions();
if (permission == "granted") {
return await uncheckedScanQrCode();
} else {
return "Permission denied";
}
}
} catch (error) {
console.error("QR code scanning failed:", error);
return JSON.stringify(error);
}
}

```

Which mean entering and exiting the camera context every time I get a bit of data out of it, by scanning a single QRCode.
To give you context I display 10 QR codes by second, but this code only catch one every 1.5second so it takes me about 15-20sec to get the whole data out of it.

I would like instead for the camera to on, and just stream me all the QR codes it finds when it does the frame-by-frame analysis of the video stream.

Expo offers this through the `onbarcodescanned` property https://docs.expo.dev/versions/latest/sdk/camera/#onbarcodescanned
You can see an example of it being used here, for an app following the same standard as mine: https://github.com/SovranBitcoin/Sovran/blob/4e7b3ccdb5237a7f99d3b4258c5dfb68bb79780b/components/layout/Camera.tsx#L172

Do you think it is doable? Is there an alteranative you can think of in the meantime? (would `getUserMedia` + analyzing the stream with some other works here instead)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.