可以使用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 的背景:

<!-- Simple viewfinder page -->
<phone:PhoneApplicationPage x:Class="ViewfinderPage" ... >
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid x:Name="ContentPanel">
<Canvas x:Name="Canvas" ... >
<Canvas.Background>
<VideoBrush x:Name="ViewfinderVideoBrush" Stretch="Uniform"/>
</Canvas.Background>
</Canvas>
</Grid>
</Grid>
</phone:PhoneApplicationPage>

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

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

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

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

using Microsoft.Devices;
using Windows.Phone.Media.Capture; ... public partial class ViewfinderPage : PhoneApplicationPage
{
private const CameraSensorLocation SENSOR_LOCATION = CameraSensorLocation.Back; private PhotoCaptureDevice _device = null;
private bool _focusing = false;
private bool _capturing = false; ... ~ViewfinderPage()
{
if (_device != null)
{
UninitializeCamera();
}
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e); if (_device == null)
{
InitializeCamera();
}
} protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
if ((_focusing || _capturing) && e.IsCancelable)
{
e.Cancel = true;
} base.OnNavigatingFrom(e);
} protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e); if (_device != null)
{
UninitializeCamera();
}
} /// <summary>
/// Synchronously initialises the photo capture device for a high resolution photo capture.
/// Viewfinder video stream is sent to a VideoBrush element called ViewfinderVideoBrush, and
/// device hardware capture key is wired to the CameraButtons_ShutterKeyHalfPressed and
/// CameraButtons_ShutterKeyPressed methods.
/// </summary>
private void InitializeCamera()
{
Windows.Foundation.Size captureResolution; var deviceName = DeviceStatus.DeviceName; if (deviceName.Contains("RM-875") || deviceName.Contains("RM-876") || deviceName.Contains("RM-877"))
{
captureResolution = new Windows.Foundation.Size(, ); // 16:9 ratio
//captureResolution = new Windows.Foundation.Size(7136, 5360); // 4:3 ratio
}
else if (deviceName.Contains("RM-937") || deviceName.Contains("RM-938") || deviceName.Contains("RM-939"))
{
captureResolution = new Windows.Foundation.Size(, ); // 16:9 ratio
//captureResolution = new Windows.Foundation.Size(4992, 3744); // 4:3 ratio
}
else
{
captureResolution = PhotoCaptureDevice.GetAvailableCaptureResolutions(SENSOR_LOCATION).First();
} var task = PhotoCaptureDevice.OpenAsync(SENSOR_LOCATION, captureResolution).AsTask(); task.Wait(); _device = task.Result; ViewfinderVideoBrush.SetSource(_device); if (PhotoCaptureDevice.IsFocusSupported(SENSOR_LOCATION))
{
Microsoft.Devices.CameraButtons.ShutterKeyHalfPressed += CameraButtons_ShutterKeyHalfPressed;
} Microsoft.Devices.CameraButtons.ShutterKeyPressed += CameraButtons_ShutterKeyPressed; ...
} /// <summary>
/// Uninitialises the photo capture device and unwires the device hardware capture keys.
/// </summary>
private void UninitializeCamera()
{
if (PhotoCaptureDevice.IsFocusSupported(SENSOR_LOCATION))
{
Microsoft.Devices.CameraButtons.ShutterKeyHalfPressed -= CameraButtons_ShutterKeyHalfPressed;
} Microsoft.Devices.CameraButtons.ShutterKeyPressed -= CameraButtons_ShutterKeyPressed; _device.Dispose();
_device = null;
} ...
}

拍摄

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

...

public partial class ViewfinderPage : PhoneApplicationPage
{
... /// <summary>
/// Asynchronously autofocuses the photo capture device.
/// </summary>
private async void CameraButtons_ShutterKeyHalfPressed(object sender, EventArgs e)
{
if (!_focusing && !_capturing)
{
_focusing = true; await _device.FocusAsync(); _focusing = false;
}
} /// <summary>
/// Asynchronously captures a frame for further usage.
/// </summary>
private async void CameraButtons_ShutterKeyPressed(object sender, EventArgs e)
{
if (!_focusing && !_capturing)
{
_capturing = true; var stream = new MemoryStream(); try
{
var sequence = _device.CreateCaptureSequence();
sequence.Frames[].CaptureStream = stream.AsOutputStream(); await _device.PrepareCaptureSequenceAsync(sequence);
await sequence.StartCaptureAsync();
}
catch (Exception ex)
{
stream.Close();
} _capturing = false; if (stream.CanRead)
{
// We now have the captured image JPEG data in variable "stream" for further usage
}
}
} ...
}

获得一个全功能的“单击画面对焦”、“在捕获时冻结预览”,可以参考示例代码  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. LaTeX排版设置图表的位置 Positioning images and tables

    Positioning images and tables LATEX is an editing tool that takes care of the format so you only hav ...

  2. android开源框架之 andbase

    andbase开发框架介绍:andbase是为Android开发人员量身打造的一款开源类库产品,您能够在本站中获取到最新的代码,演示样例以及开发文档. 下载地址:http://download.csd ...

  3. Create XML Files Out Of SQL Server With SSIS And FOR XML Syntax

    So you want to spit out some XML from SQL Server into a file, how can you do that? There are a coupl ...

  4. C#转义字符[转]

    C#转义字符: 一种特殊的字符常量 以反斜线"\"开头,后跟一个或几个字符 具有特定的含义,不同于字符原有的意义,故称“转义”字符. 主要用来表示那些用一般字符不便于表示的控制代码 ...

  5. 领扣-209 长度最小的子数组 Minimum Size Subarray Sum MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  6. MyEclipse 全面的快捷键

    摘自: http://www.360doc.com/content/11/0406/10/6704374_107513559.shtml 引用 MyEclipse快捷键(全面) 程序代码自动排版:Ct ...

  7. [ES6] 02. Traceur compiler and Grunt

    Local Install:  npm install -g traceur npm install grunt-contrib-watch npm install grunt-traceur-lat ...

  8. 百度地图SDK for Android【检索服务】

    1搜索服务 百度地图SDK集成搜索服务包括:位置检索.周边检索.范围检索.公交检索.驾乘检索.步行检索,通过初始化MKSearch类,注册搜索结果的监听对象MKSearchListener,实现异步搜 ...

  9. Python网络爬虫 - 3. 异常处理

    handle_excpetion.py from urllib.request import urlopen from urllib.error import HTTPError from bs4 i ...

  10. 微信小程序 - wx:key

    看官方源码以及代码示例: 示例官网:列表渲染wx:key 官方原话 如果列表中项目的位置会动态改变或者有新的项目添加到列表中,并且希望列表中的项目保持自己的特征和状态(如 <input/> ...