Cordova windows phone app camera orientation is wr

2019-07-10 05:20发布

问题:

I am using Cordova to create Hybrid app for windows phone in visual studio 2015. I am facing problem with camera orientation while facing front camera.

here is my code

if (!navigator.camera) {
            alert("Camera API not supported", "Error");
            deffered.reject('Unable to open camera');
            return deffered.promise;
        };
        if( direction === undefined ) {
            direction = 0;
        }
        var options =   {   
            quality: 50,
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: 1,      // 0:Photo Library, 1=Camera, 2=Saved Album
            encodingType: 0,     // 0=JPG 1=PNG
            cameraDirection: direction // 0 for back, 1 for front
        };

        navigator.camera.getPicture(
            function( imgData ) {
              deffered.resolve(imgData);
            },
            function (message) {
                console.log(message);
              deffered.reject('Unable to open camera');
            },
            options);
        return deffered.promise;
    }

when camera will open Orientation will be opposite.

Its taking opposite image I tried with

cameraOrientation : 0 or 1 but it makes camera green screen only.

回答1:

I found the solution for this. In CameraProxy.js make changes in orientationToRotation function line number 569.

case Windows.Devices.Sensors.SimpleOrientation.notRotated:
            if (cameraDirection == 0) {
                return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
            }
            else {
                return Windows.Media.Capture.VideoRotation.clockwise270Degrees;
            }