本文介绍了Cordova Windows Phone应用程序摄像头方向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cordova在Visual Studio 2015中为Windows Phone创建Hybrid应用。
我在面对前置摄像头时遇到摄像头方向问题。

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.

这是我的代码

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 imageI tried with

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


推荐答案

我找到了解决方案。在CameraProxy.js中,
更改了DirectionToToRotation函数行569。

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;
            }

这篇关于Cordova Windows Phone应用程序摄像头方向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:20