Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Anyone tried this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Anyone tried Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The opencv source from trackerSamplerAlgorithm.cpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something is empty but I tracked the function work found this :

The opencv source from trackerSamplerAlgorithm.cpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found this :

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found this :these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?

How to use Opencv 3 particle filter api

I have built the opencv_contirb for opencv 3.1, and I got the tracking module.

The document :

http://docs.opencv.org/trunk/dc/d75/classcv_1_1TrackerSamplerAlgorithm.html#gsc.tab=0

The 3.0 doc also introduce the method :

http://docs.opencv.org/3.0-beta/modules/tracking/doc/common_interfaces_tracker_sampler.html

I've tried the TrackerSampler::addTrackerSamplerAlgorithm and rewrote to the particle filter version myself below:

#include <opencv2\core.hpp>
#include <opencv2\video.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\tracking.hpp>
#include <opencv2\tracking\tracker.hpp>
#include <opencv2\tracking\feature.hpp>

using namespace std ;
using namespace cv ;
...
...
Mat src ; // video frame
Rect boundingBox ; // boundingBox the target Rect
Mat roi = Mat(src ,boundingBox) ;
vector<Mat> sampleImg ;
Ptr<TrackerSamplerAlgorithm> PFSampler  = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ;
Ptr<TrackerSampler> sampler = new TrackerSampler() ;

if( sampler->addTrackerSamplerAlgorithm( PFSampler ) ) {
  cout << PFSampler->getClassName() << endl ; // check the 'pf' mode ;
  PFSampler->sampling( src, boundingBox, sampleImg ) ;  // <---------- it occured error here
} // if

The error seemed something empty but I tracked the function work found these:

The opencv source from trackerSamplerAlgorithm.cpp

PFSolver.hpp

TrackingFunctionPF.hpp

The error message:

OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat, file C:\OpenCV\source\modules\core\src\matrix.cpp, line 477

bool TrackerSamplerPF::samplingImpl( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ){
    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<MinProblemSolver*>(_solver));

    promoted_solver->setParamsSTD(params.std);
    promoted_solver->minimize(_last_guess);
    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);

    Rect res=Rect(Point_<int>((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_<int>((int)_last_guess(0,2),(int)_last_guess(0,3)));
    sample.clear();
    sample.push_back(image(res));
    return true;
}

The src and roi, boundingBox isnt empty or null ; The only empty input is the (vector<mat>) sampleImg, however it looked like an output data..

Does anyone try this method successful ?