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

Example for 3D output of a camera path as VRML ,ThreeDOut

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 ExampleCameraPath2Vrml.cpp
* @relates ImageIO,ThreeDOut
@ingroup g_examples
@brief Example for 3D output of a camera path as VRML
@author MIP */
#include <Utils/ThreeDOut.hh>
#include <Utils/Param.hh>
#include <Image/Camera.hh>
#include <Base/Image/ImageIO.hh>
#include <vector>
using namespace std;
using namespace BIAS;
int main(int argc, char* argv[]) {
Param params(true);
string* imagesList =
params.AddParamString("imagesList",
"pass list of images containing projections", "");
string* outputName =
params.AddParamString("output",
"name of resulting wrl", "");
Vector<double>* color =
params.AddParamVecDbl("color",
"color of coord frame, default [0.0 0.0 0.0 255.0]",
"0.0 0.0 0.0 255.0");
double* scale =
params.AddParamDouble("scale", "scales the cameras", 1.0, 0.1);
bool* help = params.AddParamBool("help", "this helpful output", false, 'h');
params.ParseCommandLine(argc, argv);
if(*help) {
cout<<argv[0]<<" converts a list of projections into a vrml\n";
params.Usage();
return 0;
}
vector<string> vectorOfImageNames;
Param::ParseListFile(*imagesList, vectorOfImageNames);
vector<string>::iterator begin = vectorOfImageNames.begin();
vector<string>::iterator end = vectorOfImageNames.end();
Projection Proj;
ThreeDOut tdo;
for(vector<string>::iterator pos=begin; pos!=end; pos++) {
if(ImageIO::Load(*pos, img) != 0) {
BIASERR("could not image "<<*pos<<"!");
return -1;
}
Proj = img.GetProj();
RGBAuc col;
col[0] = (unsigned char)((*color)[0]);
col[1] = (unsigned char)((*color)[1]);
col[2] = (unsigned char)((*color)[2]);
col[3] = (unsigned char)((*color)[3]);
tdo.SetParams(tdoParams);
tdo.AddProjection(Proj, col, 0.1, *scale, "", 1);
//const RGBAuc &colorSelection=RGBAuc_WHITE_OPAQUE, const double radius=0.1, const double scale=1.0
}
tdo.VRMLOut(*outputName);
cout<<"finished\n";
return 0;
}