Hello I’m the programmer for my team and we are trying to use a ELP USB camera for driving. The problem is the frames per second only reach around 8 frames per second. For code its
UsbCamera camera = CameraServer.startAutomaticCapture();
camera.setVideoMode(PixelFormat.kMJPEG, 160, 120, 30);
Any help greatly appreciated.
You may find this page useful.
Have you checked the status return of
camera.setVideoMode? Have you tried calling
We weren’t able to set the ELP to our desired settings using the setVideoMode method and instead ended up using the following code.
In our variable declaration area:
mjpegServer1.setSource(intakeCamera); mjpegServer1.setResolution(160,120); mjpegServer1.setFPS(10); CameraServer.putVideo("Intake Camera", 160, 120);
In our initialize function (runs on startup):
private UsbCamera intakeCamera = new UsbCamera("USB Camera 0", 0); private MjpegServer mjpegServer1 = new MjpegServer("Intake Camera", 1181);
It seems the ELP only supports a fixed number of video modes, of which 160x120 resolution is not available. Using these settings we get reasonably low latency with ~.6 mps used. We could bump up our framerate a bit, but our driver cares a lot more about latency than framerate so we haven’t tried that.
You can see the video modes the camera supports on the camera server webpage: CameraServer Web Interface — FIRST Robotics Competition documentation
If you’re using a mode the camera doesn’t support, then the roboRIO is scaling the image, which increases latency. The lowest latency approach is to use a video mode the camera supports, assuming it fits within the bandwidth limits.