33 #include <opencv2/core/core.hpp>
34 #include <opencv2/highgui/highgui.hpp>
39 "imagesJoiner.exe [option] path\n"
40 "imagesJoiner.exe path_left path_right\n"
42 " -inv option for copying odd images on the right\n\n");
54 for(
int i=1;
i<argc-1; ++
i)
56 if(strcmp(
argv[
i],
"-inv") == 0)
59 printf(
" Inversing option activated...\n");
65 printf(
" Not recognized option: \"%s\"\n",
argv[
i]);
69 std::string
path, pathRight;
77 printf(
" Path left = %s\n",
path.c_str());
78 printf(
" Path right = %s\n", pathRight.c_str());
83 printf(
" Path = %s\n",
path.c_str());
87 UDirectory dirRight(pathRight,
"jpg bmp png tiff jpeg");
90 printf(
"Path invalid!\n");
94 std::string targetDirectory =
path+
"_joined";
96 printf(
" Creating directory \"%s\"\n", targetDirectory.c_str());
100 std::string fileNameB;
111 while(!fileNameA.empty() && !fileNameB.empty())
115 std::string tmp = fileNameA;
116 fileNameA = fileNameB;
124 cv::Mat imageA = cv::imread(fileNameA.c_str());
125 cv::Mat imageB = cv::imread(fileNameB.c_str());
130 if(!imageA.empty() && !imageB.empty())
132 cv::Size sizeA = imageA.size();
133 cv::Size sizeB = imageB.size();
134 cv::Size targetSize(0,0);
135 targetSize.width = sizeA.width + sizeB.width;
136 targetSize.height = sizeA.height > sizeB.height ? sizeA.height : sizeB.height;
137 cv::Mat targetImage(targetSize, imageA.type());
139 cv::Mat roiA(targetImage, cv::Rect( 0, 0, sizeA.width, sizeA.height ));
141 cv::Mat roiB( targetImage, cv::Rect( sizeA.width, 0, sizeB.width, sizeB.height ) );
144 if(!cv::imwrite(targetFilePath.c_str(), targetImage))
146 printf(
"Error : saving to \"%s\" goes wrong...\n", targetFilePath.c_str());
150 printf(
"Saved \"%s\" \n", targetFilePath.c_str());
165 printf(
"Error: loading images failed!\n");
168 printf(
"%d files processed\n",
i-1);