Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleGenSynthMatchesRig.cpp

Example for generating synthetic matches using rigs of cameras

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExampleGenSynthMatchesRig.cpp
* @relates GenSynthMatchesRig
@ingroup g_examples
@brief Example for generating synthetic matches using rigs of cameras
@author MIP */
#include <iostream>
#include <Base/Common/BIASpragma.hh>
#include <Utils/GenSynthMatchesRig.hh>
#include <Base/Image/ImageIO.hh>
#include <sstream>
#include <string>
using namespace BIAS;
using namespace std;
#define DEFAULT_PARA_FILE_NAME "GenSynthMatchesRig.ini"
#define DEBUG true
int main(int argc, char *argv[])
{
Param para;
GenSynthMatchesRig gsm(para), gsm2(para);
bool FoundDefaultParaFile=true;
ifstream is(DEFAULT_PARA_FILE_NAME);
if (!is){
is.close();
if (DEBUG) cerr << "reading "<<DEFAULT_PARA_FILE_NAME<<" failed"<<endl;
FoundDefaultParaFile=false;
} else {
if (DEBUG) cerr << "reading "<<DEFAULT_PARA_FILE_NAME<<endl;
para.ReadParameter(DEFAULT_PARA_FILE_NAME);
}
int argind = para.ParseCommandLine(argc, argv);
if (argind<0){
BIASERR("error parsing command line");
return -1;
}
if ((!FoundDefaultParaFile) && (*para.GetParamString("readconfig")=="")) {
cerr << "no parameter file found, writing default to "
<<DEFAULT_PARA_FILE_NAME<<"\n";
para.SetWriteOptions(true, false, false);
para.WriteParameter(DEFAULT_PARA_FILE_NAME);
}
// para.ShowData();
gsm.CreateMatches();
cout << gsm <<endl;
// gsm.Write("dataRig.xml");
// gsm2.Read("dataRig.xml");
// cout << gsm2 <<endl;
//vecotor to store an image for each cam
std::vector<Image<unsigned char> >im;
//draw images of each cam from time step 0 to 1
gsm.DrawTrue(im, 0, 1);
std::vector<Image<unsigned char> >::iterator imIt;
stringstream oss;
int i;
//now write the images to files
for (imIt = im.begin(), i = 0; imIt != im.end(); imIt++, i++) {
oss << i;
//ImageIO::Save("true" + oss.str() + "_01.mip", *imIt);
ImageIO::Save("true" + oss.str() + "_01.mip", *imIt);
oss.str("");
}
return 0;
}