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

load 3x4 matrix from Boujou .ban file. And this example demonstrates Dart usage: how to generate a runtime test by comparing against reference values and submit results to Dart server dashboard.

,Vector

Author
Jan Woetzel
/* 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 ExampleLoadBan.cpp
@relates Matrix3x4,Vector
@brief load 3x4 matrix from Boujou .ban file.
And this example demonstrates Dart usage: how to generate a runtime test by comparing against reference values and submit results to Dart server dashboard.
@ingroup g_examples
@author Jan Woetzel
*/
//#include <Base/Common/LeakChecking.h>
#include <Base/Common/BIASpragma.hh>
// STD
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
// BIAS
#include <bias_config.h>
#include <Base/Math/Matrix3x4.hh>
#include <Base/Math/Vector.hh>
using namespace std;
using namespace BIAS;
int main(int argc, char* argv[] )
{
int result=0;
BIASASSERT(argc>0);
cout<<"Starting "<<argv[0]<<endl;
#ifdef BIAS_TESTS_DATA
//string filename="calib01.ban";
//string filename(BIAS_TESTS_DATA "calib01.ban");
string filename;
filename = string(BIAS_TESTS_DATA);
filename += "calib01.ban";
#else
string filename;
cout<<"BIAS_TESTS_DATA not defined."<<endl;
return -1;
#endif
//
// first test: load Time=2 Matrix from ban file:
//
// load one 3x4 matrix from .ban file containing multiple P's
cout<<"trying to load "<<filename<<endl;
result = A .LoadBan(filename, 2);
if (result==0){
cout<<"successfully loaded "<<filename<<endl
<<"A: "<<A<<endl;
} else {
cout<<"Error. couls not load "<<filename<<endl;
result = -2000;
return result;
};
//
// second test: are the values correct?
//
const double v[12] = {
405.1, -0.0678595, -96.8174, 3800.26,
-2.10686, -202.721, -68.4048, 3483.67,
-0.00379941, 0.00217521, -0.171449, 7.94237 };
cout<<"DBG reference v is: "<<endl;
for (unsigned int i=0; i<12;i++) cout<<v[i]<<" ";
cout<<endl;
const double eps=1E-10; // desired precision
for (unsigned int i=0; i<12; i++) {
if (fabs(v[i] - A.GetData()[i]) >eps){
cout<<"Error: mismatch for element "<<i<<" : "<<endl
<<"should be: "<<v[i]
<<"but read : "<<A.GetData()[i]
<<endl;
result += -1*i;
}
}
//
// third test: this should fail because only 0,1,2 are inside the file
//
int errCode = A.LoadBan(filename, 3);
if (errCode == 0){
cout<<"Error: acces to Time 3 should return error but didn't."<<endl;
result += -100;
};
cout<<"done with result = "<<result<<endl;
return result;
}