mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-17 15:26:00 +08:00
Remove dependence on optim module
With all functionality preserved. Pure renaming.
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
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
|
||||
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm{
|
||||
class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm
|
||||
{
|
||||
public:
|
||||
struct CV_EXPORTS Params
|
||||
{
|
||||
@@ -819,8 +820,8 @@ protected:
|
||||
bool samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample );
|
||||
private:
|
||||
Params params;
|
||||
Ptr<optim::Solver> _solver;
|
||||
Ptr<optim::Solver::Function> _function;
|
||||
Ptr<MinProblemSolver> _solver;
|
||||
Ptr<MinProblemSolver::Function> _function;
|
||||
};
|
||||
|
||||
/************************************ Specific TrackerFeature Classes ************************************/
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <climits>
|
||||
|
||||
const int CMDLINEMAX = 30;
|
||||
const int ASSESS_TILL = 100;
|
||||
const int ASSESS_TILL = INT_MAX;
|
||||
const int LINEMAX = 40;
|
||||
|
||||
using namespace std;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "opencv2/optim.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
@@ -8,9 +8,9 @@
|
||||
namespace cv{
|
||||
|
||||
//!particle filtering class
|
||||
class PFSolver : public optim::Solver{
|
||||
class PFSolver : public MinProblemSolver{
|
||||
public:
|
||||
class Function : public optim::Solver::Function
|
||||
class Function : public MinProblemSolver::Function
|
||||
{
|
||||
public:
|
||||
//!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{
|
||||
void getParamsSTD(OutputArray std)const;
|
||||
void setParamsSTD(InputArray std);
|
||||
|
||||
Ptr<optim::Solver::Function> getFunction() const;
|
||||
void setFunction(const Ptr<Solver::Function>& f);
|
||||
Ptr<MinProblemSolver::Function> getFunction() const;
|
||||
void setFunction(const Ptr<MinProblemSolver::Function>& f);
|
||||
TermCriteria getTermCriteria() const;
|
||||
void setTermCriteria(const TermCriteria& termcrit);
|
||||
private:
|
||||
Mat_<double> _std,_particles,_logweight;
|
||||
Ptr<Solver::Function> _Function;
|
||||
Ptr<MinProblemSolver::Function> _Function;
|
||||
PFSolver::Function* _real_function;
|
||||
TermCriteria _termcrit;
|
||||
int _maxItNum,_iter,_particlesNum;
|
||||
@@ -46,11 +46,11 @@ namespace cv{
|
||||
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);
|
||||
|
||||
PFSolver::PFSolver(){
|
||||
_Function=Ptr<Solver::Function>();
|
||||
_Function=Ptr<MinProblemSolver::Function>();
|
||||
_real_function=NULL;
|
||||
_std=Mat_<double>();
|
||||
rng=RNG(getTickCount());
|
||||
@@ -154,14 +154,14 @@ namespace cv{
|
||||
double PFSolver::getAlpha(){
|
||||
return _alpha;
|
||||
}
|
||||
Ptr<optim::Solver::Function> PFSolver::getFunction() const{
|
||||
Ptr<MinProblemSolver::Function> PFSolver::getFunction() const{
|
||||
return _Function;
|
||||
}
|
||||
void PFSolver::setFunction(const Ptr<optim::Solver::Function>& f){
|
||||
void PFSolver::setFunction(const Ptr<MinProblemSolver::Function>& f){
|
||||
CV_Assert(f.empty()==false);
|
||||
|
||||
Ptr<Solver::Function> non_const_f(f);
|
||||
Solver::Function* f_ptr=static_cast<Solver::Function*>(non_const_f);
|
||||
Ptr<MinProblemSolver::Function> non_const_f(f);
|
||||
MinProblemSolver::Function* f_ptr=static_cast<MinProblemSolver::Function*>(non_const_f);
|
||||
|
||||
PFSolver::Function *pff=dynamic_cast<PFSolver::Function*>(f_ptr);
|
||||
CV_Assert(pff!=NULL);
|
||||
@@ -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());
|
||||
|
||||
if(f.empty()==false){
|
||||
|
@@ -397,11 +397,11 @@ bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::ve
|
||||
Ptr<TrackerTargetState> ptr;
|
||||
Mat_<double> _last_guess=(Mat_<double>(1,4)<<(double)boundingBox.x,(double)boundingBox.y,
|
||||
(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->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);
|
||||
promoted_solver->getOptParam(_last_guess);
|
||||
|
||||
|
Reference in New Issue
Block a user