New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera direction invalid with new release #128

Closed
AndrePinto-NET opened this Issue Sep 28, 2016 · 17 comments

Comments

Projects
None yet
9 participants
@AndrePinto-NET
Copy link

AndrePinto-NET commented Sep 28, 2016

I saw with my Galaxy S7 Edge that with the latest release of quaggaJS, the camera is always facing the user, even if the configuration states the facing mode environment.

At the time I thought that I had some sort of error on my code, but I realized that by just doing a rollback to the previous version of quaggaJS the code works without any issue.

I was able to also reproduce the error on the live example of the project website.

@serratus

This comment has been minimized.

Copy link
Owner

serratus commented Sep 28, 2016

It seems like the problem is not with quaggaJS but with the newest release of Chrome. I'm facing the same issues in other projects. What's your Chrome version? 53?

@AndrePinto-NET

This comment has been minimized.

Copy link

AndrePinto-NET commented Sep 28, 2016

The version that I have on my phone is chrome 53.0.2785.124.

I have another Android phone here, so I will make a test with that one and let you know.

@serratus

This comment has been minimized.

Copy link
Owner

serratus commented Sep 28, 2016

Yeah, that's what I thought. I'll try to track down the error and create a bug for Chrome then.

@AndrePinto-NET

This comment has been minimized.

Copy link

AndrePinto-NET commented Sep 28, 2016

I guess you are correct, because my other phone is running version 52.0.2743.98 and there it works
Strange is that with the previous release of quaggaJs it works on Chrome v 53.

@serratus

This comment has been minimized.

Copy link
Owner

serratus commented Sep 28, 2016

Yeah, that has to do with how I handle the available devices on the phone. The old way was deprecated a long time ago in Chrome, that's why I changed it to only use facingMode in the constraints object, which was working fine in Chrome up until v 52. But it seems like this constraint is completely ignored in Chrome v 53, alongside other constraints. You can get around that by using the following code:

navigator.mediaDevices.enumerateDevices()
  .then(devices => devices.filter(device => device.kind === 'videoinput' && device.label.indexOf('back') !== -1))
  .then(backFacingDevices => console.log(backFacingDevices.map(device => device.deviceId)))
@gkorland

This comment has been minimized.

Copy link

gkorland commented Sep 28, 2016

@serratus thanks for the workaround it works as expected.

@hannupekka

This comment has been minimized.

Copy link

hannupekka commented Sep 29, 2016

So where should I use the workaround given above?

Edit: Nevermind, got it: initialize Quagga inside the last promise.

@serratus

This comment has been minimized.

Copy link
Owner

serratus commented Oct 3, 2016

@serratus

This comment has been minimized.

Copy link
Owner

serratus commented Oct 3, 2016

@AndrePinto-NET I've updated the code in the master-branch with the aforementioned fix. Please give it a try and close the issue if you consider it fixed.

@AndrePinto-NET

This comment has been minimized.

Copy link

AndrePinto-NET commented Oct 4, 2016

I've tested now and it seems to be working fine.

Thanks for your quick update.

@gkorland

This comment has been minimized.

Copy link

gkorland commented Nov 2, 2016

It seems like the bug was not fixed completely, the first time we trigger a scan it opens the front camera, while the second trigger opens the back camera

@jresende18

This comment has been minimized.

Copy link

jresende18 commented Jan 13, 2017

Someone has it working?

@LaurentSouchet-Orange

This comment has been minimized.

Copy link

LaurentSouchet-Orange commented Jun 1, 2017

@bpcbb

This comment has been minimized.

Copy link

bpcbb commented Apr 16, 2018

Has someone gotten this to work? testing on my android phone and it is always picking the user facing camera even though the facingMode = "environment". I noticed that at least on my phone when doing the enumerateDevices the user camera is been returned first.

@ericblade

This comment has been minimized.

Copy link
Collaborator

ericblade commented Apr 17, 2018

works as expected here with my Nexus 5, recently ran through it on Android 5, 6, 7, and 8 on that device. at least, with facingMode = 'environment', haven't tried the other way.

it's a bit messy to figure out with extensive use of jQuery (wow, reading jQ code is obnoxious), but there is manual camera selection code in https://github.com/serratus/quaggaJS/tree/master/example in live_w_example .. it looks like you get the camera id from enumerateDevices() and then pass it to Quagga.init() as inputStream.constraints.deviceId . . . .

@geersch

This comment has been minimized.

Copy link

geersch commented Oct 31, 2018

I had this issue recently in a Cordova app which used Crosswalk v23 and was thus provided with Chromium 53. The workaround suggested by @serratus works for me.

PS: I also tested this workaround outside of Crosswalk, for example on an iPhone in mobile Safari and there I noticed that the label was being translated to whatever language my phone was set to (Dutch in my case). So this might be something you have to take into account.

@ericblade

This comment has been minimized.

Copy link
Collaborator

ericblade commented Nov 1, 2018

facingMode was deprecated quite some time ago, you should be using individual camera selection. However, Android Chrome won't prompt for camera access when you enumerateDevices(), it only prompts when you actually attempt to open the camera. This means you can't get permissions to enumerate, until after you've already tried to use the camera once.

Not much we can do about that, but it leaves end users requiring an odd set of hoops to go through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment