2015-12-15 53 views
1

如果可能,我希望使用外部PS眼镜每秒节省30帧。 enter image description here如何使用openCV操作PS眼睛

我不知道在哪里可以找到指南或代码,因为我很确定它应该在网上的某个地方。

Anyhelp,将不胜感激。提前致谢!

回答

0

因此,启动并运行ps3eye取决于您运行的是哪个操作系统。如果你运行的是Debian的任何风格,那么驱动程序已经存在了,下面的代码应该可以正常工作。

如果你在Windows上,你必须找到它的驱动程序。 CodeLibrary已经有一个驱动程序,但你必须支付3美元。 Link的here

我不知道为Mac,但有点挖掘发现this,这可能工作。

一旦你安装了驱动程序,你应该可以像任何其他相机一样访问它。

的该代码

简单位低于:

#include "stdafx.h" 
#include <opencv/cxcore.h> 
#include <opencv2\core\mat.hpp> 
#include <opencv2/highgui/highgui.hpp> 
#include <iostream> 
#include <opencv/cxcore.h> 
#include <opencv/highgui.h> 
#include <opencv/cv.h> 
#include <opencv2/opencv.hpp> 
#include <opencv2/core/core.hpp> 
#include <opencv2/videoio/videoio.hpp> 

using namespace cv; 
using namespace std; 


int main() { 

    Mat image; 

    bool escnotpressed = true; 

    VideoCapture cap(0); // open the default camera 
    if(!cap.isOpened()) // check if we succeeded 
     return -1; 
    cap.set(CV_CAP_PROP_FPS, 30); //sets framerate 

    String capturePath = "C:/this/is/a/path.avi"; 
    Size frameSize = Size(cap.get(CV_CAP_PROP_FRAME_WIDTH), cap.get(CV_CAP_PROP_FRAME_HEIGHT)); 

    VideoWriter savedCapture; 
    savedCapture.open(capturePath, VideoWriter::fourcc('M','J','P','G'), 30.0, frameSize, true); 

    if (!savedCapture.isOpened()) { 
     return -2; 
    } 

    while(escnotpressed) { //loops 
     cap >> image; 
     if (image.empty()) { 
      cout << "camera feed got interrupted" << endl; 
      return 5; //dies if camera feed is interrupted for some reason 
     } 
     imshow("Image", image); 

     savedCapture << image; 

     int c = waitKey(10); 
     if((char)c == 27) { escnotpressed = false;} 
    } 

    savedCapture.release(); 
    cout << "Done!" << endl; 

} 

编辑:如果您在您的计算机上有多个摄像头,则可能需要到VideoCapture帽(0)更改为VideoCapture帽(X) ,其中x给你正确的相机。