Commit 61110402 authored by Laurent Belcour's avatar Laurent Belcour

Fixing an error in the export of the plugin name in fitter_quadproge now

this function is called correctly. But it doesn't work in fact.
parent 20671bd9
......@@ -113,6 +113,7 @@ fitter* plugins_manager::get_fitter() const
}
else
{
std::cout << "<<DEBUG>> using \"" << _fitters.begin()->first << "\"" << std::endl ;
return _fitters.begin()->second ;
}
}
......@@ -153,6 +154,7 @@ fitter* plugins_manager::get_fitter(const std::string& n) const
}
else
{
std::cout << "<<DEBUG>> using \"" << n << "\"" << std::endl ;
return _fitters.at(n) ;
}
}
......@@ -258,8 +258,15 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
for(int i=0; i<2*d->size(); ++i)
{
ci[i] = ci[i] * delta ;
#ifdef DEBUG
std::cout << ci[i] << "\t" ;
#endif
}
#ifdef DEBUG
std::cout << std::endl << std::endl ;
std::cout << eCI << std::endl << std::endl ;
#endif
// Compute the solution
QuadProgPP::Vector<double> x;
double cost = QuadProgPP::solve_quadprog(G, g, CE, ce, CI, ci, x);
......
......@@ -14,24 +14,24 @@
#include <QTime>
data* rational_fitter_quadprog::provide_data() const
data* rational_fitter_quadproge::provide_data() const
{
return new vertical_segment() ;
}
function* rational_fitter_quadprog::provide_function() const
function* rational_fitter_quadproge::provide_function() const
{
return new rational_function() ;
}
rational_fitter_quadprog::rational_fitter_quadprog() : QObject()
rational_fitter_quadproge::rational_fitter_quadproge() : QObject()
{
}
rational_fitter_quadprog::~rational_fitter_quadprog()
rational_fitter_quadproge::~rational_fitter_quadproge()
{
}
bool rational_fitter_quadprog::fit_data(const data* dat, function* fit)
bool rational_fitter_quadproge::fit_data(const data* dat, function* fit)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......@@ -86,7 +86,7 @@ bool rational_fitter_quadprog::fit_data(const data* dat, function* fit)
return false ;
}
void rational_fitter_quadprog::set_parameters(const arguments& args)
void rational_fitter_quadproge::set_parameters(const arguments& args)
{
_max_np = args.get_float("np", 10) ;
_max_nq = args.get_float("nq", 10) ;
......@@ -95,7 +95,7 @@ void rational_fitter_quadprog::set_parameters(const arguments& args)
}
bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int nq, rational_function* r)
bool rational_fitter_quadproge::fit_data(const vertical_segment* d, int np, int nq, rational_function* r)
{
// Multidimensional coefficients
......@@ -119,7 +119,7 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function return a ration BRDF function and a boolean
bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int nq, int ny, rational_function* rf)
bool rational_fitter_quadproge::fit_data(const vertical_segment* dat, int np, int nq, int ny, rational_function* rf)
{
rational_function* r = dynamic_cast<rational_function*>(rf) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......@@ -194,8 +194,8 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
const double pi = r->p(xi, j) ;
a0_norm += pi*pi ;
a1_norm += pi*pi ;
CI(i,j) = pi ;
CI(i+d->size(),j) = -pi ;
CI(j,i) = pi ;
CI(j,i+d->size()) = -pi ;
}
// Filling the q part
else
......@@ -205,22 +205,22 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
const double qi = r->q(xi, j-np) ;
a0_norm += qi*qi * (yl[ny]*yl[ny]) ;
CI(j, i) = -yl[ny] * qi ;
a1_norm += qi*qi * (yu[ny]*yu[ny]) ;
CI(j, i) = -yl[ny] * qi ;
CI(j, i+d->size()) = yu[ny] * qi ;
}
}
// Set the c vector, will later be updated using the
// delta parameter.
ci(i) = 0.0 ; // sqrt(a0_norm) ;
ci(i+d->size()) = 0.0 ; // sqrt(a1_norm) ;
ci(i) = -sqrt(a0_norm) ;
ci(i+d->size()) = -sqrt(a1_norm) ;
ce(i) = 0.0 ;
ce(i+d->size()) = 0.0 ;
CI.row(i) /= sqrt(a0_norm) ;
CI.row(i+d->size()) /= sqrt(a1_norm) ;
/*
CI.col(i) /= sqrt(a0_norm) ;
CI.col(i+d->size()) /= sqrt(a1_norm) ;
*/
}
#ifdef DEBUG
std::cout << "CI = [" ;
......@@ -271,10 +271,17 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
#endif
for(int i=0; i<2*d->size(); ++i)
{
// CI.row(i) /= ci(i) ;
ci(i) = -delta ;
ci(i) = ci(i) * delta;
// ci(i) = delta ;
}
#ifdef DEBUG
std::cout << G << std::endl << std::endl ;
std::cout << g << std::endl << std::endl ;
std::cout << CI << std::endl << std::endl ;
std::cout << ci << std::endl << std::endl ;
#endif
// Compute the solution
Eigen::VectorXd x(np+nq);
double cost = solve_quadprog(G, g, CE, ce, CI, ci, x);
......@@ -318,4 +325,4 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
}
}
Q_EXPORT_PLUGIN2(rational_fitter_quadprog, rational_fitter_quadprog)
Q_EXPORT_PLUGIN2(rational_fitter_quadproge, rational_fitter_quadproge)
......@@ -14,15 +14,15 @@
#include <core/vertical_segment.h>
class rational_fitter_quadprog : public QObject, public fitter
class rational_fitter_quadproge : public QObject, public fitter
{
Q_OBJECT
Q_INTERFACES(fitter)
public: // methods
rational_fitter_quadprog() ;
virtual ~rational_fitter_quadprog() ;
rational_fitter_quadproge() ;
virtual ~rational_fitter_quadproge() ;
// Fitting a data object
//
......
......@@ -24,93 +24,12 @@ int main(int argc, char** argv)
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
#ifdef OLD
std::vector<function*> functions ;
std::vector<data*> datas ;
std::vector<fitter*> fitters ;
QDir pluginsDir = QDir(app.applicationDirPath());
if(args.is_defined("plugins"))
{
pluginsDir = QDir(args["plugins"].c_str()) ;
}
std::vector<QString> plugins ;
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
{
QPluginLoader loader ;
loader.setLoadHints(QLibrary::ExportExternalSymbolsHint) ;
loader.setFileName(pluginsDir.absoluteFilePath(fileName));
if(!loader.load())
{
#ifdef DEBUG
std::cout << "<<DEBUG>> " << loader.errorString().toStdString() << std::endl ;
#endif
continue ;
}
QObject *plugin = loader.instance();
if (plugin != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> loading plugin " << fileName.toStdString() << std::endl ;
#endif
/*
if(dynamic_cast<function*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a function" << std::endl ;
#endif
functions.push_back(dynamic_cast<function*>(plugin)) ;
}
if(dynamic_cast<data*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a data loader" << std::endl ;
#endif
datas.push_back(dynamic_cast<data*>(plugin)) ;
}
*/
if(dynamic_cast<fitter*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a fitter" << std::endl ;
#endif
if(args.is_defined("fitter") && loader.fileName().toStdString().find(args["fitter"]) == std::string::npos)
{
continue ;
}
std::cout << "<<INFO>> using " << loader.fileName().toStdString() << std::endl ;
fitter *f = dynamic_cast<fitter*>(plugin) ;
fitters.push_back(f) ;
datas.push_back(f->provide_data()) ;
functions.push_back(f->provide_function()) ;
}
}
else
{
#ifdef DEBUG
std::cout << "<<DEBUG>> " << loader.errorString().toStdString() << std::endl ;
#endif
plugins.push_back(fileName) ;
}
}
fitter* fit = fitters[0] ;
#else
plugins_manager manager(args) ;
fitter* fit = manager.get_fitter(args["fitter"]) ;
if(fit == NULL)
{
fit = manager.get_fitter() ;
}
#endif
if(! args.is_defined("input")) {
std::cerr << "<<ERROR>> the input filename is not defined" << std::endl ;
......@@ -124,10 +43,6 @@ int main(int argc, char** argv)
// if(fitters.size() > 0 && datas.size() > 0 && functions.size() > 0)
{
fit->set_parameters(args) ;
/*
function* f = functions[0] ;
data* d = datas[0] ;
*/
function* f = NULL;
if(args.is_defined("func"))
{
......@@ -164,7 +79,7 @@ int main(int argc, char** argv)
/*/
f->save(args["output"], args) ;
#ifdef OLD // use brdf2gnuplot
size_t n = args["output"].find('.') ;
std::string gnuplot_filename = args["output"].substr(0,n);
gnuplot_filename.append(".gnuplot") ;
......@@ -207,6 +122,7 @@ int main(int argc, char** argv)
efile << std::endl ;
}
//*/
#endif
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment