Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How to use Opencv 3 particle filter api

$
0
0
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 #include #include #include #include #include using namespace std ; using namespace cv ; ... ... Mat src ; // video frame Rect boundingBox ; // boundingBox the target Rect Mat roi = Mat(src ,boundingBox) ; vector sampleImg ; Ptr PFSampler = new TrackerSamplerPF( roi, TrackerSamplerPF::Params() ) ; Ptr 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& sample ){ Ptr ptr; Mat_ _last_guess=(Mat_(1,4)<<(double)boundingBox.x,(double)boundingBox.y, (double)boundingBox.x+boundingBox.width,(double)boundingBox.y+boundingBox.height); PFSolver* promoted_solver=dynamic_cast(static_cast(_solver)); promoted_solver->setParamsSTD(params.std); promoted_solver->minimize(_last_guess); dynamic_cast(static_cast(promoted_solver->getFunction()))->update(image); while(promoted_solver->iteration() <= promoted_solver->getTermCriteria().maxCount); promoted_solver->getOptParam(_last_guess); Rect res=Rect(Point_((int)_last_guess(0,0),(int)_last_guess(0,1)),Point_((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) sampleImg, however it looked like an output data.. Does anyone try this method successful ?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>