opencv打开双目,采集标定双目的图片
Opencv 图片 打开 采集 标定 双目
2023-09-27 14:25:50 时间
1 按 “C/ c”后图片会保存在根目录的pic文件夹中,首先好新建 pic文件夹。
#include <opencv2\opencv.hpp>
#include <iostream>
#include <Windows.h>
#include<string>
#include<vector>
using namespace cv;
using namespace std;
#define typecam//2个相机驱动
//int main17060500()
int main()
{
Mat view0;
#ifndef typecam
VideoCapture m_InputCapture(0);
Mat view0;
m_InputCapture.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
m_InputCapture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
while (!m_InputCapture.isOpened())
{
Sleep(2);
cout << "cannot open the camera!" << endl;
}
#else
VideoCapture m_InputCapturel(0);
VideoCapture m_InputCapturer(2);
m_InputCapturel.set(CV_CAP_PROP_FRAME_WIDTH, 640);
m_InputCapturel.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
m_InputCapturer.set(CV_CAP_PROP_FRAME_WIDTH, 640);
m_InputCapturer.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
while (!m_InputCapturel.isOpened())
{
Sleep(2);
cout << "cannot open the cameral!" << endl;
}
while (!m_InputCapturer.isOpened())
{
Sleep(2);
cout << "cannot open the camerar!" << endl;
}
#endif // !typecam
printf("按“C”键截取当前帧并保存为标定图片...\n按“Q”键退出截取帧过程...\n\n");
int number_image = 1;
char *str1;
str1 = ".jpg";
char filenamel[20] = "";
char filenamer[20] = "";
for (;;)
{
Mat mLeftView, mRightView;
#ifndef typecam
m_InputCapture >> view0;
mLeftView = view0(cv::Rect(0, 0, 640, 480));
mRightView = view0(cv::Rect(640, 0, 640, 480));
#else
m_InputCapturel >> mLeftView;
m_InputCapturer >> mRightView;
#endif // !typecam
imshow("cameraR", mRightView);
imshow("cameraL", mLeftView);
char mod = (char)waitKey(100);
if (mod == 'c' || mod == 'C')
{
sprintf_s(filenamel, "pic/left%d.jpg", number_image);
imwrite(filenamel, mLeftView);
sprintf_s(filenamer, "pic/right%d.jpg", number_image);
imwrite(filenamer, mRightView);
cout << "成功获取当前帧,并以文件名" << filenamel << "保存...\n\n";
cout << "成功获取当前帧,并以文件名" << filenamer << "保存...\n\n";
printf("按“C”键截取当前帧并保存为标定图片...\n按“Q”键退出截取帧过程...\n\n");
number_image++;
}
else if (mod == 'q' || mod == 'Q')
{
printf("截取图像帧过程完成...\n\n");
cout << "共成功截取" << --number_image << "帧图像!!\n\n";
break;
}
}
return 0;
}
相关文章
- 用cv::Scalar来设置opencv中图片的颜色
- [OpenCV开发]OpenCV图像编码和解码 imencode和imdecode使用,用于网络传输图片
- 【计算机视觉】OPENCV对于有alpha通道的透明背景图片的读取和图片叠加
- OpenCV入门之寻找图像的凸包(convex hull)
- [OpenCV] Image Denoising
- OpenCV实现SfM(三):多目三维重建
- opencv 图像梯度
- OpenCV+TensorFlow图片手写数字识别(附源码)
- VS QT opencv打开显示图片,界面添加工具栏,在工具栏中添加字体和颜色对话框功能
- OpenCV人工智能图像处理学习笔记1目录
- opencv sobel算子的理解
- Improving Opencv 6: The Core Functionality :Changing the contrast and brightness of an image!
- Opencv split函数 把图片分成rgb三通道
- Python,OpenCV制作全透明图,简单的图片
- Python OpenCV 保存视频中有人脸的图片
- OpenCV肤色检测
- python-opencv-文字与图片的绘制
- 关于opencv中人脸识别主函数的部分注释详解。
- Python通过URL打开图片opencv / skimage / PIL