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

small example demonstrating the ProjectionParametersProjective

Author
sedlazeck 8/2009
/*
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 ExampleProjectionParametersProjective.cpp
@relates ProjectionParametersProjective
@brief small example demonstrating the ProjectionParametersProjective
@ingroup g_examples
@author sedlazeck 8/2009
*/
#include <Geometry/ProjectionParametersProjective.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
R.SetXYZ(30.0 / 180.0 * M_PI, 10.0 / 180.0 * M_PI, 20.0 / 180.0 * M_PI);
C[0] = 0.0;
C[1] = 0.0;
C[2] = 0.0;
P.Compose(K, R, C);
cout << "using P Matrix " << P << endl;
ppp.SetP(P);
ppp.SetImageSize(400, 600);
cout << "retrieving C " << ppp.GetC() << endl;
cout << "ostream after setting from P : ppp " << ppp << endl;
#ifdef BIAS_HAVE_XML2
string fname = "ProjParProjExample01.xml";
int res = ppp.XMLWrite(fname);
res = ppp.XMLRead(fname);
if (res!=0)
{
cerr << "error reading "<< fname << endl;
return -3;
}
#endif
cout << "ostream after xml read ppp " << ppp << endl;
// testing copy constructor
cout << "copy constructor " << pppc << endl;
// project and unproject
HomgPoint3D point3D(3, 4, 0, 1);
HomgPoint2D point2D = ppp.Project(point3D);
HomgPoint3D point3DNew = HomgPoint3D(ppp.UnProjectToPoint(point2D, 5));
point3DNew.Homogenize();
cout << "orig 3D point " << point3D << " project/unproject " << point3DNew << endl;
// testing project with P and Project method
HomgPoint3D point3D1(1.5, -2.3, 4.34, 1.0);
HomgPoint2D point2D1 = ppp.Project(point3D1);
point2D1.Homogenize();
cout << "point2D by Project method " << point2D1 << endl;
point2D1 = ppp.GetP() * point3D1;
point2D1.Homogenize();
cout << "point2D by P projection " << point2D1 << endl;
return 0;
}