如何在C#中为UWP创建相机蒙版 [英] How to create camera mask in C# for UWP

查看:84
本文介绍了如何在C#中为UWP创建相机蒙版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上搜索过,但找不到答案,需要帮助。我正在创建一个移动HR程序,需要为照相机提供一个轮廓遮罩,以便用户知道要为该人拍照并确保所有照片看起来相同的距离。



我想做的是,当用户单击一个按钮时,显示照相机并有一个涂黑的区域,以便仅透明部分以所需的形状显示照相机的焦点。



如果有人知道示例代码在哪里,或者对此主题有很好的教程,我将不胜感激。

解决方案

根据您的要求,您可以使用



MainPage.xaml

 < Grid> 
< CaptureElement Name = PreviewControl Stretch = Uniform Height = 400 Width = 400>
< / CaptureElement>
< Image Source = head.png Height = 400 Width = 400 />
< / Grid>


I have searched the net but can't find an answer and need some help. I am creating a mobile HR program and need to provide a profile mask to the camera so that the user knows what distance to be at to take a picture of the person and to ensure all photos look the same.

What I would like to do is when the user clicks a button show the camera and have an area blacked out so that only the transparent section shows the focus of the camera in the desired shape.

If anyone knows where sample code is or a good tutorial on this subject is I would appreciate it.

解决方案

For your requirement, you could use MediaCapture class to display the camera preview. And cover CaptureElement with human shape image just like the following.

MainPage.xaml

<Grid>
    <CaptureElement Name="PreviewControl" Stretch="Uniform" Height="400" Width="400" >
    </CaptureElement>
    <Image Source="head.png" Height="400" Width="400" />
</Grid>

这篇关于如何在C#中为UWP创建相机蒙版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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