We are using a C920 Camera on our robot and have encountered very bad FPS even when communicating directly through device cable and over the radio. This is our camera code. Any help is appreciated .
UsbCamera usbCamera = CameraServer.getInstance().startAutomaticCapture();
usbCamera.setVideoMode(VideoMode.PixelFormat.kYUYV, 640, 360, 60);
I don’t have one, but we use a C930e and that is typically in MJPEG format. YUYV is less compressed and could be slower.
There could be multiple causes for the poor FPS.
Compression: The images transmitted to the driver station are always transmitted in MJPG. Since you have the camera set to YUYV pixel format, that means the image must be compressed in software, which is going to slow down the FPS. If you set the camera to MJPG pixel format instead and set the dashboard to -1 or hardware compression and don’t set the resolution, then the compression will be performed by the camera instead of software (if you change the compression settings and resolution in the dashboard you’ll go back to software compression). However, the camera doesn’t give good controls over compression settings, so that may result in using more bandwidth than you want.
Resolution: Every pixel takes time, especially when using software compression. Do you really need a 640x360 image or can you get by with a fraction of that resolution? Using the lowest resolution you can live with will help with both FPS and bandwidth. In addition, some cameras have weird performance corners with some resolutions. It may be worth trying a different resolution just for that reason.
Camera settings: FPS can be restricted by a lot of other factors in the camera itself. USB cameras are generally used for conferencing applications and thus are optimized for lighting quality over FPS. In particular, turn off auto exposure and auto white balance.
Hey thanks for the help I got a solid 29.8 FPS now by reducing my resolution by half, I didnt realize that what I had was already large. I could not get the camera to go to MJPEG it would crash the robot. I also took out my auto white balance.