I am using a NOIR Pi camera for my Raspberry Pi 3 module. I plan to run some high fps image processing algo using openCV in a C++ environment. However, I cant seem to obtain the video stream in a high enough fps. Setting CV_CAM_PROPS_FPS using openCV's VideoCapture class doesn't seem to do anything to the actual fps of the camera.
Is there a way I can adjust the FPS of the camera to 90fps within the cpp file or externally from the console? I don't mind reducing the resolution of the video.
[Edit]
Here is the code i am using
#include "stdio.h"
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
std::cout << "Init Program 2\n";
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
{
std::cout << "Camera Init Fail\n";
return -1;
}
std::cout << "Camera Init Successful\n";
std::cout << "Setting parameters..\n";
std::cout <<"\t[PARAM_FPS] ";
if(!cap.set(CV_CAP_PROP_FPS,15)){
std::cout <<"SUCCESS\n";
}else{
std::cout <<"FAIL\n";
}
std::cout <<"\t[PARAM_FRAME_WIDTH] ";
if(!cap.set(CV_CAP_PROP_FRAME_WIDTH,320)){
std::cout <<"SUCCESS\n";
}else{
std::cout <<"FAIL\n";
}
std::cout <<"\t[PARAM_FRAME_HEIGHT] ";
if(!cap.set(CV_CAP_PROP_FRAME_HEIGHT,240)){
std::cout <<"SUCCESS\n";
}else{
std::cout <<"FAIL\n";
}
int nFPS = cap.get(CV_CAP_PROP_FPS);
std::cout << "Loaded FPS : " << nFPS << "\n";
namedWindow("show",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("show", frame);
if(waitKey(1) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
[Solved]
The setting the FPS after setting the width and height seems to do the trick. That makes sense because a higher resolution image will cause a significant drop in the FPS. Therefore every time you change the geometry feature, the FPS will reset by default.