我正在使用Cordova在visual studio 2015中为Windows手机创建混合应用程序。 面对前置摄像头时,我面临着摄像头方向的问题。
这是我的代码
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;
}
当相机打开时,方向将相反。
采取相反的形象 我试过
cameraOrientation : 0 or 1 but it makes camera green screen only.
答案 0 :(得分:3)
我找到了解决方法。 在CameraProxy.js中,在orientationToRotation函数行号569中进行更改。
case Windows.Devices.Sensors.SimpleOrientation.notRotated:
if (cameraDirection == 0) {
return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
}
else {
return Windows.Media.Capture.VideoRotation.clockwise270Degrees;
}