本文整理汇总了C++中ParticleSet::calc_distWeights_particles2detection方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSet::calc_distWeights_particles2detection方法的具体用法?C++ ParticleSet::calc_distWeights_particles2detection怎么用?C++ ParticleSet::calc_distWeights_particles2detection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSet
的用法示例。
在下文中一共展示了ParticleSet::calc_distWeights_particles2detection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv){
/////////////////////
int totalFrames = 32;
///////////////////////////////////
bool shouldImShow_Detecions = true;
bool shouldImShow_Particles = true;
/////////////////////////////////////////////
std::string stringBasePATH = "images/";
std::string stringExtension = ".png";
/////////////////////////////////////////////
std::cout << std::endl << std::endl;
ParticleSet particleSet;
//////////////////////////////
particleSet.FrameRangeX = 720;
particleSet.FrameRangeY = 480;
//////////////////////////////
for (int iii=0; iii<totalFrames; iii++)
{
// Read Current Frame
std::ostringstream stringStream;
stringStream << stringBasePATH << iii+1 << stringExtension;
cv::Mat currFrame = cv::imread( stringStream.str() );
std::cout << stringStream.str () << std::endl;
if (currFrame.empty()){
std::cout << std::endl << std::endl << "main - Empty Image - Not read from disk" << std::endl << std::endl;
}
// If first Frame, then create particle set around manual initialization
if (iii==0)
{
std::cout << "frame " << iii+1 << " / " << totalFrames << " \t" << "Detection Manually Annotated" << std::endl;
particleSet.detection.initializeManually(currFrame, 448,191, 38,33);
particleSet.detection.weight = -888; // reset to 'default' dummy value
cv::imwrite("nemoInitial.png",particleSet.detection.roi);
particleSet.createSet( 100 ); // number of particles (this number will be constant - resampling with substitution is used)
/////////
continue;
/////////
}
particleSet.resampling_andReplaceParticles(); // resample (preparations done at previous iteration)
particleSet.find_ROIs_forParticles( currFrame );
particleSet.calc_hist_forParticles();
particleSet.calc_distWeights_particles2detection(); // max Weight is BeSt
// find best particle // TODO-average
particleSet.calcNormalizedWeights();
particleSet.calculateMaxWeight();
//particleSet.findDetection_BestParticle(); // uncomment this line and comment the next one, if you want to try just the strongest particle
particleSet.findAverageParticle();
particleSet.arrangeWeightsInCircle(); // preparation for resampling
// Visualization & Write to disk
// Tracked state @ current frame
std::ostringstream stringStreamSHOW;
stringStreamSHOW << "DETECTION_" << iii+1 << ".png";
cv::Mat currFrameSHOW = currFrame.clone();
particleSet.detection.show_onFrame( currFrameSHOW, shouldImShow_Detecions );
#if 0
cv::imwrite( stringStreamSHOW.str(),currFrameSHOW );
#endif
// Visualization & Write to disk
// Tracked state @ current frame and all particles
cv::Mat currFrameSHOW2 = currFrame.clone();
std::ostringstream stringStreamSHOW2;
stringStreamSHOW2 << "PARTICLES_" << iii+1 << ".png";
particleSet.show_ROIs_forParticles_onFrame( currFrameSHOW2, shouldImShow_Particles );
#if 0
cv::imwrite( stringStreamSHOW2.str(), currFrameSHOW2 );
#endif
std::cout << "frame " << iii+1 << " / " << totalFrames << " \t" << "BestFit = " << particleSet.maxWeight_BestFit << "\t particle ID = " << particleSet.maxWeight_BestFit_ParticleID << std::endl;
if (shouldImShow_Detecions || shouldImShow_Particles) cv::waitKey();
}
std::cout << std::endl << std::endl;
cv::waitKey();
}