Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleCameraPath2Vrml.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 /** @example ExampleCameraPath2Vrml.cpp
26  * @relates ImageIO,ThreeDOut
27  @ingroup g_examples
28  @brief Example for 3D output of a camera path as VRML
29  @author MIP */
30 
31 #include <Utils/ThreeDOut.hh>
32 #include <Utils/Param.hh>
33 #include <Image/Camera.hh>
34 #include <Base/Image/ImageIO.hh>
35 
36 #include <vector>
37 
38 using namespace std;
39 using namespace BIAS;
40 
41 
42 int main(int argc, char* argv[]) {
43  Param params(true);
44 
45  string* imagesList =
46  params.AddParamString("imagesList",
47  "pass list of images containing projections", "");
48  string* outputName =
49  params.AddParamString("output",
50  "name of resulting wrl", "");
51 
52  Vector<double>* color =
53  params.AddParamVecDbl("color",
54  "color of coord frame, default [0.0 0.0 0.0 255.0]",
55  "0.0 0.0 0.0 255.0");
56 
57  double* scale =
58  params.AddParamDouble("scale", "scales the cameras", 1.0, 0.1);
59 
60  bool* help = params.AddParamBool("help", "this helpful output", false, 'h');
61 
62 
63  params.ParseCommandLine(argc, argv);
64 
65  if(*help) {
66  cout<<argv[0]<<" converts a list of projections into a vrml\n";
67  params.Usage();
68  return 0;
69  }
70 
71  vector<string> vectorOfImageNames;
72  Param::ParseListFile(*imagesList, vectorOfImageNames);
73 
74  vector<string>::iterator begin = vectorOfImageNames.begin();
75  vector<string>::iterator end = vectorOfImageNames.end();
77  Projection Proj;
78  ThreeDOut tdo;
79  for(vector<string>::iterator pos=begin; pos!=end; pos++) {
80  if(ImageIO::Load(*pos, img) != 0) {
81  BIASERR("could not image "<<*pos<<"!");
82  return -1;
83  }
84  img.ParseMetaData();
85  Proj = img.GetProj();
86  RGBAuc col;
87  col[0] = (unsigned char)((*color)[0]);
88  col[1] = (unsigned char)((*color)[1]);
89  col[2] = (unsigned char)((*color)[2]);
90  col[3] = (unsigned char)((*color)[3]);
91 
92  ThreeDOutParameters tdoParams;
93  tdoParams.CameraStyle = PyramidSolid;
94 
95  tdo.SetParams(tdoParams);
96 
97  tdo.AddProjection(Proj, col, 0.1, *scale, "", 1);
98  //const RGBAuc &colorSelection=RGBAuc_WHITE_OPAQUE, const double radius=0.1, const double scale=1.0
99  }
100 
101  tdo.VRMLOut(*outputName);
102  cout<<"finished\n";
103 
104 
105  return 0;
106 }
int VRMLOut(const std::string &sFilename)
flush all 3d objects to a vrml file with name sFilename, this is the function most users would call ...
Definition: ThreeDOut.cpp:3670
class RGBAuc is asynonym for a Vector4 of corerct type
Unified output of 3D entities via OpenGL or VRML.
Definition: ThreeDOut.hh:349
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:305
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:351
configuration struct for drawing styles of various 3d objects
Definition: ThreeDOut.hh:309
void SetParams(const ThreeDOutParameters &params)
Definition: ThreeDOut.cpp:209
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
CameraDrawingStyle CameraStyle
Definition: ThreeDOut.hh:313
unsigned int AddProjection(const Projection &p, const RGBAuc &colorSelection=RGBAuc_WHITE_OPAQUE, const double radius=0.1, const double scale=1.0, const std::string &identifier="", const int camera_type=-1)
Add a projection object to ThreeDOut mem.
Definition: ThreeDOut.cpp:1308
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
Definition: Param.cpp:176
This class hides the underlying projection model, like projection matrix, spherical camera...
Definition: Projection.hh:70
BIAS::Vector< double > * AddParamVecDbl(const std::string &name, const std::string &help, const BIAS::Vector< double > &deflt, char cmdshort=0, int Group=GRP_NOSHOW)
Add a parameter that expects a string on command line like &quot;&lt;value0&gt; &lt;value1&gt; &lt;value2&gt; ...
Definition: Param.cpp:378
This class Param provides generic support for parameters.
Definition: Param.hh:231
const BIAS::Projection & GetProj() const
Definition: Camera.hh:109
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:327
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...
Definition: Camera.cpp:154