Data Translation
Data Translation Knowledge Base
Home / All Categories / Imaging Software / Development
KB HomeKnowledge Base Home | SearchSearch | GlossaryGlossary

Multi-threading for Images, DT3162

Question:  Are there any issues with using multiple threads to capture triggered images from more than 1 DT3162?
 
Answer:  An assumption may have been made that in order to perform acquisitions simultaneously, each acquisition would have to be conducted from a separate thread. This is in fact not the case. The best way to acquire images simultaneously from multiple DT3162s is to set the trigger type on all frame grabbers to ExternalForEach. Then, start continuous acquire on each frame grabber (optionally displaying the output) and use the external trigger to initiate the acquisitions. The OnFrameComplete events from each control instance can be monitored to know when all frames have been acquired. This approach will allow the user to achieve the best frame rate as well. This approach was tested with the VC++ sample program that ships with the board and two DT3162s in a Windows XP system. Frames were able to be acquired simultaneously from both frame grabbers, using an external trigger generated by a pattern generator, without error.

In general, MFC is not a thread-safe framework (i.e. it's not a good idea to have multiple threads accessing MFC objects that were created on the main thread). Additionally, if an MFC program needs to create worker threads, the AfxBeginThread function should be used instead of _beginthread. Threading is a complex topic so below is a link to an MSDN article on Microsoft's web site that explains some of the caveats surrounding the use of threads in MFC. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_multithreading.3a_.programming_tips.asp*Dated: 01/09/03.

Copyright © 2013 Data Translation, Inc. All rights reserved.