Cordova Windows Phone 应用程序相机方向错误

标签 cordova camera windows-phone-8.1 navigator

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

这是我的代码

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.

最佳答案

我找到了这个问题的解决方案。 在 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;
            }

关于Cordova Windows Phone 应用程序相机方向错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33731152/

相关文章:

android - 如何从 Card.io Phonegap iOS 和 Android 中删除/隐藏 Paypal Logo ?

cordova - Phonegap构建全局化插件 "Class not found"错误

android - 保存时从照片中获取 ID

c# - 从网络源下载字节数

Cordova/Phonegap : WP8. 1 导航栏重叠

c# - 没有状态栏的 Window.Current.Bounds 高度,每个方向

javascript - 在 Cordova ,如何导航到另一个 html 页面?

javascript - PhoneGap 构建嵌入 YouTube 视频

swift - 黄色警告 : Conditional cast from 'AVCaptureVideoPreviewLayer' to 'AVCaptureVideoPreviewLayer' always succeeds

android - 如何协调相机预览尺寸和图片尺寸之间的纵横比差异