Skip to content

Commit cf68a01

Browse files
committed
saliency: cleanup module and samples
1 parent 3f4e7df commit cf68a01

File tree

4 files changed

+7
-56
lines changed

4 files changed

+7
-56
lines changed

modules/saliency/include/opencv2/saliency/saliencyBaseClasses.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
6767
*/
6868
virtual ~Saliency();
6969

70-
/**
71-
* \brief Create Saliency by saliency type.
72-
*/
73-
static Ptr<Saliency> create( const String& saliencyType );
74-
7570
/**
7671
* \brief Compute the saliency
7772
* \param image The image.
@@ -80,12 +75,6 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
8075
*/
8176
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap );
8277

83-
/**
84-
* \brief Get the name of the specific saliency type
85-
* \return The name of the tracker initializer
86-
*/
87-
CV_WRAP String getClassName() const;
88-
8978
protected:
9079

9180
virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap ) = 0;

modules/saliency/samples/computeSaliency.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,7 @@ int main( int argc, char** argv )
9595
Mat frame;
9696

9797
//instantiates the specific Saliency
98-
Ptr<Saliency> saliencyAlgorithm = Saliency::create( saliency_algorithm );
99-
100-
if( saliencyAlgorithm == NULL )
101-
{
102-
cout << "***Error in the instantiation of the saliency algorithm...***\n";
103-
return -1;
104-
}
98+
Ptr<Saliency> saliencyAlgorithm;
10599

106100
Mat binaryMap;
107101
Mat image;
@@ -117,6 +111,7 @@ int main( int argc, char** argv )
117111
if( saliency_algorithm.find( "SPECTRAL_RESIDUAL" ) == 0 )
118112
{
119113
Mat saliencyMap;
114+
saliencyAlgorithm = StaticSaliencySpectralResidual::create();
120115
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
121116
{
122117
StaticSaliencySpectralResidual spec;
@@ -132,6 +127,7 @@ int main( int argc, char** argv )
132127
else if( saliency_algorithm.find( "FINE_GRAINED" ) == 0 )
133128
{
134129
Mat saliencyMap;
130+
saliencyAlgorithm = StaticSaliencyFineGrained::create();
135131
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
136132
{
137133
imshow( "Saliency Map", saliencyMap );
@@ -151,6 +147,7 @@ int main( int argc, char** argv )
151147

152148
else
153149
{
150+
saliencyAlgorithm = ObjectnessBING::create();
154151
vector<Vec4i> saliencyMap;
155152
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setTrainingPath( training_path );
156153
saliencyAlgorithm.dynamicCast<ObjectnessBING>()->setBBResDir( training_path + "/Results" );
@@ -164,8 +161,7 @@ int main( int argc, char** argv )
164161
}
165162
else if( saliency_algorithm.find( "BinWangApr2014" ) == 0 )
166163
{
167-
168-
//Ptr<Size> size = Ptr<Size>( new Size( image.cols, image.rows ) );
164+
saliencyAlgorithm = MotionSaliencyBinWangApr2014::create();
169165
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( image.cols, image.rows );
170166
saliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
171167

@@ -183,10 +179,7 @@ int main( int argc, char** argv )
183179
cvtColor( frame, frame, COLOR_BGR2GRAY );
184180

185181
Mat saliencyMap;
186-
if( saliencyAlgorithm->computeSaliency( frame, saliencyMap ) )
187-
{
188-
//std::cout << "current frame motion saliency done" << std::endl;
189-
}
182+
saliencyAlgorithm->computeSaliency( frame, saliencyMap );
190183

191184
imshow( "image", frame );
192185
imshow( "saliencyMap", saliencyMap * 255 );

modules/saliency/src/motionSaliencyBinWangApr2014.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ bool MotionSaliencyBinWangApr2014::decisionThresholdAdaptation()
621621
return true;
622622
}
623623

624-
bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image, OutputArray saliencyMap )
624+
bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( InputArray image, OutputArray saliencyMap )
625625
{
626626
Mat highResBFMask, u_highResBFMask;
627627
Mat lowResBFMask, u_lowResBFMask;
@@ -646,24 +646,11 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
646646
decisionThresholdAdaptation();
647647
}
648648

649-
//double t = (double) getTickCount();
650-
651649
templateOrdering();
652-
653-
/*t = ( (double) getTickCount() - t ) / getTickFrequency();
654-
std::cout << "T :" << t << std::endl;
655-
*/
656650
templateReplacement( saliencyMap.getMat(), image.getMat() );
657-
658-
//double t2 = (double) getTickCount();
659-
660651
templateOrdering();
661652

662-
//t2 = ( (double) getTickCount() - t2 ) / getTickFrequency();
663-
//std::cout << "T2 :" << t2 << std::endl;
664-
665653
activityControlFlag = true;
666-
667654
return true;
668655
}
669656

modules/saliency/src/saliency.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,6 @@ Saliency::~Saliency()
5151

5252
}
5353

54-
Ptr<Saliency> Saliency::create( const String& saliencyType )
55-
{
56-
if (saliencyType == "SPECTRAL_RESIDUAL")
57-
return makePtr<StaticSaliencySpectralResidual>();
58-
else if (saliencyType == "FINE_GRAINED")
59-
return makePtr<StaticSaliencyFineGrained>();
60-
else if (saliencyType == "BING")
61-
return makePtr<ObjectnessBING>();
62-
else if (saliencyType == "BinWangApr2014")
63-
return makePtr<MotionSaliencyBinWangApr2014>();
64-
return Ptr<Saliency>();
65-
}
66-
6754
bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap )
6855
{
6956
if( image.empty() )
@@ -72,10 +59,5 @@ bool Saliency::computeSaliency( InputArray image, OutputArray saliencyMap )
7259
return computeSaliencyImpl( image, saliencyMap );
7360
}
7461

75-
String Saliency::getClassName() const
76-
{
77-
return className;
78-
}
79-
8062
} /* namespace saliency */
8163
} /* namespace cv */

0 commit comments

Comments
 (0)