camera FPS code in C++

Has anyone found out what we should use to set the camera FPS in c++. I noticed that there appears to be several ways to do it in java with the most simple being camera.setFPS(), but there appears to be nothing in the C++ wpi library that does that.

I noticed that through the driver station you have the option to change the FPS settings there, but the FPS slider in the driver station appears to do nothing. At least i see no difference in the FPS no matter what value i move the slider to. Based on what the driver station shows it seems like we are locked to 30 FPS.

I’m not exactly sure how you guys are streaming video, but this can be an option.

http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=fps#videowriter-videowriter

The documentation uses OpenCV 2.4.

Here is how we do it:
VideoCapture GearCap("/dev/gearcam"); // open the default camera
GearCap.set(CV_CAP_PROP_FRAME_WIDTH,inputframewidth);
GearCap.set(CV_CAP_PROP_FRAME_HEIGHT,inputframeheight);
GearCap.set(CV_CAP_PROP_FPS,gearfpsused);

You will need to figure out what your camera supports as far as FPS and frame size. This can be done following:

Regards,
K Murphy

sorry it put some spaces in the code where they should not have been:
VideoCapture GearCap("/dev/gearcam"); // open the default camera
GearCap.set(CV_CAP_PROP_FRAME_WIDTH,inputframewidth);
GearCap.set(CV_CAP_PROP_FRAME_HEIGHT,inputframeheight);
GearCap.set(CV_CAP_PROP_FPS,gearfpsused);

First (if you want to use the camera server class)
Use cs::UsbCamera camera; for USB cameras or
Use cs::AxisCamera camera; for Axis camera

Then camera = CameraServer::GetInstance()->StartAutomaticCapture();
To start capturing am image

Then camera.SetFPS(10);
To set fps

Then camera.SetResolution(480, 320);
To set resolution

Hope that helps :slight_smile:

Also for Axis cameras start automatic capture might not work so you might have to look up the command to specify an IP instead