将双目相机拍照并且分为左右两张图片
1、C++版
#include "opencv2/opencv.hpp"
#include <string>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
VideoCapture inputVideo(1);//0-笔记本自带摄像头,1-外接usb双目摄像头
if (!inputVideo.isOpened())
{
cout << "Could not open the input video " << endl;
return -1;
}
Mat frame, Left, Right;
string leftname,rightname;
int f = 1;
while (1) //Show the image captured in the window and repeat
{
inputVideo >> frame; // read
if (frame.empty()) break; // check if at end
Left = frame(Rect(0, 0, frame.size().width / 2, frame.size().height)); //分割图片
Right = frame(Rect(frame.size().width / 2, 0, frame.size().width / 2, frame.size().height));
imshow("Left", Left);
imshow("Right", Right);
char key = waitKey(1);
if (key == 27)break;
if (key == 'q' || key ==