如何在C#中为UWP创建相机蒙版

编程入门 行业动态 更新时间:2024-10-16 00:24:35
本文介绍了如何在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创建相机蒙版

本文发布于:2023-11-04 18:19:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1558673.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中为   相机   如何在   UWP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!