#include "test_precomp.hpp" #include static void mytest(cv::Ptr solver,cv::Ptr ptr_F,cv::Mat& x, cv::Mat& etalon_x,double etalon_res){ solver->setFunction(ptr_F); //int ndim=MAX(step.cols,step.rows); double res=solver->minimize(x); std::cout<<"res:\n\t"<getTermCriteria().epsilon; ASSERT_TRUE(std::abs(res-etalon_res)::iterator it1=x.begin(),it2=etalon_x.begin();it1!=x.end();it1++,it2++){ ASSERT_TRUE(std::abs((*it1)-(*it2)) solver=cv::optim::createConjGradSolver(); #if 1 { cv::Ptr ptr_F(new SphereF()); cv::Mat x=(cv::Mat_(4,1)<<50.0,10.0,1.0,-10.0), etalon_x=(cv::Mat_(1,4)<<0.0,0.0,0.0,0.0); double etalon_res=0.0; mytest(solver,ptr_F,x,etalon_x,etalon_res); } #endif #if 1 { cv::Ptr ptr_F(new RosenbrockF()); cv::Mat x=(cv::Mat_(2,1)<<0.0,0.0), etalon_x=(cv::Mat_(2,1)<<1.0,1.0); double etalon_res=0.0; mytest(solver,ptr_F,x,etalon_x,etalon_res); } #endif }