加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
read_images.cpp 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
sourishg 提交于 2016-06-30 18:39 . Add command line opts to read images
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <iostream>
#include "popt_pp.h"
using namespace std;
using namespace cv;
int x = 0;
int main(int argc, char const *argv[])
{
char* imgs_directory;
char* extension;
int im_width, im_height;
static struct poptOption options[] = {
{ "img_width",'w',POPT_ARG_INT,&im_width,0,"Image width","NUM" },
{ "img_height",'h',POPT_ARG_INT,&im_height,0,"Image height","NUM" },
{ "imgs_directory",'d',POPT_ARG_STRING,&imgs_directory,0,"Directory to save images in","STR" },
{ "extension",'e',POPT_ARG_STRING,&extension,0,"Image extension","STR" },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
POpt popt(NULL, argc, argv, options, 0);
int c;
while((c = popt.getNextOpt()) >= 0) {}
VideoCapture cap1(0);
VideoCapture cap2(1);
Mat img1, img_res1, img2, img_res2;
while (1) {
cap1 >> img1;
cap2 >> img2;
resize(img1, img_res1, Size(im_width, im_height));
resize(img2, img_res2, Size(im_width, im_height));
imshow("IMG1", img_res1);
imshow("IMG2", img_res2);
if (waitKey(30) > 0) {
x++;
char filename1[200], filename2[200];
sprintf(filename1, "%sleft%d.%s", imgs_directory, x, extension);
sprintf(filename2, "%sright%d.%s", imgs_directory, x, extension);
cout << "Saving img pair " << x << endl;
imwrite(filename1, img_res1);
imwrite(filename2, img_res2);
}
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化