EricssonResearch / bowser

A WebRTC browser for iOS developed in the open
BSD 2-Clause "Simplified" License
208 stars 65 forks source link

Environment Camera 90 degrees off #81

Closed cloudis31 closed 8 years ago

cloudis31 commented 8 years ago

Sorry for opening another issue, but when i get a stream from the environment camera on iphones, the image is 90 degrees rotated. I could add an extra operation after drawing to a canvas to rotate the image 90 degrees if it's an iphone, and that may be the way i'll have to do it, but it just seems sort of an ad hoc solution.

I might be doing something wrong, but heres some code, which works on all webrtc enabled browsers correctly, but gives me a 90 degree rotated image on iphones:

width and height are 640x480, and i've tried reversing them, but still getting a 90 degree rotated image

getting the stream:


                var constraints = {
                    "audio": false,
                    "video": {
                      facingMode: "environment"
                    }
                };
                navigator.mediaDevices.getUserMedia(constraints)
                .then(function(stream) {
                    window.stream = stream; // make stream available to console
                     if (window.URL) {
                        cameraVideo.src = window.URL.createObjectURL(stream);
                    } else {
                        cameraVideo.src = stream;
                    }
                    cameraVideo.play();
                })
                .catch(function(error) {
                    console.log('navigator.getUserMedia error: ', error);
                });

drawing to a canvas:

                `videoCanvasContext.drawImage(cameraVideo, 0, 0);`

i originally had:

                `videoCanvasContext.drawImage(cameraVideo, 0, 0, WIDTH, HEIGHT);`

for drawing to the canvas, but this would not actually draw the image, and found out that the image i'm getting from the camera is smaller than what i had width and height set to (now set to 640x480 which covers the entire canvas)

Just in case this is not an actual issue, and i'm just doing something wrong, is there a discussion somewhere i could post a topic on about bowser where i might get some help?

cloudis31 commented 8 years ago

This is a little silly, but i can't say this is actually an issue now because the camera is just not rotating when i rotate the device. when i go to landscape mode, it's displaying properly