[英]Parallel processing using the AForge.Net library and C#.
My program works as follows: 我的程序工作如下:
That is, I am trying to detect motion of objects that have skin color. 也就是说,我正在尝试检测具有肤色的对象的运动。 But I want to speed up my program, so I thought about using parallel programming, where I use two threads, one for skin filtering, and one for motion detection, and then do a logical
AND
of the results. 但是我想加快程序的速度,所以我考虑使用并行编程,在这里我使用两个线程,一个用于皮肤过滤,一个用于运动检测,然后对结果进行逻辑
AND
。
I am using C# and the Aforge.Net library. 我正在使用C#和Aforge.Net库。 Can I do what I described using C#?
我可以使用C#进行描述吗? Could you please give me some hints on how to accomplish what I have described?
您能给我一些有关如何完成我所描述的内容的提示吗? All I have been able to find is
Parallel.For
. 我只能找到
Parallel.For
。
There are several ways to do threaded and parallel processing in .NET: 在.NET中有几种方法可以执行线程和并行处理:
You either can use a ThreadPool
. 您可以使用
ThreadPool
。 http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx tells you more about this. http://msdn.microsoft.com/zh-cn/library/system.threading.threadpool.aspx告诉您更多有关此的信息。
Maybe you can make use of TaskFactory.StartNew(...)
http://msdn.microsoft.com/en-us/library/dd321439.aspx instead. 也许您可以改用
TaskFactory.StartNew(...)
http://msdn.microsoft.com/zh-cn/library/dd321439.aspx 。
Another way would be the BlockingCollection for .NET 4, see BlockingCollection Class in MSDN. 另一种方法是.NET 4的BlockingCollection,请参阅MSDN中的BlockingCollection类。
Also you could write your own ThreadPool-class. 您也可以编写自己的ThreadPool类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.