c# – 如何显示使用Emgu捕获的网络摄像头图像?
发布时间:2020-12-15 03:52:42 所属栏目:百科 来源:网络整理
导读:我目前正在使用一个使用面部识别的项目. 因此,我需要一种方式来向用户显示网络摄像头图像,以便他可以调整自己的脸部. 我一直在尝试使用尽可能少的CPU从网络摄像头获取图像的很多东西: VideoRendererElement WPFMediaKit DirectShow-Lib 但没有一个是好的…
我目前正在使用一个使用面部识别的项目.
因此,我需要一种方式来向用户显示网络摄像头图像,以便他可以调整自己的脸部. 我一直在尝试使用尽可能少的CPU从网络摄像头获取图像的很多东西: > VideoRendererElement 但没有一个是好的…任何一种方式太慢或太CPU资源消耗. 然后我尝试了Emgu library,我感觉很好. 现在我有以下源代码: <Window x:Class="HA.FacialRecognition.Enroll.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Width="800" Height="600" Loaded="Window_Loaded" Closing="Window_Closing"> <Grid> <Image x:Name="webcam" Width="640" Height="480" > <Image.Clip> <EllipseGeometry RadiusX="240" RadiusY="240"> <EllipseGeometry.Center> <Point X="320" Y="240" /> </EllipseGeometry.Center> </EllipseGeometry> </Image.Clip> </Image> </Grid> </Window> 和代码背后: private Capture capture; private System.Timers.Timer timer; public Window1() { InitializeComponent(); } private void Window_Loaded(object sender,RoutedEventArgs e) { capture = new Capture(); capture.FlipHorizontal = true; timer = new System.Timers.Timer(); timer.Interval = 15; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); } void timer_Elapsed(object sender,ElapsedEventArgs e) { using (Image<Bgr,byte> frame = capture.QueryFrame()) { if (frame != null) { var bmp = frame.Bitmap; // How do I pass this bitmap to my Image control called "webcam"? } } } private void Window_Closing(object sender,CancelEventArgs e) { if (capture != null) { capture.Dispose(); } } 我的猜测是使用BitmapSource / WriteableBitmap,但我没有让他们工作… 谢谢! 解决方法
Image Class有一个您可能正在寻找的UriSource属性
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |