可以使用Windows.Phone.Media.Capture.PhotoCaptureDevice 进行高像素图片的捕获(需要自己画视图界面,因为该平台的PhotoChooserTask API 不支持捕获高像素的功能),并且需要使用预定义像素分辨率手动设置捕获的像素。需要注意的额外的像素是没有从 PhotoCaptureDevice 类的获取手机支持分辨率的静态方法 IReadOnlyList<Size> GetAvailabeCaptureResolutions() 方法中检索到的。还有就是为了让 PhotoCaptureDevice 正常工作ID_CAP_ISV_CAMERA功能声明需要添加到清单文件WMAppManifest.xml

下面是可以手动获取的支持高分辨率的设备型号

 手机型号 变体  手动配置高像素的选项
 Lumia 1020 RM-875, RM-876, RM-877 7712x4352 (16:9), 7136x5360 (4:3)
 Lumia 1520 RM-937, RM-938, RM-939 5376x3024 (16:9), 4992x3744 (4:3)

为高像素拍摄初始化相机

下面的示例代码演示你如何在应用中创建简单的取景器,并且初始化高像素 photo capture。下面

的代码是使用 VideoBrush 作为 canvas 的背景:

  1. <!-- Simple viewfinder page -->
  2. <phone:PhoneApplicationPage x:Class="ViewfinderPage" ... >
  3. <Grid x:Name="LayoutRoot" Background="Transparent">
  4. <Grid x:Name="ContentPanel">
  5. <Canvas x:Name="Canvas" ... >
  6. <Canvas.Background>
  7. <VideoBrush x:Name="ViewfinderVideoBrush" Stretch="Uniform"/>
  8. </Canvas.Background>
  9. </Canvas>
  10. </Grid>
  11. </Grid>
  12. </phone:PhoneApplicationPage>

在相应的 C# 页面,向以往相同,先初始化 PhotoCaptureDevice,这里需要添加额外的代码检测

设备的型号,从而根据条件进行选择,并且在 IAsyncOperation<PhotoCaptureDevice> OpenAsync(CameraSensorLocation senor, Size initialRsolution) 方法中初始化高分辨率的尺寸。需要注意的是你只能每次使用一种分辨率捕获一张照片,所以如果你需要高像素的版本和低像素

的版本的图片,你可以先捕获一张高像素照片,然后对它进行操作,比如使用 Nokia Imaging SDK 对它进行压缩

尺寸来获得另一个版本的图片。

  1. using Microsoft.Devices;
  2. using Windows.Phone.Media.Capture;
  3.  
  4. ...
  5.  
  6. public partial class ViewfinderPage : PhoneApplicationPage
  7. {
  8. private const CameraSensorLocation SENSOR_LOCATION = CameraSensorLocation.Back;
  9.  
  10. private PhotoCaptureDevice _device = null;
  11. private bool _focusing = false;
  12. private bool _capturing = false;
  13.  
  14. ...
  15.  
  16. ~ViewfinderPage()
  17. {
  18. if (_device != null)
  19. {
  20. UninitializeCamera();
  21. }
  22. }
  23.  
  24. protected override void OnNavigatedTo(NavigationEventArgs e)
  25. {
  26. base.OnNavigatedTo(e);
  27.  
  28. if (_device == null)
  29. {
  30. InitializeCamera();
  31. }
  32. }
  33.  
  34. protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
  35. {
  36. if ((_focusing || _capturing) && e.IsCancelable)
  37. {
  38. e.Cancel = true;
  39. }
  40.  
  41. base.OnNavigatingFrom(e);
  42. }
  43.  
  44. protected override void OnNavigatedFrom(NavigationEventArgs e)
  45. {
  46. base.OnNavigatedFrom(e);
  47.  
  48. if (_device != null)
  49. {
  50. UninitializeCamera();
  51. }
  52. }
  53.  
  54. /// <summary>
  55. /// Synchronously initialises the photo capture device for a high resolution photo capture.
  56. /// Viewfinder video stream is sent to a VideoBrush element called ViewfinderVideoBrush, and
  57. /// device hardware capture key is wired to the CameraButtons_ShutterKeyHalfPressed and
  58. /// CameraButtons_ShutterKeyPressed methods.
  59. /// </summary>
  60. private void InitializeCamera()
  61. {
  62. Windows.Foundation.Size captureResolution;
  63.  
  64. var deviceName = DeviceStatus.DeviceName;
  65.  
  66. if (deviceName.Contains("RM-875") || deviceName.Contains("RM-876") || deviceName.Contains("RM-877"))
  67. {
  68. captureResolution = new Windows.Foundation.Size(, ); // 16:9 ratio
  69. //captureResolution = new Windows.Foundation.Size(7136, 5360); // 4:3 ratio
  70. }
  71. else if (deviceName.Contains("RM-937") || deviceName.Contains("RM-938") || deviceName.Contains("RM-939"))
  72. {
  73. captureResolution = new Windows.Foundation.Size(, ); // 16:9 ratio
  74. //captureResolution = new Windows.Foundation.Size(4992, 3744); // 4:3 ratio
  75. }
  76. else
  77. {
  78. captureResolution = PhotoCaptureDevice.GetAvailableCaptureResolutions(SENSOR_LOCATION).First();
  79. }
  80.  
  81. var task = PhotoCaptureDevice.OpenAsync(SENSOR_LOCATION, captureResolution).AsTask();
  82.  
  83. task.Wait();
  84.  
  85. _device = task.Result;
  86.  
  87. ViewfinderVideoBrush.SetSource(_device);
  88.  
  89. if (PhotoCaptureDevice.IsFocusSupported(SENSOR_LOCATION))
  90. {
  91. Microsoft.Devices.CameraButtons.ShutterKeyHalfPressed += CameraButtons_ShutterKeyHalfPressed;
  92. }
  93.  
  94. Microsoft.Devices.CameraButtons.ShutterKeyPressed += CameraButtons_ShutterKeyPressed;
  95.  
  96. ...
  97. }
  98.  
  99. /// <summary>
  100. /// Uninitialises the photo capture device and unwires the device hardware capture keys.
  101. /// </summary>
  102. private void UninitializeCamera()
  103. {
  104. if (PhotoCaptureDevice.IsFocusSupported(SENSOR_LOCATION))
  105. {
  106. Microsoft.Devices.CameraButtons.ShutterKeyHalfPressed -= CameraButtons_ShutterKeyHalfPressed;
  107. }
  108.  
  109. Microsoft.Devices.CameraButtons.ShutterKeyPressed -= CameraButtons_ShutterKeyPressed;
  110.  
  111. _device.Dispose();
  112. _device = null;
  113. }
  114.  
  115. ...
  116. }

拍摄

现在设备的相机已经初始化完成了,设备的拍照按键可以是相机进行自动对焦,并且捕获一张高像素照片

  1. ...
  2.  
  3. public partial class ViewfinderPage : PhoneApplicationPage
  4. {
  5. ...
  6.  
  7. /// <summary>
  8. /// Asynchronously autofocuses the photo capture device.
  9. /// </summary>
  10. private async void CameraButtons_ShutterKeyHalfPressed(object sender, EventArgs e)
  11. {
  12. if (!_focusing && !_capturing)
  13. {
  14. _focusing = true;
  15.  
  16. await _device.FocusAsync();
  17.  
  18. _focusing = false;
  19. }
  20. }
  21.  
  22. /// <summary>
  23. /// Asynchronously captures a frame for further usage.
  24. /// </summary>
  25. private async void CameraButtons_ShutterKeyPressed(object sender, EventArgs e)
  26. {
  27. if (!_focusing && !_capturing)
  28. {
  29. _capturing = true;
  30.  
  31. var stream = new MemoryStream();
  32.  
  33. try
  34. {
  35. var sequence = _device.CreateCaptureSequence();
  36. sequence.Frames[].CaptureStream = stream.AsOutputStream();
  37.  
  38. await _device.PrepareCaptureSequenceAsync(sequence);
  39. await sequence.StartCaptureAsync();
  40. }
  41. catch (Exception ex)
  42. {
  43. stream.Close();
  44. }
  45.  
  46. _capturing = false;
  47.  
  48. if (stream.CanRead)
  49. {
  50. // We now have the captured image JPEG data in variable "stream" for further usage
  51. }
  52. }
  53. }
  54.  
  55. ...
  56. }

获得一个全功能的“单击画面对焦”、“在捕获时冻结预览”,可以参考示例代码  Photo Inspector

Nokia WiKi 原文链接:http://developer.nokia.com/Resources/Library/Lumia/#!imaging/working-with-high-resolution-photos/capturing-high-resolution-photos.html

捕获高像素照片(updated)的更多相关文章

  1. Unity 3D 调用摄像头捕获照片 录像

    1,要想调用摄像头首先要打开摄像头驱动,如果用户允许则可以使用. 2,定义WebCamTexture的变量用于捕获单张照片. 3,连续捕获须启用线程. 实现代码: using UnityEngine; ...

  2. 处理图片(updated)

    高像素的图片,比如分辨率为 7712x4352 的照片,当加载到一个 bitmap 中时会占用相当大的内存. 每个像素会占用 4个字节的内存,所以当没有被压缩时,全部的图片会占用 12800万字节(约 ...

  3. HoloLens开发手记 - Unity之Locatable camera 使用相机

    Enabling the capability for Photo Video Camera 启用相机能力 为了使用摄像头,我们必须启用WebCam能力. 在Unity中打开Player settin ...

  4. 快速构建Windows 8风格应用29-捕获图片与视频

    原文:快速构建Windows 8风格应用29-捕获图片与视频 引言 本篇博文主要介绍Windows 8中相机的概念.捕获图片与视频的基本原理.如何实现捕获图片与视频.相机最佳实践. 一.相机 关于相机 ...

  5. UIImagePickerController 相关

    UIImagePickerController是系统封装好的一个导航视图控制器,使用其开发者可以十分方便的进行相机相册相关功能的调用.UIImagePickerController继承于UINavig ...

  6. Android Intent 教程

    原文:Android: Intents Tutorial 作者:Darryl Bayliss 译者:kmyhy 人不会漫无目的地瞎逛,他们所做的大部分事情--比方看电视.购物.编写下一个杀手级 app ...

  7. opencv python训练人脸识别

    总计分为三个步骤 一.捕获人脸照片 二.对捕获的照片进行训练 三.加载训练的数据,识别 使用python3.6.8,opencv,numpy,pil 第一步:通过笔记本前置摄像头捕获脸部图片 将捕获的 ...

  8. 与众不同 windows phone (41) - 8.0 相机和照片: 通过 AudioVideoCaptureDevice 捕获视频和音频

    [源码下载] 与众不同 windows phone (41) - 8.0 相机和照片: 通过 AudioVideoCaptureDevice 捕获视频和音频 作者:webabcd 介绍与众不同 win ...

  9. 与众不同 windows phone (42) - 8.0 相机和照片: 通过 PhotoCaptureDevice 捕获照片

    [源码下载] 与众不同 windows phone (42) - 8.0 相机和照片: 通过 PhotoCaptureDevice 捕获照片 作者:webabcd 介绍与众不同 windows pho ...

随机推荐

  1. [Todo]提升电商网站性能方面的一些资料材料

    又到国庆,喷一喷12306.cn的技术架构 http://chengxu.org/p/369.html 其中用到了不少比较细节的优化技巧. 提到库存管理是电商非常难的地方.也讲了跟秒杀相关的一些内容.

  2. Dede(织梦) CMS SQL Injection Vulnerability

    测试方法: @Sebug.net   dis本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! # Dede Cms All Versions Sql Vulnerability ...

  3. 会话追踪(session tracking)

    HTTP是一种无连接的协议,如果一个客户端只是单纯地请求一个文件(HTML或GIF),服务器端可以响应给客户端,并不需要知道一连串的请求是否来自于相同的客户端,而且也不需要担心客户端是否处在连接状态. ...

  4. 利用kettle中的JS来完成ETL数据校验

    最近参与了一个信托行业的BI项目,由于信托业务系统设计的问题,很多都是用户手工录入的数据,也有一些是需要分析的但是用户没有录入的数据,针对这样的数据质量,我们就要在ETL抽取的过程中来对数据流进行校验 ...

  5. [RSpec] LEVEL 1: INTRODUCTION

    Install RSpec: Describe Lets start writing a specification for the Tweet class. Write a describe blo ...

  6. HDU2089 ------不要62(数位dp)

    不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  7. 给你的webstorm添加快速生成注释得快捷键

    打开File----setting-map-搜搜"fix doc"

  8. Cleaner ITweenPath Source

    iTweenPath.cs [pyg language="csharp" s="monokai" ] //Slight additions for a clea ...

  9. NSURLConnection经常使用的代理方法

    NSURLConnection的代理Protocol定义有三类:NSURLConnectionDelegate.NSURLConnectionDataDelegate和NSURLConnectionD ...

  10. Matlab interpgui

    function interpgui(arg1,arg2) %INTERPGUI Behavior of interpolating functions. % Demonstrates interpo ...