[UWP]如何在Windows应用商店应用中设置相机的方向? [英] [UWP]how to set the orientation for camera in windows store apps?

查看:122
本文介绍了[UWP]如何在Windows应用商店应用中设置相机的方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了Windows应用商店应用程序,使用Windows.Media.Capture.dll从相机捕获图像。我的电脑分辨率是(1080,1920)。


CameraCaptureUI显示 可逆(图像180度)。 如何在WindowsStoreApp中设置摄像头的方向?
$


我在这里给出了我的代码示例。



             CameraCaptureUI captureUI = new CameraCaptureUI();

            captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;

            captureUI.PhotoSettings.CroppedSizeInPixels = new Size(1080,1920);

            captureUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.VeryLarge5M;



            capturedPhoto = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);



            

             if(capturedPhoto!= null)

            {

                 BitmapImage bi = new BitmapImage();

                bi.CreateOptions = BitmapCreateOptions.None;

                bi.UriSource = new Uri(FilePath,UriKind.Absolute);

                 PhotoPreview.Source = bi;

            }


I have created windows store app to capture image from camera using Windows.Media.Capture.dll. My pc resolution is ( 1080, 1920 ).
CameraCaptureUI shows  reversly (image 180 degree).  How to set the orientation of camera in WindowsStoreApp?

I have given my code sample here.

            CameraCaptureUI captureUI = new CameraCaptureUI();
            captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
            captureUI.PhotoSettings.CroppedSizeInPixels = new Size(1080, 1920);
            captureUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.VeryLarge5M;

            capturedPhoto = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);

            
             if(capturedPhoto != null)
            {
                 BitmapImage bi = new BitmapImage();
                bi.CreateOptions = BitmapCreateOptions.None;
                bi.UriSource = new Uri(FilePath, UriKind.Absolute);
                PhotoPreview.Source = bi;
            }

推荐答案

嗯,所以让我确认你的问题。你想要将相机旋转大约180度,对吗?

Well, so let me confirm your question. You want to rotate the camera about 180 degree, right? 

如果您仍想使用CameraCaptureUI,则在图像控件中加载图像之前无法旋转可以旋转图像控件。您正在使用的CameraCaptureUI将自动启动UWP相机APP。但你可以看到
无法在相机窗口内旋转相机。 

If you still wants to use CameraCaptureUI, it is impossible to rotate until the image is loaded in the image control so you could rotate the image control. The CameraCaptureUI you are using will auto launch the UWP camera APP. But you could see there is no way to rotate the camera inside the camera windows. 

我的建议是使用  MediaCapture类用于捕获照片。使用MediaCapture类,您可以在应用程序内创建Media Preview并旋转相机。
欲了解更多信息,请参考:使用MediaCapture进行基本照片,视频和音频捕获 &absp; 使用MediaCapture处理
设备方向

My suggestion is to use MediaCapture class to capture photo. Using MediaCapture class you could create Media Preview inside your app and also rotate the camera. For more information, you could refer:Basic photo, video, and audio capture with MediaCapture and Handle device orientation with MediaCapture

祝你好运,

Roy


这篇关于[UWP]如何在Windows应用商店应用中设置相机的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆