双目相机图片分割为左右两张图片

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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。用之前把电脑自带摄像头禁用。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值