0

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;
Alophind
  • 842
  • 2
  • 12
  • 27
  • 1
    Please give representative code. What you show only grabs one frame and doesn't show any processing or timing. – Mark Setchell Aug 26 '18 at 12:40
  • The processing isn't relevant , even if I just capture 120 frames and check the time it took , its 4 sec... I'll update code. – Alophind Aug 26 '18 at 13:21
  • 1
    You'd be surprised how often people say they can't achieve 60fps when they have a `waitKey(30)` in their code that waits 30ms between frames... – Mark Setchell Aug 26 '18 at 13:36
  • 1
    Did you try setting the FPS? And what FPS does it report when you get it and print it? How is the camera connected and which one is it? – Mark Setchell Aug 26 '18 at 13:40
  • https://www.amazon.com/ELP-Camera-Megapixel-Windows-Android/dp/B00KA7WSSU This is an example camera (60FPS) , I didn't set FPS (using default) because it should be at highest fps at min resolution. What do you suggest I'll try ? – Alophind Aug 26 '18 at 14:13
  • @MarkSetchell I can't read camera FPS because its for video stream , I need to calculate it which is what I do (capture 120 frames and check time) – Alophind Aug 26 '18 at 14:21
  • 1
    Why are you sending me a link for a 60fps camera when yours is 90fps? – Mark Setchell Aug 26 '18 at 18:37
  • @MarkSetchell because I changed to this one and it also doesn't give me more than 60fps... the 90fps is a camera I don't have a link to product , but this 60fps camera is one I also use and can send you link... thing is , the FPS doesn't go above 30 – Alophind Aug 27 '18 at 11:45

0 Answers0