2015-12-15 102 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給你正確的相機。