Problem
I’ve noticed that there is a lag with the camera image shown on the Dashboard. What is causing this and how can I fix it?
Solution
There are two different things that could be causing the lag that you’re seeing with the video shown on the Dashboard. If you see a big lag (~5 seconds), this is caused by a TCP backlog somewhere in your network between the camera, cRIO, bridge, router and laptop. Typically, the cRIO will be sending the camera images every 33ms but the classmate will display a new image every 100ms. This leads to a build up in the TCP cache on the classmate and after about 5 seconds the video jumps ahead to catch up to what is being recently seen by the camera.
A slightly different behavior you might notice is that the frame rate for the video is low. The frame rate is of the video is affected by the jpeg image size being sent by the camera. The larger your image is and the lower the compression of the image, the larger the size of data for an image. In general, we’ve noticed that images that are larger than 16kB causes more time to allocate memory for the image (~100ms) and images smaller than 16kB take much less time for memory allocation (~5ms).
The following are frame rates (in frames/second) that we have seen after some testing based on different compression ratios:
Image Size | Compression (%) | fps |
---|---|---|
160x120 | > 0 | 20 - 30 |
320x240 | < 25 | 8 -14 |
> 25 | 25 - 30 | |
640x480 | < 75 | 5 - 10 |
> 75 | 19 - 20 |
These rates are relatively similar whether you’re using LabVIEW or C++ to program your robot. Keep in mind that the camera is not capable of acquiring faster than 30 fps (or 1 frame every 33ms).
To change the compression ratio of the images go to the Begin VI and notice there is a series of Camera VI’s that initializes its settings. One of the VI’s is a Set Image Compression VI and you can wire in the compression ratio you would like to use. By default this value is 5.
If you are increasing the compression ratio to achieve a faster frame rate, keep in mind that high compression ratios affect image quality and this is not a linear affect. If you use a high compression ratio, the images you see on the dashboard will be distorted and the ellipse detection may not work as well.