Downhill Solver -- error due to pure virtual functions
I'm familiarizing with Optimization Algorithm in OpenCV. I've found an interesting example to start with:
http://answers.opencv.org/question/33...
so, I developed some code based on that:
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace cv;
using namespace std;
class DistanceToLines :public MinProblemSolver::Function
{
public:
double calc(const double* x)const
{
return x[0] * x[0] + x[1] * x[1];
}
};
int main()
{
Ptr<DownhillSolver> DHS = DownhillSolver::create();
// Ptr<MinProblemSolver::Function> ptr_F = makePtr<DistanceToLines>(); // NOT WORKING!!!
Ptr<MinProblemSolver::Function> ptr_F(new DistanceToLines()); // NOT WORKING!!!
return 0;
}
It gives me the following error, when building:
D:\ALGORITMI\minDownhill\main.cpp:50: error: invalid new-expression of abstract class type 'DistanceToLines'
Ptr<MinProblemSolver::Function> ptr_F(new DistanceToLines());
D:\ALGORITMI\minDownhill\main.cpp:33: note: because the following virtual functions are pure within 'DistanceToLines':
class DistanceToLines :public MinProblemSolver::Function
any hint? I saw that there are not many examples on the web about these methods, so I cannot figure out what is happening.