Your program only displays the elapsed time until you extract the image from the buffer. This is essentially the same as when the image was captured, unless there are significant delays between acquisition and extraction.
You also have some unknown offset since the first millisecond value could be read any time before the loop starts. Most likely, it will read early in the execution of the software and you will have a small gap.
I have found that cameras provide a reasonably good timing mechanism. They take images at a nice, fixed rate. After measuring the frame rate, you can just take the buffer number and divide it by the frame rate to get the elapsed time for each frame.
To measure the frame rate, you can set up a loop that just reads the current frame number and the current time in milliseconds. To initialize, monitor the frame number for a change and store an initial frame number and time. After that, at each frame change calculate the number of frames acquired and the total elapsed time and divide to get frame rate. It will converge rapidly to the actual frame rate.
Bruce
Bruce Ammons
Ammons Engineering