照相机Camera

本节提供有关创建使用相机或麦克风捕获照片、视频或音频的通用 Windows 平台 (UWP) 应用的指南。This section provides guidance for creating Universal Windows Platform (UWP) apps that use the camera or microphone to capture photos, video, or audio.

使用 Windows 内置相机 UIUse the Windows built-in camera UI

主题Topic 描述Description
使用 Windows 内置相机 UI 捕获照片和视频Capture photos and video with Windows built-in camera UI 展示如何使用 CameraCaptureUI 类来使用内置于 Windows 的相机 UI 捕获照片或视频。Shows how to use the CameraCaptureUI class to capture photos or videos using the camera UI built into Windows. 如果仅希望使用户能够捕获照片或视频,并将结果返回到应用,这就是达到此目的的最快且最简单的方法。If you simply want to enable the user to capture a photo or video and return the result to your app, this is the quickest and easiest way to do it.

MediaCapture 基本任务Basic MediaCapture tasks

主题Topic 描述Description
显示相机预览Display the camera preview 展示如何在 UWP 应用的 XAML 页面内快速显示相机预览流。Shows how to quickly display the camera preview stream within a XAML page in a UWP app.
使用 MediaCapture 捕获基本的照片、视频和音频Basic photo, video, and audio capture with MediaCapture 展示使用 MediaCapture 类捕获照片和视频的最简单方法。Shows the simplest way to capture photos and video using the MediaCapture class. MediaCapture 类公布了一组强大的 API,可提供捕获管道的低级别控制和启用高级捕获方案,但本文旨在帮助你将基本的媒体捕获快速且轻松地添加到应用。The MediaCapture class exposes a robust set of APIs that provide low-level control over the capture pipeline and enable advanced capture scenarios, but this article is intended to help you add basic media capture to your app quickly and easily.
移动设备的相机 UI 功能Camera UI features for mobile devices 展示如何利用仅在移动设备上提供的特殊相机 UI 功能。Shows you how to take advantage of special camera UI features that are only present on mobile devices.

MediaCapture 高级任务Advanced MediaCapture tasks

主题Topic 描述Description
使用 MediaCapture 处理设备和屏幕方向Handle device and screen orientation with MediaCapture 展示在使用帮助程序类捕获照片和视频时,如何处理设备方向。Shows you how to handle device orientation when capturing photos and videos by using a helper class.
通过相机配置文件发现和选择相机功能Discover and select camera capabilities with camera profiles 展示如何使用相机配置文件来发现和管理不同视频捕获设备的功能。Shows how to use camera profiles to discover and manage the capabilities of different video capture devices. 这包括如下任务:选择支持特定分辨率或帧速率的配置文件、选择支持同时访问多台相机的配置文件,以及选择支持 HDR 的配置文件。This includes tasks such as selecting profiles that support specific resolutions or frame rates, profiles that support simultaneous access to multiple cameras, and profiles that support HDR.
为 MediaCapture 设置格式、分辨率和帧速率Set format, resolution, and frame rate for MediaCapture 展示如何使用 IMediaEncodingProperties 界面设置相机预览流以及已捕获照片和视频的分辨率和帧速率。Shows you how to use the IMediaEncodingProperties interface to set the resolution and frame rate of the camera preview stream and captured photos and video. 还将展示如何确保预览流的纵横比与已捕获媒体的纵横比相匹配。It also shows how to ensure that the aspect ratio of the preview stream matches that of the captured media.
捕获 HDR 照片和光线较暗的照片HDR and low-light photo capture 展示如何使用 AdvancedPhotoCapture 类捕获高动态范围 (HDR) 照片和光线较暗的照片。Shows you how to use the AdvancedPhotoCapture class to capture High Dynamic Range (HDR) and low-light photos.
用于照片和视频捕获的手动相机控件Manual camera controls for photo and video capture 展示如何使用手动设备控件实现增强的照片和视频捕获方案,包括光学图像防抖动和平滑缩放。Shows you how to use manual device controls to enable enhanced photo and video capture scenarios including optical image stabilization and smooth zoom.
用于视频捕获的手动相机控件Manual camera controls for video capture 展示如何使用手动设备控件实现增强的视频捕获方案,包括 HDR 视频和曝光优先级。Shows you how to use manual device controls to enable enhanced video capture scenarios including HDR video and exposure priority.
用于视频捕获的视频防抖动效果Video stabilization effect for video capture 展示如何使用视频防抖动效果。Shows you how to use the video stabilization effect.
MediaCapture 的场景分析Scene anlysis for MediaCapture 展示如何使用 SceneAnalysisEffectFaceDetectionEffect 分析媒体捕获预览流的内容。Shows you how to use the SceneAnalysisEffect and the FaceDetectionEffect to analyze the content of the media capture preview stream.
使用 VariablePhotoSequence 捕获照片序列Capture a photo sequence with VariablePhotoSequence 展示如何捕获可变照片序列,这允许你快速连续捕获图像的多个帧,并将每个帧配置为使用不同的焦点、闪光灯、ISO、曝光和曝光补偿设置。Shows you how to capture a variable photo sequence, which allows you to capture multiple frames of images in rapid succession and configure each frame to use different focus, flash, ISO, exposure, and exposure compensation settings.
使用 MediaFrameReader 处理媒体帧Process media frames with MediaFrameReader 展示如何将 MediaFrameReaderMediaCapture 结合使用,以获取一个或多个可用源提供的媒体帧,这些可用源包括颜色、深度、红外线相机、音频设备,甚至是自定义的帧源(例如生成骨架跟踪帧的帧源)。Shows you how to use a MediaFrameReader with MediaCapture to get media frames from one or more available sources, including color, depth, and infrared cameras, audio devices, or even custom frame sources such as those that produce skeletal tracking frames. 此功能旨在由执行实时处理媒体帧的应用使用,例如增强现实和感知深度的相机应用。This feature is designed to be used by apps that perform real-time processing of media frames, such as augmented reality and depth-aware camera apps.
获取预览帧Get a preview frame 展示如何从媒体捕获预览流获取单个预览帧。Shows you how to get a single preview frame from the media capture preview stream.

相机的 UWP 应用示例UWP app samples for camera