diff --git a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h index 76404b2b055ba058b118c3e65094c9926a6a76a4..0f4eeaea005ac8b40aa5a717f4157a07ea313742 100644 --- a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h +++ b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.h @@ -96,6 +96,10 @@ public: itkGetConstMacro(InhibitionRadius, double); itkSetMacro(InhibitionRadius, double); + /** The maximum iteration number during negative sample positions */ + itkGetConstMacro(NbMaxIteration, unsigned long int); + itkSetMacro(NbMaxIteration, unsigned long int); + /** Set the seed for random number generator */ void SetSeed(unsigned int seed) { @@ -122,6 +126,7 @@ private: int m_NoClassIdentifier; double m_RandomLocalizationDensity; double m_InhibitionRadius; + unsigned long int m_NbMaxIteration; }; } // end namespace otb diff --git a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx index 8b31036d6fc8f4822475a857eada6db8091a9cd7..cfa68e0eeb8706699317ef5b397cfcf0a1d81e2e 100644 --- a/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx +++ b/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.txx @@ -29,8 +29,9 @@ LabeledSampleLocalizationGenerator<TVectorData> ::LabeledSampleLocalizationGenerator() : m_ClassKey("Class"), m_NoClassIdentifier(0), - m_RandomLocalizationDensity(.05), - m_InhibitionRadius(5.0) + m_RandomLocalizationDensity(.005), + m_InhibitionRadius(5.0), + m_NbMaxIteration(10000) { this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); @@ -114,16 +115,17 @@ LabeledSampleLocalizationGenerator<TVectorData> //std::cout << "insiders: " << insiders.size() << std::endl; // Search parametrization - unsigned int nbMaxIter = (unsigned int)(node->GetPolygonExteriorRing()->GetArea()); -// - insiders.size() * CONST_PI * vcl_pow(this->GetInhibitionRadius(), 2)) -// / (CONST_PI * vcl_pow(this->GetInhibitionRadius(), 2))); - //std::cout << "nbMaxIter: " << nbMaxIter << std::endl; - - unsigned int nbMaxPosition = (unsigned int)(nbMaxIter * this->GetRandomLocalizationDensity()); + //unsigned int nbMaxIter = (unsigned int)(node->GetPolygonExteriorRing()->GetArea()); + // - insiders.size() * CONST_PI * vcl_pow(this->GetInhibitionRadius(), 2)) + // / (CONST_PI * vcl_pow(this->GetInhibitionRadius(), 2))); + + unsigned int nbMaxPosition = (unsigned int)(node->GetPolygonExteriorRing()->GetArea() * this->GetRandomLocalizationDensity()); + + //std::cout << "nbMaxIter: " << this->GetNbMaxIteration() << std::endl; //std::cout << "nbMaxPosition: " << nbMaxPosition << std::endl; // Generation - unsigned int nbIter = nbMaxIter; + unsigned long int nbIter = this->GetNbMaxIteration(); unsigned int nbPosition = nbMaxPosition; PointType rangeMin,rangeMax; diff --git a/Testing/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.cxx b/Testing/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.cxx index cac3d605d6f33d20da267f842e41d381fea8888e..08d91bda76c7859eb588a01b3bf800a4ad2b338b 100644 --- a/Testing/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.cxx +++ b/Testing/Code/ObjectDetection/otbLabeledSampleLocalizationGenerator.cxx @@ -67,7 +67,8 @@ int otbLabeledSampleLocalizationGenerator(int argc, char* argv[]) generator->SetClassKey("Class"); generator->SetNoClassIdentifier(0); generator->SetInhibitionRadius(5); - generator->SetRandomLocalizationDensity(0.05); + generator->SetRandomLocalizationDensity(0.004); + generator->SetNbMaxIteration(1000); generator->Update();