MATLAB Answers


Image Acquisition getdata race condition when camera is active capturing frames

Asked by Spencer Chen on 21 Oct 2016
I am working with a PCO Edge 4.2 on Matlab R2016a with Image Acquisition Toolbox on Win7sp1 64-bit. This camera has the functionality to capture a fixed sequence of images in response to an external trigger. I set it up so the camera is in acquisition mode, waiting for an Inf number of triggers, until I manually stop it. I also used the FramesAcquiredFcn callback to read images when a sequence is available.
Now, running things asynchronously means I may be reading images (getdata()) from the previous sequence while the camera is actively capturing images for the next sequence. When this happens, getdata() does not behave appropriately. I want to read in the N images from the previous sequence. getdata() reads in N images as I specified, but the last few images can replaced by the first n images from the currently active sequence. And the FramesAvailable count after getdata() only has N-n images subtracted.
I think because the camera capture runs on a separate thread, there might be a race condition between getdata() and the thread that is reading in the data. Has anyone also encountered this?
I found that this problem turns out to be easy to replicate, simply by delaying image read onset to coincide with the next camera sequence, and getdata() will play up on me.
Blessings, Spencer


Sign in to comment.

0 Answers