Example Code

Retrieve Timestamp Data from IMAQdx (FireWire) Acquistion

Functional Description

Most IEEE 1394 (FireWire) cameras attach some meta data to the images that they return.  The LabVIEW API for IMAQdx allows you access to these data.  This meta data is brought into LabVIEW attached to the image.  Each piece of data has two parts: a key, and the data itself.  In this example, I will focus on how to get timestamp data from the camera.  You can call IMAQ Get Custom Keys VI to return a String array of keys that your camera is currently outputting.  You can call IMAQ Read Custom Data to return the data corresponding to a particular key.  This data will come back flattened as a string.  It will take a little know-how in order to get anything useful out of this.

In this example, there are three important parts.  First, we have to set the IMAQdx property called "ReceiveTimestampMode" to "System Time."  This will tell the driver to keep the data being appended by the camera.  By default, it will not.  Then you acquire your image(s).  Then you should call IMAQ Get Custom keys to return the array of available keys.  The keys that you should have available are "IMAQdxReceiveTimestampHigh" and "IMAQdxReceiveTimestampLow."  Then call IMAQ Read Custom data for each key.  At this point you have data, but it is represented as a string.  These particular keys are U32s and together, the represent the 64-bit timestamp.  "IMAQdxReceiveTimestampHigh" is the 4 most significant bytes of the time stamp, and "IMAQdxReceiveTimestampLow" is the 4 least significant bytes of the timestamp.  So, you will need to use th Join Numbers function in LabVIEW to merge them correctly into one integer.  Next you will need to convert this U64 into a timestamp.  Now you have timestamp data from your image!

Block Diagram.png

Caveats and Additional Notes

You will notice that I have divided the U64 by 10^7 before converting to timestamp.  This is because timestamp takes an input of seconds (it represents the number of seconds that have passed since Midnight, Jan 1, 1904), and the U64 contains values in 100s of microseconds (or tenths of milliseconds).  This may vary a little bit for different cameras, so if you are not getting an accurate timestamp, check to see what the quotient is.  You may need to adjust the constant for your camera.

Wes Pierce
Principal Engineer
Pierce Controls

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Eric_R
NI Employee (retired)
on

This is very impressive please post more examples.


Thank You
Eric Reid
National Instruments
Motion R&D
BlueCheese
NI Employee (retired)
on

The timestamp being appended here is actually recorded by the IMAQdx driver at the time of the frame done interrupt, not from the firewire camera itself. It is then subjected to the jitter of the system's timing abilities. If you are using a GigE camera there is an additional *relative* timestamp sent by the camera that is accessible as well.

elac
Member
Member
on

Hi can you post the actual code file please I am having some trouble recreating this, thank you! Oh for Labview 2011 please

mgan
Member
Member
on

Actual code would be helpful. Where do you set up the 'IMAQdx property called "ReceiveTimestampMode" to "System Time." '

Wes_P
Member
Member
on

The VI used to be attached but I think NI removed several attached VIs some time ago. This VI is a pretty simple one though, and all of the relevant info is contained within the image and text.

Wes Pierce
Principal Engineer
Pierce Controls
45jgfhfhjg
Member
Member
on

Hi,

Do you know of any tutorial on how to accesse the camera timestamp? Thank you

Contributors