0
您好,我正在基於模板匹配項目工作。我需要一個相機接口。 我的代碼面臨的問題與相機分辨率有關。我需要使用我的Logitech HD C270網絡攝像頭獲得最高分辨率。是否有可能獲得640x480或更高的分辨率?Opencv相機分辨率問題
這是我的代碼,我試圖獲得640x480分辨率,但我得到一些錯誤。 請幫忙。 的#include 的#include 的#include 的#include
using namespace cv;
using namespace std;
int n = 0;
static char cam_image[200];
int capture_image(cv::Mat& frame_in) {
VideoCapture capture(-1); //try to open string, this will attempt to open it as a video file or image sequence
if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
capture.open(-1);
capture = cvCreateCameraCapture(-1);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
//videoFrame = cvQueryFrame(capture);
if (!capture.isOpened()) {
cerr << "Failed to open the video device, video file or image sequence!\n" << endl;
//help(av);
return 1;
}
string window_name = "Reference Image";
namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
Mat frame;
capture >> frame;
if (frame.empty());
frame_in= frame;
imshow(window_name, frame);
waitKey(30);
sprintf(cam_image,"filename%.3d.jpg",n++);
imwrite(cam_image,frame);
cout << "Saved " << cam_image << endl;
return 0;
}
camera.h: In function ‘int capture_image(cv::Mat&)’:
camera.h:17:43: error: invalid conversion from ‘CvCapture*’ to ‘int’ [-fpermissive]
/usr/local/include/opencv2/highgui/highgui.hpp:209:13: error: initializing argument 1 of ‘cv::VideoCapture::VideoCapture(int)’ [-fpermissive]
camera.h:18:65: error: cannot convert ‘cv::VideoCapture’ to ‘CvCapture*’ for argument ‘1’ to ‘int cvSetCaptureProperty(CvCapture*, int, double)’
camera.h:19:66: error: cannot convert ‘cv::VideoCapture’ to ‘CvCapture*’ for argument ‘1’ to ‘int cvSetCaptureProperty(CvCapture*, int, double)’