开发者

C# threads that synchronize two cameras

I need to capture images from two cameras and combine them together.

The flow is like this:

  • two threads, one for each camera, sample the camera frames.
  • Each one sends the frame to a third thread, the c开发者_开发百科onsumer.
  • Only when the consumer has two frames he processes them, and
  • releases the capture threads so they can get the next frame.

Can someone outline what I need to do ? I'm using C# .Net 4.0


Have you tried reading this article?

http://msdn.microsoft.com/en-us/library/ms228964.aspx

All about thread synchronization using .NET 4. Surprisingly simple.


I would use any static variables or database to store the progress of individual camera's sampling activity. When both camera marks their individual flag as completed, reader flag will consume all frames, reset those flags. Uplon reset of its own individual flag, worker threads start on capturing next frame. You can also use delegate patters (prescriber-subscriber) to inform each other through events.


i'd give each capture-worker 2 AutoResetEvent objects ... one to signal when capturing is done (A), and the other to wait for permission to start the next capture (B) ...

worker routine would be the following loop:

capture to local buffer
signal A
wait for B

consumer loop:

wait for both A
copy both buffers
signal both B
process copys of buffers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜