使用opencv和PlayStation Eye进行高速视频捕捉

时间:2011-09-16 15:34:57

标签: c++ macos opencv camera

我正在开发一个需要低分辨率和大约110 fps的项目。所以我买了30美元的PlayStation眼睛,在240分辨率下提供120 fps的320分辨率。

我安装了以前版本的macam(因为最新版本没有用)并成功获得大约120 fps(但由于macam中的一些错误,我无法录制)。

enter image description here

我写了一个简单的代码,将每个帧保存为jpg文件:

 #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;
 }

但它每秒只能节省30帧。我的意思是它创建30个文件而不是每秒110个文件。有什么问题?

更新:我使用以下命令编译上面的代码:

g++ main.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv` -o exec -m32

1 个答案:

答案 0 :(得分:1)

cvWaitKey(10);等待10毫秒。

110Hz的帧速率需要每9ms拍摄一次快照,此外还有用于保存帧的处理时间。

这是一个问题,除了CV_CAP_PROP_FPS没有按预期工作。