5

I'm working on a project which need low resolution and about 110 fps. So i bought 30$ PlayStation eye which provide 120 fps in 320 in 240 resolution.

I installed previous version of macam( because latest version didn't work ) and successfully get about 120 fps( but i can't record because of some bugs in macam ).

enter image description here

I wrote a simple code to save each frame as a jpg file:

 #include <stdio.h>
 #include "cv.h"
 #include "highgui.h"
 #include<iostream>
 using namespace std;

 int main(int argc, char** argv) {

     int i = 0;
     char *buf;
     IplImage *frame;
     CvCapture* capture = cvCreateCameraCapture(3);
     cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 320);
     cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
     cvSetCaptureProperty( capture, CV_CAP_PROP_FPS, 110);

     while (true) {

         frame = cvQueryFrame(capture);
         asprintf(&buf, "%d.jpg", i++);
         cvShowImage("1", frame);
         cvSaveImage(buf, frame);
         cvWaitKey(10);
     }
     return 0;
 }

but it's only save 30 frames per second. I mean it creates 30 files instead of 110 files per second. What's the problem ?

Update: i compile above code using following command:

g++ main.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv` -o exec -m32
Michel Gokan Khan
  • 2,525
  • 3
  • 30
  • 54
  • possible duplicate of [How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake](http://stackoverflow.com/questions/7039575/how-to-set-camera-fps-in-opencv-cv-cap-prop-fps-is-a-fake) – genpfault Sep 16 '11 at 15:54
  • no it's not ... that question is about something else man. – Michel Gokan Khan Sep 16 '11 at 16:09
  • I agree with @genpfault We know that CV_CAP_PROP_FPS don't work as expected. That question have some useful information on how to get OpenCV to work with custom FPS settings. – karlphillip Sep 16 '11 at 16:15
  • @Michel Kogan, I ran into the same problem, have u find a way to solve it? What will happen if u use cvWaitKey(1)? In principle it will only sleep for 1 ms, so it will not affect the FPS. However, I still get very slow FPS. You are quite right, the CV_CAP_PROP_FPS seems no effect at all. OpenCV2.4.3 – Wang Nov 07 '12 at 18:50
  • @Wang : not really , but I think the easiest way to do this is to switch to a painful Windows PC ! – Michel Gokan Khan Nov 10 '12 at 06:10
  • 1
    Maybe it will help you http://code.google.com/p/qt-opencv-multithreaded/wiki/Documentation (but I just read it, I didn't try it) –  Dec 27 '12 at 16:09

1 Answers1

1

cvWaitKey(10); waits for 10ms.

A frame rate of 110Hz requires a snapshot every 9ms, plus there is processing time for the saving of the frame.

So that's an issue here, in addition to CV_CAP_PROP_FPS not working as expected.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055