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
*/
virtual ~Saliency();
/**
* \brief Create Saliency by saliency type.
*/
static Ptr<Saliency> create( const String& saliencyType );
/**
* \brief Compute the saliency
* \param image The image.
......@@ -80,12 +75,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
*/
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:
virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap ) = 0;
......
......@@ -95,13 +95,7 @@ int main( int argc, char** argv )
Mat frame;
//instantiates the specific Saliency
Ptr<Saliency> saliencyAlgorithm = Saliency::create( saliency_algorithm );
if( saliencyAlgorithm == NULL )
{
cout << "***Error in the instantiation of the saliency algorithm...***\n";
return -1;
}
Ptr<Saliency> saliencyAlgorithm;
Mat binaryMap;
Mat image;
......@@ -117,6 +111,7 @@ int main( int argc, char** argv )
if( saliency_algorithm.find( "SPECTRAL_RESIDUAL" ) == 0 )
{
Mat saliencyMap;
saliencyAlgorithm = StaticSaliencySpectralResidual::create();
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{
StaticSaliencySpectralResidual spec;
......@@ -132,6 +127,7 @@ int main( int argc, char** argv )
else if( saliency_algorithm.find( "FINE_GRAINED" ) == 0 )
{
Mat saliencyMap;
saliencyAlgorithm = StaticSaliencyFineGrained::create();
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{
imshow( "Saliency Map", saliencyMap );
......@@ -151,6 +147,7 @@ int main( int argc, char** argv )
else
{
saliencyAlgorithm = ObjectnessBING::create();
vector<Vec4i> saliencyMap;
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setTrainingPath( training_path );
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setBBResDir( training_path + "/Results" );
......@@ -164,8 +161,7 @@ int main( int argc, char** argv )
}
else if( saliency_algorithm.find( "BinWangApr2014" ) == 0 )
{
//Ptr<Size> size = Ptr<Size>( new Size( image.cols, image.rows ) );
saliencyAlgorithm = MotionSaliencyBinWangApr2014::create();
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( image.cols, image.rows );
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
......@@ -183,10 +179,7 @@ int main( int argc, char** argv )
cvtColor( frame, frame, COLOR_BGR2GRAY );
Mat saliencyMap;
if( saliencyAlgorithm->computeSaliency( frame, saliencyMap ) )
{
//std::cout << "current frame motion saliency done" << std::endl;
}
saliencyAlgorithm->computeSaliency( frame, saliencyMap );
imshow( "image", frame );
imshow( "saliencyMap", saliencyMap * 255 );
......
......@@ -621,7 +621,7 @@ bool MotionSaliencyBinWangApr2014::decisionThresholdAdaptation()
return true;
}
bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image, OutputArray saliencyMap )
bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( InputArray image, OutputArray saliencyMap )
{
Mat highResBFMask, u_highResBFMask;
Mat lowResBFMask, u_lowResBFMask;
......@@ -646,24 +646,11 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
decisionThresholdAdaptation();
}
//double t = (double) getTickCount();
templateOrdering();
/*t = ( (double) getTickCount() - t ) / getTickFrequency();
std::cout << "T :" << t << std::endl;
*/
templateReplacement( saliencyMap.getMat(), image.getMat() );
//double t2 = (double) getTickCount();
templateOrdering();
//t2 = ( (double) getTickCount() - t2 ) / getTickFrequency();
//std::cout << "T2 :" << t2 << std::endl;
activityControlFlag = true;
return true;
}
......
......@@ -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 )
{
if( image.empty() )
......@@ -72,10 +59,5 @@ bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap )
return computeSaliencyImpl( image, saliencyMap );
}
String Saliency::getClassName() const
{
return className;
}
} /* namespace saliency */
} /* 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