View Full Version : playback methods (ring buffer?)

June 6, 2007, 23:09:00
I want to playback the captured movie (AVI) or images so that we can identify before and after of a particular event.

For golfers for example:
Let's say I have captured movie or images about the ball hits 4 times by club. I want to review seconds before and after a particular hit (the third hit).

I know when those hits occured by using timestamp, but I still need to know the related StartImage if I use Images[StartImage]. but how?

Images is ImageBuffers.

How can I do that?

Stefan Geissler
June 7, 2007, 11:37:28

I suppose, I have already mailed the answer to you. But since you asked here again, I need to answer it here too:

The sample captures all time the live video is shown images into the ring buffer. The ring buffer
size has been set to 120, this means 120 images are stored continuously. If 120 images have be
already stored in the ring buffer, IC Imaging Control starts again a the first ring buffer element
with storing.

If the "Capture" button has been clicked, the live video stream is stopped and no more images are
saved into the ring buffer. Thus we have now 120 images in our ring buffer, that covers the last 4
seconds (at 30 fps). We do not know the oldest image in the ring buffer now. Thus we must evaluate
all images in the ring buffer and search for the image with the smallest sample start time. This is
the oldest image and the first to be displayed or to be saved into an AVI file. This search is done
in the following loop:

//Find the oldest image in the ring buffer. Its index is saved in
StartImage = 0;
MinStartTime = icImagingControl1.ImageBuffers[StartImage].SampleStartTime;
for (int i = 1; i < (icImagingControl1.ImageRingBufferSize - 1); i++)
if (Images[i].SampleStartTime < MinStartTime)
StartImage = i;
MinStartTime = Images[StartImage].SampleStartTime;
i = 120;

For example the oldest image in the ring buffer, the one with the smallest sample start time is on
index 112. This means the images from 0 to 111 in the ring buffer were snapped after our image at
position 112. Also the images from 113 to 119 are snapped after our position 112 image. If we now
want to run in chronological sequence through the images in the ring buffer, we must start at
position 112. Then proceed until 119. Now we are the end of the ring buffer and we must proceed at
position 0 and end at 111.
Thus we save the position (index) of the oldest starting image in "StartImage".

If you want to capture image after you have clicked the "Capture" button, then you should insert a
"Sleep" command before your call "LiveStop":


Now you have the images 2 seconds before and 2 seconds after you have clicked on the "Capture"
button in your image ring buffer.