/* * Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke * * This file is part of RTAB-Map. * * RTAB-Map is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RTAB-Map is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RTAB-Map. If not, see . */ #include "utilite/ULogger.h" #include "utilite/UTimer.h" #include "utilite/UDirectory.h" #include "utilite/UConversion.h" #include #include void showUsage() { printf("Usage:\n" "imagesJoiner.exe \"# (see below)\" \"type\" [option]\n" " # : Name pattern is how the file names are formatted (in number).\n" " Examples: 4 for pictures with 0001.jpg, 0002.jpg, ..., 0010.jpg, 0100.jpg, 1000.jpg, ...\n" " 1 for pictures with 1.jpg, 2.jpg, ..., 10.jpg, 100.jpg, 1000.jpg, ...\n" " type : is the extension (jpg, bmp, png...)\n" " Options:\n" " -inv option for copying odd images on the right\n" " -d # destination filename size\n"); exit(1); } int main(int argc, char * argv[]) { if(argc < 3) { showUsage(); } bool inv = false; unsigned int sizeFileName = std::atoi(argv[1]); unsigned int sizeTargetFileName = sizeFileName; std::string type = argv[2]; for(int i=3; i sizeB.height ? sizeA.height : sizeB.height; IplImage* targetImage = cvCreateImage(targetSize, imageA->depth, imageA->nChannels); if(targetImage) { cvSetImageROI( targetImage, cvRect( 0, 0, sizeA.width, sizeA.height ) ); cvCopy( imageA, targetImage ); cvSetImageROI( targetImage, cvRect( sizeA.width, 0, sizeB.width, sizeB.height ) ); cvCopy( imageB, targetImage ); cvResetImageROI( targetImage ); if(!cvSaveImage(fileNameTarget.c_str(), targetImage)) { printf("Error : saving to \"%s\" goes wrong...\n", fileNameTarget.c_str()); } else { printf("Saved \"%s\" \n", fileNameTarget.c_str()); } cvReleaseImage(&targetImage); } else { printf("Error : can't allocated the target image with size (%d,%d)\n", targetSize.width, targetSize.height); imagesExist = false; } } else { imagesExist = false; } if(imageA) { cvReleaseImage(&imageA); } if(imageB) { cvReleaseImage(&imageB); } counterJoined++; counterImages += 2; } return 0; }