在matlab里面标定时,需要将左右图片分别放在两个文件夹里。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
int main()
{
VideoCapture cap(0);
while (1)
{
Mat frame;
cap >> frame;
resize(frame, frame, Size(1280, 480));//set size of image
Mat leftImage, rightImage;
leftImage = frame(Rect(0, 0, frame.size().width / 2, frame.size().height));//split left image
rightImage = frame(Rect(frame.size().width / 2, 0, frame.size().width / 2, frame.size().height));//split right image
imshow("leftImage", leftImage);//left image
imshow("rightImage", rightImage);//right image
waitKey(33);
}
return 0;
}
文件名后缀.cpp。用之前把电脑自带摄像头禁用。