Commit cf68a011 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov

saliency: cleanup module and samples

parent 3f4e7dfc
...@@ -67,11 +67,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm ...@@ -67,11 +67,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
*/ */
virtual ~Saliency(); virtual ~Saliency();
/**
* \brief Create Saliency by saliency type.
*/
static Ptr<Saliency> create( const String& saliencyType );
/** /**
* \brief Compute the saliency * \brief Compute the saliency
* \param image The image. * \param image The image.
...@@ -80,12 +75,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm ...@@ -80,12 +75,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
*/ */
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap ); CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap );
/**
* \brief Get the name of the specific saliency type
* \return The name of the tracker initializer
*/
CV_WRAP String getClassName() const;
protected: protected:
virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap ) = 0; virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap ) = 0;
......
...@@ -95,13 +95,7 @@ int main( int argc, char** argv ) ...@@ -95,13 +95,7 @@ int main( int argc, char** argv )
Mat frame; Mat frame;
//instantiates the specific Saliency //instantiates the specific Saliency
Ptr<Saliency> saliencyAlgorithm = Saliency::create( saliency_algorithm ); Ptr<Saliency> saliencyAlgorithm;
if( saliencyAlgorithm == NULL )
{
cout << "***Error in the instantiation of the saliency algorithm...***\n";
return -1;
}
Mat binaryMap; Mat binaryMap;
Mat image; Mat image;
...@@ -117,6 +111,7 @@ int main( int argc, char** argv ) ...@@ -117,6 +111,7 @@ int main( int argc, char** argv )
if( saliency_algorithm.find( "SPECTRAL_RESIDUAL" ) == 0 ) if( saliency_algorithm.find( "SPECTRAL_RESIDUAL" ) == 0 )
{ {
Mat saliencyMap; Mat saliencyMap;
saliencyAlgorithm = StaticSaliencySpectralResidual::create();
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) ) if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{ {
StaticSaliencySpectralResidual spec; StaticSaliencySpectralResidual spec;
...@@ -132,6 +127,7 @@ int main( int argc, char** argv ) ...@@ -132,6 +127,7 @@ int main( int argc, char** argv )
else if( saliency_algorithm.find( "FINE_GRAINED" ) == 0 ) else if( saliency_algorithm.find( "FINE_GRAINED" ) == 0 )
{ {
Mat saliencyMap; Mat saliencyMap;
saliencyAlgorithm = StaticSaliencyFineGrained::create();
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) ) if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{ {
imshow( "Saliency Map", saliencyMap ); imshow( "Saliency Map", saliencyMap );
...@@ -151,6 +147,7 @@ int main( int argc, char** argv ) ...@@ -151,6 +147,7 @@ int main( int argc, char** argv )
else else
{ {
saliencyAlgorithm = ObjectnessBING::create();
vector<Vec4i> saliencyMap; vector<Vec4i> saliencyMap;
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setTrainingPath( training_path ); saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setTrainingPath( training_path );
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setBBResDir( training_path + "/Results" ); saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setBBResDir( training_path + "/Results" );
...@@ -164,8 +161,7 @@ int main( int argc, char** argv ) ...@@ -164,8 +161,7 @@ int main( int argc, char** argv )
} }
else if( saliency_algorithm.find( "BinWangApr2014" ) == 0 ) else if( saliency_algorithm.find( "BinWangApr2014" ) == 0 )
{ {
saliencyAlgorithm = MotionSaliencyBinWangApr2014::create();
//Ptr<Size> size = Ptr<Size>( new Size( image.cols, image.rows ) );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( image.cols, image.rows ); saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( image.cols, image.rows );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init(); saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
...@@ -183,10 +179,7 @@ int main( int argc, char** argv ) ...@@ -183,10 +179,7 @@ int main( int argc, char** argv )
cvtColor( frame, frame, COLOR_BGR2GRAY ); cvtColor( frame, frame, COLOR_BGR2GRAY );
Mat saliencyMap; Mat saliencyMap;
if( saliencyAlgorithm->computeSaliency( frame, saliencyMap ) ) saliencyAlgorithm->computeSaliency( frame, saliencyMap );
{
//std::cout << "current frame motion saliency done" << std::endl;
}
imshow( "image", frame ); imshow( "image", frame );
imshow( "saliencyMap", saliencyMap * 255 ); imshow( "saliencyMap", saliencyMap * 255 );
......
...@@ -621,7 +621,7 @@ bool MotionSaliencyBinWangApr2014::decisionThresholdAdaptation() ...@@ -621,7 +621,7 @@ bool MotionSaliencyBinWangApr2014::decisionThresholdAdaptation()
return true; return true;
} }
bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image, OutputArray saliencyMap ) bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( InputArray image, OutputArray saliencyMap )
{ {
Mat highResBFMask, u_highResBFMask; Mat highResBFMask, u_highResBFMask;
Mat lowResBFMask, u_lowResBFMask; Mat lowResBFMask, u_lowResBFMask;
...@@ -646,24 +646,11 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image, ...@@ -646,24 +646,11 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
decisionThresholdAdaptation(); decisionThresholdAdaptation();
} }
//double t = (double) getTickCount();
templateOrdering(); templateOrdering();
/*t = ( (double) getTickCount() - t ) / getTickFrequency();
std::cout << "T :" << t << std::endl;
*/
templateReplacement( saliencyMap.getMat(), image.getMat() ); templateReplacement( saliencyMap.getMat(), image.getMat() );
//double t2 = (double) getTickCount();
templateOrdering(); templateOrdering();
//t2 = ( (double) getTickCount() - t2 ) / getTickFrequency();
//std::cout << "T2 :" << t2 << std::endl;
activityControlFlag = true; activityControlFlag = true;
return true; return true;
} }
......
...@@ -51,19 +51,6 @@ Saliency::~Saliency() ...@@ -51,19 +51,6 @@ Saliency::~Saliency()
} }
Ptr<Saliency> Saliency::create( const String& saliencyType )
{
if (saliencyType == "SPECTRAL_RESIDUAL")
return makePtr<StaticSaliencySpectralResidual>();
else if (saliencyType == "FINE_GRAINED")
return makePtr<StaticSaliencyFineGrained>();
else if (saliencyType == "BING")
return makePtr<ObjectnessBING>();
else if (saliencyType == "BinWangApr2014")
return makePtr<MotionSaliencyBinWangApr2014>();
return Ptr<Saliency>();
}
bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap ) bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap )
{ {
if( image.empty() ) if( image.empty() )
...@@ -72,10 +59,5 @@ bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap ) ...@@ -72,10 +59,5 @@ bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap )
return computeSaliencyImpl( image, saliencyMap ); return computeSaliencyImpl( image, saliencyMap );
} }
String Saliency::getClassName() const
{
return className;
}
} /* namespace saliency */ } /* namespace saliency */
} /* namespace cv */ } /* namespace cv */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment