I'm using a webcam for Aruco detection which suppose to give 90FPS at 640X480 (MJPEG) or less using YUY2 capture.
In OpenCV when I'm getting up to 30 fps no matter what. I made sure the resolution is set to 640X480 and before that defined the FOURCC as MJPEG.
inputVideo.open(camId);
inputVideo.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
inputVideo.set(cv::CAP_PROP_FRAME_HEIGHT, height);
inputVideo.set(cv::CAP_PROP_FRAME_WIDTH, width);
inputVideo.grab()
.
.
.
Any idea how can I get higher FPS using OpenCV
Update
This is the code I use to grab frames and calculate FPS
VideoCapture video2(0);
video2.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
video2.set(cv::CAP_PROP_FRAME_WIDTH, 640);
int h = video2.get(CAP_PROP_FRAME_HEIGHT);
int w = video2.get(CAP_PROP_FRAME_WIDTH);
double fps = video2.get(CAP_PROP_FPS);
cout << "Frames per second using video.get(CV_CAP_PROP_FPS) : " << w << " " << h << " " << fps << endl;
// Number of frames to capture
int num_frames = 120;
// Start and end times
time_t start, end;
// Variable for storing video frames
Mat frame;
cout << "Capturing " << num_frames << " frames" << endl;
// Start time
time(&start);
// Grab a few frames
for (int i = 0; i < num_frames; i++)
{
video2 >> frame;
}
// End Time
time(&end);
// Time elapsed
double seconds = difftime(end, start);
cout << "Time taken : " << seconds << " seconds" << endl;
// Calculate frames per second
fps = num_frames / seconds;
cout << "Estimated frames per second : " << fps << endl;
// Release video
video2.release();
return 0;