PDA

View Full Version : snapImages Performance



jdbethun
July 8, 2005, 18:00:41
Hey guys,

We've had a Sony DFW X-710 camera w/ the IC Capture software for sometime now and have stumbled across some performance issues, at least for our application.

We're finding the snapImages function is taking between 10 and 120 ms. To test this, we're using MemBufferCollection of 10 (just to see correlation of removal and addition of new images to the collection), and calling the snapImages function at random times between 0 and 600 ms. As you'll see at the end of this message, the time to execute is quite variable, and for our application is not acceptible because it introduces jitter into our pictures (we're taking them from a moving vehicle so consistency is important). If there is anyway to ensure consistent performance please let me know ASAP.


Here's a code snippit:

for(j = 0; j < 50; j++){
random = nrand(600);
Sleep(random);
cout << "Slept for " << random << " milliseconds" << '\t';

//Time snapping
startTime = timeGetTime();
bool snapped = m_pGrabber->snapImages( 1, 200 );
finishTime = timeGetTime();

cout << "Snapping took: " << (finishTime - startTime)<< '\n';

//if image couldn't be snapped return any error
if(!snapped) {
return E_POINTER;
}
}

And the output:
Slept for 0 milliseconds Snapping took: 42
Slept for 341 milliseconds Snapping took: 57
Slept for 117 milliseconds Snapping took: 83
Slept for 490 milliseconds Snapping took: 109
Slept for 354 milliseconds Snapping took: 45
Slept for 291 milliseconds Snapping took: 111
Slept for 212 milliseconds Snapping took: 50
Slept for 543 milliseconds Snapping took: 55
Slept for 499 milliseconds Snapping took: 33
Slept for 453 milliseconds Snapping took: 13
Slept for 105 milliseconds Snapping took: 91
Slept for 521 milliseconds Snapping took: 11
Slept for 431 milliseconds Snapping took: 101
Slept for 311 milliseconds Snapping took: 88
Slept for 184 milliseconds Snapping took: 15
Slept for 9 milliseconds Snapping took: 57
Slept for 55 milliseconds Snapping took: 78
Slept for 221 milliseconds Snapping took: 44
Slept for 89 milliseconds Snapping took: 43
Slept for 100 milliseconds Snapping took: 99
Slept for 599 milliseconds Snapping took: 66
Slept for 270 milliseconds Snapping took: 61
Slept for 72 milliseconds Snapping took: 127
Slept for 2 milliseconds Snapping took: 63
Slept for 5 milliseconds Snapping took: 127
Slept for 229 milliseconds Snapping took: 36
Slept for 322 milliseconds Snapping took: 10
Slept for 346 milliseconds Snapping took: 53
Slept for 365 milliseconds Snapping took: 34
Slept for 368 milliseconds Snapping took: 31
Slept for 100 milliseconds Snapping took: 99
Slept for 402 milliseconds Snapping took: 63
Slept for 273 milliseconds Snapping took: 59
Slept for 213 milliseconds Snapping took: 52
Slept for 34 milliseconds Snapping took: 99
Slept for 368 milliseconds Snapping took: 31
Slept for 475 milliseconds Snapping took: 124
Slept for 487 milliseconds Snapping took: 112
Slept for 315 milliseconds Snapping took: 84
Slept for 183 milliseconds Snapping took: 17
Slept for 531 milliseconds Snapping took: 68
Slept for 440 milliseconds Snapping took: 25
Slept for 580 milliseconds Snapping took: 20
Slept for 561 milliseconds Snapping took: 39
Slept for 327 milliseconds Snapping took: 68
Slept for 86 milliseconds Snapping took: 46
Slept for 280 milliseconds Snapping took: 120
Slept for 142 milliseconds Snapping took: 56
Slept for 523 milliseconds Snapping took: 76
Slept for 127 milliseconds Snapping took: 70

Thanks,

Jeff Bethune
Product Development Manager
Tannery Creek Systems

Stefan Geissler
July 11, 2005, 08:19:47
Jeff

What you have measured it not the performance of the software but the frame rate of the camera. SnapImage() will return, after a complete frame has been delivered. This means, if snapImages() is called due to a frame delivery, the current frame is invalid (the beginning is missing) and thrown away. In the worst case snapImages() was called just a millisecond after a frame was started. SnapImages() would return after 121 ms (1000/15 *2 , 15 = fps, 2 = count of frames). This explains why you get different duration times of snapImages().

There could be two ways to solve this problem:
1. The SONY Dcam has an external trigger. You could use this trigger to let the camera snap an image exactly at the point of time you need the image. You would need an external hardware, that creates the TTL trigger pulse. The image would be saved into memory by a call to snapImages with a very long time out time. SnapImage() would wait for the image and return after it has been delivered by the camera.
2. Snap all incoming images to a ring buffer. When you need to save an image, get the image that has been snapped at the nearest point of time you need. With this method you would have a sequence of images that have been saved around the point of time that is of interest for you. But you would seldom have an image, that was taken exactly at the point of time your event to snap occurred.
For this method you would not call snapImages() but you would set the framegrabbersink from the current “eSNAP” to “eGRAB”. After your image snap event occurred, you would lock all buffers, so they wont be overwritten. Then you would examine them and select the most matching image. Have a look to MemBuffer::getSampleDesc method, that gives you the sample times.(http://www.imagingcontrol.com/ic/docs/html/class/meth_descMemBuffer_getSampleDesc.htm)

I hope this gives you an idea how the camera live stream works and how to solve your problem.