Library: Issues when detecting 2D codes because of poor (auto)focusing

Created on 16 Dec 2019  路  8Comments  路  Source: zxing-js/library

When trying https://zxing-js.github.io/library/examples/multi-camera/, the detection rate was quite poor in my tests due to the fact it was impossible to do the focus.

Would it be possible to add this feature in the demo:

On "tap" event (i.e. when tapping the image viewer with one finger), trigger a re-focus / auto-focus.

This is quite common in most camera apps, and I think it would increase the detection rate for users.
What do you think @odahcam @werthdavid ?

feature request nice to have no-issue-activity

Most helpful comment

.decodeOnceFromConstraints(
        {
          video: {
            aspectRatio,
            facingMode: 'environment',
            focusMode: 'continuous',
            frameRate: { ideal: 10, max: 15 },
            width: { min: 640, ideal: 2048, max: 4048 },
          },
          audio: false,
        },
        videoRef.current,
      )

With focusMode: 'continuous' you can enable autofocus.

All 8 comments

Do you have/know any content about this feature for us to take a look?

Thank you for your answer @odahcam. It's just a normal barcode photo but very blurry, because the phone camera did not make the autofocus.

Is there a way from code to ask the device's camera to trigger an autofocus?
This would be very useful.

Well, that was exactly what I wanted to know. 馃槃 I'm afraid we'll have to search for it together.

Stale issue message

.decodeOnceFromConstraints(
        {
          video: {
            aspectRatio,
            facingMode: 'environment',
            focusMode: 'continuous',
            frameRate: { ideal: 10, max: 15 },
            width: { min: 640, ideal: 2048, max: 4048 },
          },
          audio: false,
        },
        videoRef.current,
      )

With focusMode: 'continuous' you can enable autofocus.

Good news! Thanks for taking time to coming all the way back here after so long.

For various reasons what @DavidSichau is suggesting didn't work for me. For instance I want to be able to toggle between different cameras and not let the library decide which camera to open.
Also I am trying to add the autofocus while decoding with the use of applyConstraints() on the stream with no success till now.
@odahcam do you believe that adding a constraints object to decode functions in order to pass more constraints to those functions and not just the deviceId could be possible?

It already exists. See the "broswer" repository.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helloo0-0oword picture helloo0-0oword  路  8Comments

robbelroot picture robbelroot  路  6Comments

kenlyon picture kenlyon  路  6Comments

sethusuryateja picture sethusuryateja  路  6Comments

Hopingocean picture Hopingocean  路  3Comments