答案 0 :(得分:0)
因此,启动和运行ps3eye会因您运行的操作系统而异。如果您运行任何Debian风格,驱动程序已经存在,我下面的代码应该可以正常工作。
如果你在Windows上,你将不得不为它找到一个驱动程序。 CodeLibrary已经制作了一个驱动程序,但你需要支付3美元。链接的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为您提供合适的摄像头。