Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High speed video capture with opencv and PlayStation Eye

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
like image 504
Michel Gokan Khan Avatar asked Nov 13 '22 17:11

Michel Gokan Khan


1 Answers

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.

like image 123
Lightness Races in Orbit Avatar answered Dec 22 '22 07:12

Lightness Races in Orbit