Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

since your Solver takes a Ptr<Function> as argument, this is, what you should provide.

your 1st version, providing the addess of a (stack created) Function crashes, because the internal cv::Ptr will try to release it, and call delete on something, that was not created with new .

so please try like this:

void Fitting()
{
Ptr<TorusFunction> ptr = makePtr<TorusFunction>();
Ptr<MinProblemSolver::Function> ptr_F = Ptr<MinProblemSolver::Function>(ptr);
Ptr<ConjGradSolver> TorusFitting = ConjGradSolver::create();
TorusFitting->setFunction(ptr_F);
}

since your Solver takes a Ptr<Function> as argument, this is, what you should provide.

your 1st version, providing the addess of a (stack created) Function crashes, because the internal cv::Ptr will try to release it, and call delete on something, that was not created with new .

so please try like this:

void Fitting()
{
Ptr<TorusFunction> Ptr<MinProblemSolver::Function> ptr = makePtr<TorusFunction>();
Ptr<MinProblemSolver::Function> ptr_F = Ptr<MinProblemSolver::Function>(ptr);
Ptr<ConjGradSolver> TorusFitting = ConjGradSolver::create();
TorusFitting->setFunction(ptr_F);
TorusFitting->setFunction(ptr);
}