BrowserQRCodeReader doesn't focus when I use rear camera
See original GitHub issueHi! 😋
Firstly, thanks for developing this great library. My problem is the following, I’m developing a web app that allows user to scan QR codes.
===================================================================================
async function scanCode() {
try {
const codeReader = new BrowserQRCodeReader();
const previewElem = document.querySelector(
"#test-area-qr-code-webcam > video"
);
const controls2 = await codeReader.decodeOnceFromConstraints(
{
video: {
aspectRatio: 1.7777777778,
facingMode: 'environment',
focusMode: 'continuous',
frameRate: { ideal: 30, max: 60 },
width: { min: 640, ideal: 640, max: 640 },
},
audio: false
},
previewElem
)
setSerialNumber(controls2.text)
} catch (error) {
console.log(error);
}
}
The result is this:
And if I just set the following config, app uses front camera and autofocus works perfectly fine but, scan codes using front camera is quite uncomfortable.
const controls2 = await codeReader.decodeOnceFromConstraints(
{
video: true,
audio: false,
},
previewElem
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
SOLVED: Rear facing camera won't auto focus - iPhone 8 - iFixit
The motor is damaged on the rear camera so it can't focus. This happens usually after the phone is dropped numerous times.
Read more >Camera doesn't focus anymore | XDA Forums
I changed the rear cameras,but now sometimes it takes good picture and sometimes not. I reset it and no change.What should I do?...
Read more >Lenovo-Duet-rear-camera-doesn-t-focus - English Community
Lenovo Duet rear camera doesn't focus. When taking photos the rear camera does not focus / autofocus, everything is blurred. Front camera ...
Read more >[Solved] Why iPhone Camera Won't Focus and How to Fix It
How to Fix iPhone Camera Won't Focus Issue. 1. Tap the iPhone. Use a piece of napkin, or just your palm to tap...
Read more >Surface book Rear camera not focusing - Microsoft Community
I am facing a problem with the rear camera not being able to take any ... You can follow the question or vote...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been playing around with library for quite some time and here is what I’ve learnt.
In the past it was easy. Smartphone had just two cameras. A front-facing and a back-facing. But now with mobiles becoming more sophisticated, suddenly they have multiple lenses, wide lenses and zoom lenses. Unfortunately the browser / smartphone / library isnt always correct when choosing a default lense (I’ve experienced problems mostly with Samsung phones), with some lenses being unusable for close up Scanning, as they are unfocused. Basically the only solution I found is providing a dropdown to the user, where he can select his lenses (and potentially store the selection in a cookie).
Curious: Did someone else come up with a different solution?
Yes, of course
How to display a select box with the various lenses
When loading the codeReader, do as follows:
If it helps (and not published yet): I’m trying to help improve the documentation. Here is a branch with a more enriched documentation. Have a look at it. You might get some more ideas (and maybe some feedback): https://github.com/fydelio/browser/tree/improved_documentation