Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleCalcRelativeTransform.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 /**
26  @example ExampleCalcRelativeTransform.cpp
27  @relates CoordinateTransform3D
28  @brief Example for calculation of the relative transform between 2 transforms
29  @ingroup g_examples
30  @author MIP
31 */
32 
33 #include <Geometry/CoordinateTransform3D.hh>
34 #include <Geometry/Projection.hh>
35 #include <Utils/Param.hh>
36 #include <iostream>
37 
38 using namespace std;
39 using namespace BIAS;
40 
41 void commandHelp(char* argv) {
42  cout<<argv<<" [options] <projection A > <projection B>\n";
43 }
44 
45 
46 int main(int argc, char* argv[])
47 {
48  Param params(true);
49 
50  bool* help = params.AddParamBool("help", "", false, 'h');
51 
52  int fup = params.ParseCommandLine(argc, argv);
53 
54  if(*help || argc<3) {
55  commandHelp(argv[0]);
56  params.Usage();
57  return 0;
58  }
59 
60  Projection A, B;
61  if(A.Load(argv[fup])!=0) {
62  cerr<<"error loading projection A\n";
63  commandHelp(argv[0]);
64  params.Usage();
65  return -1;
66  }
67  if(B.Load(argv[fup+1])!=0) {
68  cerr<<"error loading projection B\n";
69  commandHelp(argv[0]);
70  params.Usage();
71  return -1;
72  }
73 
74  Pose poseA, poseB, result, check;
75  poseA = A.GetPose();
76  poseB = B.GetPose();
77 
78  cout<<" PoseA = ";
79  poseA.Talk();
80 
81  cout<<" PoseB = ";
82  poseB.Talk();
83 
84  cout<<"calculating relative transformations between A and B:\n\n";
85  cout<<"making A global: A*result = B :\n";
86  result.BecomeRelativeTransform(poseB, poseA);
87  result.Talk();
88  cout<<endl;
89 // cout<<"check should be B : ";
90 // poseA.ConcatenateLocalTransform(result, check);
91 // check.Talk();
92 // cout<<endl;
93 
94  cout<<"making B global: B*result = A :\n";
95  result.BecomeRelativeTransform(poseA, poseB);
96  result.Talk();
97  cout<<endl;
98 // cout<<"check should be A : ";
99 // poseB.ConcatenateLocalTransform(result, check);
100 // check.Talk();
101 // cout<<endl;
102 
103 
104  return 0;
105 }
void BecomeRelativeTransform(const CoordinateTransform3D &newLocal, const CoordinateTransform3D &newGlobal)
Changes this coordinate transformation so that parameter newLocal becomes the local coordinate frame ...
virtual int Load(const std::string &filename)
convenience wrapper which tries to read different formats
Definition: Projection.cpp:62
virtual const Pose & GetPose(unsigned int cam=0) const
return complete pose object.
Definition: Projection.hh:318
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:305
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
Definition: Param.cpp:176
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
This class hides the underlying projection model, like projection matrix, spherical camera...
Definition: Projection.hh:70
void Talk() const
Prints this transformation with more intuitive rotation representation.
This class Param provides generic support for parameters.
Definition: Param.hh:231