在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。用之前把电脑自带摄像头禁用。
该博客介绍了如何在MATLAB环境下利用OpenCV库读取摄像头视频流,并实时分割左右图像,分别显示在两个窗口中。通过调整代码,可以适应不同的图像尺寸,适用于立体视觉或双目视觉系统的图像预处理步骤。
5743





