Wrap all methods from ObjectnessBING, add create methods for all Saliency classes

pull/796/head
Vladislav Sovrasov 9 years ago
parent 5b2d6a667d
commit 94e919eb45
  1. 8
      modules/saliency/include/opencv2/saliency/saliencyBaseClasses.hpp
  2. 66
      modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
  3. 4
      modules/saliency/src/BING/objectnessBING.cpp
  4. 6
      modules/saliency/src/staticSaliency.cpp

@ -84,7 +84,7 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
* \brief Get the name of the specific saliency type * \brief Get the name of the specific saliency type
* \return The name of the tracker initializer * \return The name of the tracker initializer
*/ */
String getClassName() const; CV_WRAP String getClassName() const;
protected: protected:
@ -109,10 +109,10 @@ class CV_EXPORTS_W StaticSaliency : public virtual Saliency
algorithm calculates the optimal threshold separating those two classes, so that their algorithm calculates the optimal threshold separating those two classes, so that their
intra-class variance is minimal. intra-class variance is minimal.
@param saliencyMap the saliency map obtained through one of the specialized algorithms @param _saliencyMap the saliency map obtained through one of the specialized algorithms
@param binaryMap the binary map @param _binaryMap the binary map
*/ */
CV_WRAP bool computeBinaryMap( const Mat& saliencyMap, Mat& binaryMap ); CV_WRAP bool computeBinaryMap( InputArray _saliencyMap, OutputArray _binaryMap );
protected: protected:
virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap )=0; virtual bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap )=0;

@ -42,7 +42,6 @@
#ifndef __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__ #ifndef __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__
#define __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__ #define __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__
//#include "opencv2/saliency/kyheader.hpp"
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -71,9 +70,22 @@ class CV_EXPORTS_W StaticSaliencySpectralResidual : public StaticSaliency
{ {
public: public:
CV_WRAP StaticSaliencySpectralResidual(); StaticSaliencySpectralResidual();
virtual ~StaticSaliencySpectralResidual(); virtual ~StaticSaliencySpectralResidual();
CV_WRAP static Ptr<StaticSaliencySpectralResidual> create()
{
return makePtr<StaticSaliencySpectralResidual>();
}
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap )
{
if( image.empty() )
return false;
return computeSaliencyImpl( image, saliencyMap );
}
CV_WRAP void read( const FileNode& fn ); CV_WRAP void read( const FileNode& fn );
void write( FileStorage& fs ) const; void write( FileStorage& fs ) const;
@ -115,9 +127,22 @@ protected:
class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
{ {
public: public:
CV_WRAP MotionSaliencyBinWangApr2014(); MotionSaliencyBinWangApr2014();
virtual ~MotionSaliencyBinWangApr2014(); virtual ~MotionSaliencyBinWangApr2014();
CV_WRAP static Ptr<MotionSaliencyBinWangApr2014> create()
{
return makePtr<MotionSaliencyBinWangApr2014>();
}
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap )
{
if( image.empty() )
return false;
return computeSaliencyImpl( image, saliencyMap );
}
/** @brief This is a utility function that allows to set the correct size (taken from the input image) in the /** @brief This is a utility function that allows to set the correct size (taken from the input image) in the
corresponding variables that will be used to size the data structures of the algorithm. corresponding variables that will be used to size the data structures of the algorithm.
@param W width of input image @param W width of input image
@ -205,11 +230,24 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
{ {
public: public:
CV_WRAP ObjectnessBING(); ObjectnessBING();
virtual ~ObjectnessBING(); virtual ~ObjectnessBING();
void read(); CV_WRAP static Ptr<ObjectnessBING> create()
void write() const; {
return makePtr<ObjectnessBING>();
}
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap )
{
if( image.empty() )
return false;
return computeSaliencyImpl( image, saliencyMap );
}
CV_WRAP void read();
CV_WRAP void write() const;
/** @brief Return the list of the rectangles' objectness value, /** @brief Return the list of the rectangles' objectness value,
@ -223,7 +261,7 @@ public:
the trained model. the trained model.
@param trainingPath trained model path @param trainingPath trained model path
*/ */
void setTrainingPath( std::string trainingPath ); CV_WRAP void setTrainingPath( const String& trainingPath );
/** @brief This is a utility function that allows to set an arbitrary path in which the algorithm will save the /** @brief This is a utility function that allows to set an arbitrary path in which the algorithm will save the
optional results optional results
@ -232,29 +270,29 @@ public:
each row). each row).
@param resultsDir results' folder path @param resultsDir results' folder path
*/ */
void setBBResDir( std::string resultsDir ); CV_WRAP void setBBResDir( const String& resultsDir );
double getBase() const CV_WRAP double getBase() const
{ {
return _base; return _base;
} }
inline void setBase(double val) CV_WRAP inline void setBase(double val)
{ {
_base = val; _base = val;
} }
int getNSS() const CV_WRAP int getNSS() const
{ {
return _NSS; return _NSS;
} }
void setNSS(int val) CV_WRAP void setNSS(int val)
{ {
_NSS = val; _NSS = val;
} }
int getW() const CV_WRAP int getW() const
{ {
return _W; return _W;
} }
void setW(int val) CV_WRAP void setW(int val)
{ {
_W = val; _W = val;
} }

@ -88,12 +88,12 @@ void ObjectnessBING::setColorSpace( int clr )
_bbResDir = _resultsDir + "/" + std::string( format( "BBoxesB%gW%d%s/", _base, _W, _clrName[_Clr] ).c_str() ); _bbResDir = _resultsDir + "/" + std::string( format( "BBoxesB%gW%d%s/", _base, _W, _clrName[_Clr] ).c_str() );
} }
void ObjectnessBING::setTrainingPath( std::string trainingPath ) void ObjectnessBING::setTrainingPath( const String& trainingPath )
{ {
_trainingPath = trainingPath; _trainingPath = trainingPath;
} }
void ObjectnessBING::setBBResDir( std::string resultsDir ) void ObjectnessBING::setBBResDir(const String &resultsDir )
{ {
_resultsDir = resultsDir; _resultsDir = resultsDir;
} }

@ -50,9 +50,9 @@ namespace saliency
* StaticSaliency * StaticSaliency
*/ */
bool StaticSaliency::computeBinaryMap( const Mat& saliencyMap, Mat& BinaryMap ) bool StaticSaliency::computeBinaryMap( InputArray _saliencyMap, OutputArray _binaryMap )
{ {
Mat saliencyMap = _saliencyMap.getMat();
Mat labels = Mat::zeros( saliencyMap.rows * saliencyMap.cols, 1, 1 ); Mat labels = Mat::zeros( saliencyMap.rows * saliencyMap.cols, 1, 1 );
Mat samples = Mat_<float>( saliencyMap.rows * saliencyMap.cols, 1 ); Mat samples = Mat_<float>( saliencyMap.rows * saliencyMap.cols, 1 );
Mat centers; Mat centers;
@ -90,6 +90,8 @@ bool StaticSaliency::computeBinaryMap( const Mat& saliencyMap, Mat& BinaryMap )
outputMat.convertTo( outputMat, CV_8U ); outputMat.convertTo( outputMat, CV_8U );
// adaptative thresholding using Otsu's method, to make saliency map binary // adaptative thresholding using Otsu's method, to make saliency map binary
_binaryMap.createSameSize(outputMat, outputMat.type());
Mat BinaryMap = _binaryMap.getMat();
threshold( outputMat, BinaryMap, 0, 255, THRESH_BINARY | THRESH_OTSU ); threshold( outputMat, BinaryMap, 0, 255, THRESH_BINARY | THRESH_OTSU );
return true; return true;

Loading…
Cancel
Save