Camera Lag

My team is wanting to use a camera on our robot this year. We are using the Microsoft LifeCam 3000, and it works fine. However, there is about a one second delay. This makes the camera only barely useful. Anyone have any ideas how to reduce or eliminate that lag?

We haven’t seen a lag anywhere near that long when we did the simpleVision and intermediateVision java examples (we haven’t gotten very much farther than that yet). We were able to get what we could believe was 30 fps at 640 pixels across over twisted pair with perhaps a tenth of a second lag (when someone spoke, it looked like a poorly dubbed movie). We haven’t tried wireless yet.

  • What resolution, frame rate, and picture quality are you using?
  • What is the USB cable connected to (raspberry pi, roboRIO, something else)? If a pi or something else, how is that signal getting to the roboRIO?
    What language and libraries are you using?
  • Have you tried the simplevision or intermediatevision examples?

Likewise, the MS camera has been extremely responsive for us. There’s a delay like you would expect - 100-200 ms.

What are the camera settings and dashboard settings? What bandwidth does the dashboard report?

Greg McKaskle

CameraServer.getInstance().setQuality(50);
    	CameraServer.getInstance().startAutomaticCapture("cam0");

This is our code… We had to get it down to 1/100 and there was still a full second of lag. We do have alot going through our robot and the Lifecam caused wayy too much lag so much to the point where we could not drive our robot. Our team is pulling off the camera now is there any way to reduce the lag? It is put directly into the USB port.

THANKS!

The vision white paper a few years included info on camera settings and how they affect the image and the size.

The summary is that compression will reduce the size of the image. It is hard to estimate the size of a compressed image, so some cameras also support a bandwidth limited option, but WPILib doesn’t expose that since it is a bit advanced and not present on all cameras. The frame rate has a direct, linear relationship to the bandwidth needed. The size of the image determines how many pixels and each step down reduces the size by 4x.

So, if you give the rest of the settings of the camera, we can give better input. The default dashboard shows the fps or frames per second, and it shows the Mbps or Megabits per second. The selector allows you to change the major contributors to bandwidth usage. The LED gives a pretty good indication as to where you are regarding bandwidth usage.

A pretty good rule of thumb is that if you are not receiving as many frames as you request, that your devices will buffer the unread frames and that will cause lag.

Also, what is the CPU usage of the laptop and the roboRIO? If either are maxed out, they may introduce lag.

Greg McKaskle

We lower the bandwith and get the FPS we request. Right now it is the lowest setting we can put it at 160x120 5FPS 30% compression. We should (in theory) have almost no lag. But we should not have the robot stop a full second after we let go of our joystick. Btw the CPU isn’t maxed out and I don’t know how to check the roboRIO processor.

We lower the bandwith and get the FPS we request. Right now it is the lowest setting we can put it at 160x120 5FPS 30% compression. We should (in theory) have almost no lag. But we should not have the robot stop a full second after we let go of our joystick. Btw the CPU isn’t maxed out and I don’t know how to check the roboRIO processor.

The roboRIO processor usage is plotted on the chart tab on the right. It is the red line on the lower plot. This info is also logged and can be viewed after the fact using the log file viewer. The Logs… button will launch that for you.

Also, it sounds like you have robot lag, not camera lag like the original post.

Does this happen when the camera is disabled?

It may make the most sense for you to post some log files. You can open the log file viewer and scroll to the bottom and click on some of the logs for one that isn’t mostly empty. Post a screenshot, or you can go to Users/public/documents/FRC/Log Files and access the actual files there.

Greg McKaskle