简体   繁体   English

C#WPF-从DLL捕获相机

[英]C# WPF - Camera capture from DLL

I'm using AForge.NET library to capture USB Camera, I need that piece of code to be on a DLL. 我正在使用AForge.NET库捕获USB摄像头,我需要将这段代码放在DLL中。 For each frame the AForge.NEt library create an event with a bitmap, I'm trying to bubble up this event to my main WPF window, for this I created a simple event in the DLL library so the main app can init this event. 对于AForge.NEt库的每个帧,创建一个带有位图的事件,我试图将此事件冒泡到我的主WPF窗口中,为此,我在DLL库中创建了一个简单事件,以便主应用程序可以初始化此事件。 but I'm getting "The calling thread cannot access this object because a different thread owns it." 但我收到“调用线程无法访问此对象,因为其他线程拥有它。” I'm using 我正在使用

Dispatcher.Invoke(() => 
   {
       imgCamera.Source = newFrame;
   });

still the same message. 还是一样的消息。 any idea? 任何想法?

I found the solution after spending on it so many time. 我花了很多时间后找到了解决方案。 just do -> newFrame.Freeze(); 只需-> newFrame.Freeze();

it takes of all thread issues 它需要处理所有线程问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM