
因此,我需要一种方式来向用户显示网络摄像头图像,以便他可以调整自己的脸部.
我一直在尝试使用尽可能少的cpu从网络摄像头获取图像的很多东西:
> VideoRendererElement
> WPFMediaKit
> DirectShow-Lib
但没有一个是好的…任何一种方式太慢或太cpu资源消耗.
然后我尝试了Emgu library,我感觉很好.
起初,我在一个windows窗体项目中尝试过,并在图片框中更新图像.
但是,当我尝试将其整合到我的WPF项目中时,我陷入了如何将我的图像传递给我的图像控件.
现在我有以下源代码:
<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属性 总结以上是内存溢出为你收集整理的c# – 如何显示使用Emgu捕获的网络摄像头图像?全部内容,希望文章能够帮你解决c# – 如何显示使用Emgu捕获的网络摄像头图像?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)