yugasun / qrcode-decoder

🤘Tool for decoding qrcode by image,video or camera.
https://yugasun.github.io/qrcode-decoder/
MIT License
97 stars 35 forks source link

Use Rear Camera in Mobile Device #6

Closed incredible888 closed 2 years ago

incredible888 commented 4 years ago

Hi,

May i know how to use rear camara to decode QR.

Currently i only manage to use front camera as default.

Below is my code:

 let qr = new QrcodeDecoder();
  setTimeout(() => {
            try {
                var videoElem = document.querySelector("video");
                qr.decodeFromCamera(videoElem).then((res) => {
                    console.log(res);
                    if (res['data']) {
                        qr.stop();
                    }
                });
            } catch (error) {
                alert(error);
            }
        }, 200);
incredible888 commented 4 years ago

Update:

Try to modify in

node-modules/qrcode-decoder/dist/index.js. line 37 node-modules/qrcode-decoder/dist/index.esm.js. line 33 node-modules/qrcode-decoder/dist/index.aio.min.js node-modules/qrcode-decoder/dist/index.aio.js 16724

this.videoConstraints = { video: true, audio: false, facingMode: 'environment' };

still failed to use back camera.

yittoo commented 3 years ago

bump. I'm having this issue aswell

yugasun commented 2 years ago

Latest version support use rear camera now, refer to https://github.com/yugasun/qrcode-decoder/commit/7d77236fc02b8bcf665fb8dc7f57e9f0543ceb38