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

Example computing H matrix

Author
woelk 05/2008 www.vision-n.de
/* 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 ExampleHMatrixEstimation.cpp
@relates HMatrixExtimation
@brief Example computing H matrix
@ingroup g_examples
@author woelk 05/2008 www.vision-n.de
*/
#include <Geometry/HMatrixEstimation.hh>
#include <vector>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
const int num_points=4;
vector<HomgPoint2D> frompoints(4), topoints(4);
const int num_fields = 22;
frompoints[0].Set(0.0, 0.0, 1.0);
frompoints[1].Set((double)(num_fields), 0.0, 1.0);
frompoints[2].Set((double)(num_fields), (double)(num_fields), 1.0);
frompoints[3].Set(0.0, (double)(num_fields), 1.0);
topoints[0].Set(521.8942308, 64.35576923, 1.);
topoints[1].Set(527., 280., 1.);
topoints[2].Set(310.96, 282.0, 1.);
topoints[3].Set(309., 62., 1.);
int res = Hest.Compute(frompoints, topoints, H);
if (res!=0) {
BIASERR("error computing H: "<<res);
return res;
} else {
HomgPoint2D hfrom;
for (int i=0; i<num_points; i++){
hfrom = H * frompoints[i];
BIASASSERT(!hfrom.IsAtInfinity());
hfrom.Homogenize();
cout << " from = "<<frompoints[i]
<< "\nH * from = "<<hfrom
<< "\n to = "<<topoints[i]<<"\n--------\n";
}
}
return 0;
}