I want to take pictures of the user camera. This component, has a video html element and a canvas html element.
When the component is mounted I get the user media stream with the following constraints:
constraints: {
audio: false,
video: {
facingMode: "environment",
width: { min: 640, ideal: 1920, max: 1920 },
height: { min: 400, ideal: 1080, max: 1080 },
},
}
The component takes the picture sucessfully if I have Auto-Rotate turned on, because it rotates the browser and the camera.
If I have Auto-Rotate turned off, only the camera sensor is rotated and not the browser and then the picture that is expected to be horizontally turns out to be vertically (Portrait), because thats how the video element is presented.
I have also tried reading the exif, but noticed it cant be read from canvas element or video element.
I have tried orientation events but they don't fire when Auto-Rotate is turned off and it is right because the page doesn't rotate but the camera will always rotate by itself.
But is there a way to lock the camera from not rotating at all or to detect that rotation? Should I use device motion events? (overkill for sure :D)
This component also has to work with Android and IOS devices.
CodePen Link to reproduce this problem Note that you must have auto-rotate turned off in order to reproduce this. Tested on OnePlus 8 Pro.
(this codepen was forked from here, I have just added more constraints to get the right camera Vue Webcam Camera Capture)