Commit e67b9e9e authored by Alex Leontiev's avatar Alex Leontiev

Remove dependence on optim module

With all functionality preserved. Pure renaming.
parent eee3e052
set(the_description "Tracking API") set(the_description "Tracking API")
ocv_define_module(tracking opencv_imgproc opencv_optim opencv_video opencv_highgui) ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui)
...@@ -804,7 +804,8 @@ class CV_EXPORTS_W TrackerSamplerCS : public TrackerSamplerAlgorithm ...@@ -804,7 +804,8 @@ class CV_EXPORTS_W TrackerSamplerCS : public TrackerSamplerAlgorithm
}; };
class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm{ class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm
{
public: public:
struct CV_EXPORTS Params struct CV_EXPORTS Params
{ {
...@@ -819,8 +820,8 @@ protected: ...@@ -819,8 +820,8 @@ protected:
bool samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ); bool samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample );
private: private:
Params params; Params params;
Ptr<optim::Solver> _solver; Ptr<MinProblemSolver> _solver;
Ptr<optim::Solver::Function> _function; Ptr<MinProblemSolver::Function> _function;
}; };
/************************************ Specific TrackerFeature Classes ************************************/ /************************************ Specific TrackerFeature Classes ************************************/
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <climits> #include <climits>
const int CMDLINEMAX = 30; const int CMDLINEMAX = 30;
const int ASSESS_TILL = 100; const int ASSESS_TILL = INT_MAX;
const int LINEMAX = 40; const int LINEMAX = 40;
using namespace std; using namespace std;
......
#include "opencv2/optim.hpp" #include "opencv2/core.hpp"
#include "opencv2/core/core_c.h" #include "opencv2/core/core_c.h"
#include <algorithm> #include <algorithm>
#include <typeinfo> #include <typeinfo>
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
namespace cv{ namespace cv{
//!particle filtering class //!particle filtering class
class PFSolver : public optim::Solver{ class PFSolver : public MinProblemSolver{
public: public:
class Function : public optim::Solver::Function class Function : public MinProblemSolver::Function
{ {
public: public:
//!if parameters have no sense due to some reason (e.g. lie outside of function domain), this function "corrects" them, //!if parameters have no sense due to some reason (e.g. lie outside of function domain), this function "corrects" them,
...@@ -31,13 +31,13 @@ namespace cv{ ...@@ -31,13 +31,13 @@ namespace cv{
void getParamsSTD(OutputArray std)const; void getParamsSTD(OutputArray std)const;
void setParamsSTD(InputArray std); void setParamsSTD(InputArray std);
Ptr<optim::Solver::Function> getFunction() const; Ptr<MinProblemSolver::Function> getFunction() const;
void setFunction(const Ptr<Solver::Function>& f); void setFunction(const Ptr<MinProblemSolver::Function>& f);
TermCriteria getTermCriteria() const; TermCriteria getTermCriteria() const;
void setTermCriteria(const TermCriteria& termcrit); void setTermCriteria(const TermCriteria& termcrit);
private: private:
Mat_<double> _std,_particles,_logweight; Mat_<double> _std,_particles,_logweight;
Ptr<Solver::Function> _Function; Ptr<MinProblemSolver::Function> _Function;
PFSolver::Function* _real_function; PFSolver::Function* _real_function;
TermCriteria _termcrit; TermCriteria _termcrit;
int _maxItNum,_iter,_particlesNum; int _maxItNum,_iter,_particlesNum;
...@@ -46,11 +46,11 @@ namespace cv{ ...@@ -46,11 +46,11 @@ namespace cv{
RNG rng; RNG rng;
}; };
CV_EXPORTS_W Ptr<PFSolver> createPFSolver(const Ptr<optim::Solver::Function>& f=Ptr<optim::Solver::Function>(),InputArray std=Mat(), CV_EXPORTS_W Ptr<PFSolver> createPFSolver(const Ptr<MinProblemSolver::Function>& f=Ptr<MinProblemSolver::Function>(),InputArray std=Mat(),
TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER,5,0.0),int particlesNum=100,double alpha=0.6); TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER,5,0.0),int particlesNum=100,double alpha=0.6);
PFSolver::PFSolver(){ PFSolver::PFSolver(){
_Function=Ptr<Solver::Function>(); _Function=Ptr<MinProblemSolver::Function>();
_real_function=NULL; _real_function=NULL;
_std=Mat_<double>(); _std=Mat_<double>();
rng=RNG(getTickCount()); rng=RNG(getTickCount());
...@@ -154,14 +154,14 @@ namespace cv{ ...@@ -154,14 +154,14 @@ namespace cv{
double PFSolver::getAlpha(){ double PFSolver::getAlpha(){
return _alpha; return _alpha;
} }
Ptr<optim::Solver::Function> PFSolver::getFunction() const{ Ptr<MinProblemSolver::Function> PFSolver::getFunction() const{
return _Function; return _Function;
} }
void PFSolver::setFunction(const Ptr<optim::Solver::Function>& f){ void PFSolver::setFunction(const Ptr<MinProblemSolver::Function>& f){
CV_Assert(f.empty()==false); CV_Assert(f.empty()==false);
Ptr<Solver::Function> non_const_f(f); Ptr<MinProblemSolver::Function> non_const_f(f);
Solver::Function* f_ptr=static_cast<Solver::Function*>(non_const_f); MinProblemSolver::Function* f_ptr=static_cast<MinProblemSolver::Function*>(non_const_f);
PFSolver::Function *pff=dynamic_cast<PFSolver::Function*>(f_ptr); PFSolver::Function *pff=dynamic_cast<PFSolver::Function*>(f_ptr);
CV_Assert(pff!=NULL); CV_Assert(pff!=NULL);
...@@ -194,7 +194,7 @@ namespace cv{ ...@@ -194,7 +194,7 @@ namespace cv{
} }
} }
Ptr<PFSolver> createPFSolver(const Ptr<optim::Solver::Function>& f,InputArray std,TermCriteria termcrit,int particlesNum,double alpha){ Ptr<PFSolver> createPFSolver(const Ptr<MinProblemSolver::Function>& f,InputArray std,TermCriteria termcrit,int particlesNum,double alpha){
Ptr<PFSolver> ptr(new PFSolver()); Ptr<PFSolver> ptr(new PFSolver());
if(f.empty()==false){ if(f.empty()==false){
......
...@@ -397,11 +397,11 @@ bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::ve ...@@ -397,11 +397,11 @@ bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::ve
Ptr<TrackerTargetState> ptr; Ptr<TrackerTargetState> ptr;
Mat_<double> _last_guess=(Mat_<double>(1,4)<<(double)boundingBox.x,(double)boundingBox.y, Mat_<double> _last_guess=(Mat_<double>(1,4)<<(double)boundingBox.x,(double)boundingBox.y,
(double)boundingBox.x+boundingBox.width,(double)boundingBox.y+boundingBox.height); (double)boundingBox.x+boundingBox.width,(double)boundingBox.y+boundingBox.height);
PFSolver* promoted_solver=dynamic_cast<PFSolver*>(static_cast<optim::Solver*>(_solver)); PFSolver* promoted_solver=dynamic_cast<PFSolver*>(static_cast<MinProblemSolver*>(_solver));
promoted_solver->setParamsSTD(params.std); promoted_solver->setParamsSTD(params.std);
promoted_solver->minimize(_last_guess); promoted_solver->minimize(_last_guess);
dynamic_cast<TrackingFunctionPF*>(static_cast<optim::Solver::Function*>(promoted_solver->getFunction()))->update(image); dynamic_cast<TrackingFunctionPF*>(static_cast<MinProblemSolver::Function*>(promoted_solver->getFunction()))->update(image);
while(promoted_solver->iteration() <= promoted_solver->getTermCriteria().maxCount); while(promoted_solver->iteration() <= promoted_solver->getTermCriteria().maxCount);
promoted_solver->getOptParam(_last_guess); promoted_solver->getOptParam(_last_guess);
......
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