Comments (8)
IMHO this cannot be a bug of zbar-wasm because this module does not control the camera in any way, i.e. it can neither switch beween front and back camera nor prevent this.
Edit: when writing this, I did not consider the example cited below which actually does select a camera.
from zbar-wasm.
Ah, I think in main.js
this needs to be adressed:
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: 'environment' } })
In here we can determine exact deviceID. I will improve and report back when it works.
from zbar-wasm.
Unfortunately, in Safari/iOS this will still only give us some camera facing the environment, not necessarily the high-resolution camera.
In recent WebKit browsers one could add the zoom
capability to the MediaTrackConstraints
, this should prevent fisheye cameras from being selected (only guessing, not tested).
from zbar-wasm.
By selecting the last camera in the available devices most phones return the correct enviroment camera. As such:
// List cameras and microphones.
navigator.mediaDevices.enumerateDevices()
.then((devices) => {
devices.forEach((device) => {
if (device.kind == 'videoinput') {
deviceCam = device.deviceId;
}
});
constraints = {
audio: false,
video: {
width: {
min: 1280,
ideal: 1920,
max: 2560,
},
height: {
min: 720,
ideal: 1080,
max: 1440
},
deviceId: deviceCam
}
}
navigator.mediaDevices.getUserMedia(constraints)
.then(stream => {
videoContainer.srcObject = stream
})
.catch(error => {
})
detectVideo(true);
})
.catch((err) => {
console.error(`${err.name}: ${err.message}`);
});
from zbar-wasm.
Thank you @opicron for your investigation!
I would not feel well, however, including this workaround in the example since I could not find any specification that guarantees that the last device represents the environmental camera.
Instead, I am thinking about replacing the line
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: 'environment' } })
with
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: { exact: 'environment' } } })
which requires rather than just requests a device facing the environment (specified here).
Unfortunately, I do not have an iPhone available for testing. I would appreciate very much if you could test this idea; if this works then I would like to modify the example accordingly.
from zbar-wasm.
Yes, an exact match was my first approach. But that didnt work out unfortunately. The above case works for all iphones in our company. And I see referrals to this solution being adres in multiple forums.
https://www.reddit.com/r/javascript/comments/8eg8w5/choosing_cameras_in_javascript_with_the/
from zbar-wasm.
If we add facingMode: { exact: 'environment' }
to the above example code which gets the devices it might be even more consistent.
from zbar-wasm.
Going to check this too. Thanks for lead.
from zbar-wasm.
Related Issues (20)
- __dirname is not defined with nextjs HOT 1
- Paused when failed to detect unsupported code type. HOT 2
- zbar-wasm doesn't work with nodejs 18
- TypeError: Failed to construct 'URL': Invalid URL HOT 5
- Issue with utf-8 HOT 13
- after 15 june this package giving an error HOT 2
- loading zbar-wasm as ES module fails in Node HOT 2
- webpack error migrating from 0.9.15 -> 0.9.16 HOT 5
- How to bundle zbar.wasm in a module project? HOT 6
- The barcode type DataMatrix is not supported HOT 1
- Please Help : Why i show this error when i tray import the package in Angular 16 HOT 1
- Build fails when using in Next.js App directory router. HOT 2
- [BUG] WebAssembly.Module doesn't parse at byte 1227: invalid opcode 192, in function at index 28 HOT 7
- Feature Suggestion: Allow Passing the Zbar Instance HOT 6
- [BUG] Not able to scan the barcode of this image using this library, however able to scan it with the phone app HOT 5
- Prepare for a NPM release of this package please HOT 1
- [BUG] Combined scan symbol type not recognized HOT 1
- [Enhancement] Allow specifying the URL of the WASM file HOT 2
- [BUG] library not being recognized/provided by vite HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zbar-wasm.