How to create camera mask in C# for UWP

2019-07-15 05:28发布

问题:

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.

回答1:

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# camera uwp