diff --git a/lib/PlaYUVerModuleIf.h b/lib/PlaYUVerModuleIf.h index 7cf42ef..a919049 100644 --- a/lib/PlaYUVerModuleIf.h +++ b/lib/PlaYUVerModuleIf.h @@ -19,7 +19,7 @@ /** * \file PlaYUVerModuleIf.h - * \ingroup PlaYUVerLib_Modules + * \ingroup PlaYUVer_Modules * \brief PlaYUVer modules interface */ @@ -27,8 +27,7 @@ #define __PLAYUVERMODULESIF_H__ /** - * \ingroup PlaYUVerLib - * @defgroup PlaYUVerLib_Modules PlaYUVer Modules + * @defgroup PlaYUVer_Modules PlaYUVer Modules * @{ * PlaYUVerLib supports the creation of independent * frame processing modules @@ -53,7 +52,7 @@ public: \ return false; /** Module_API_Version Enum - * \ingroup PlaYUVerLib_Modules + * \ingroup PlaYUVer_Modules * Version of the modules API required * @see m_iModuleAPI */ @@ -64,7 +63,7 @@ enum Module_API_Version }; /** Module_Type Enum - * \ingroup PlaYUVerLib_Modules + * \ingroup PlaYUVer_Modules * Type of module * @see m_iModuleType */ @@ -75,7 +74,7 @@ enum Module_Type }; /** Module_NumberOfFrames Enum - * \ingroup PlaYUVerLib_Modules + * \ingroup PlaYUVer_Modules * Number of frames requires by a module * @see m_uiNumberOfFrames */ @@ -92,7 +91,7 @@ enum Module_NumberOfFrames }; /** Module_Features Enum - * \ingroup PlaYUVerLib_Modules + * \ingroup PlaYUVer_Modules * Features/Requirements of a module * @see m_uiModuleRequirements */ @@ -115,7 +114,7 @@ enum Module_Key_Supported /** * \class PlaYUVerModuleIf - * \ingroup PlaYUVerLib PlaYUVerLib_Modules + * \ingroup PlaYUVerLib PlaYUVer_Modules * \brief Abstract class for modules */ class PlaYUVerModuleIf diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 58912c3..3477466 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -38,6 +38,7 @@ ADD_MODULE_USE_OPENCV( OpticalFlowFarneback "OpticalFlow" VERSION 3.1.0 MODULES ADD_MODULE_USE_OPENCV( OpticalDeepFlow "OpticalFlow" VERSION 3.1.0 MODULES video optflow ) ADD_MODULE_USE_OPENCV( SaliencyDetectionSpectral "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) ADD_MODULE_USE_OPENCV( SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) +ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.1.0 MODULES saliency ) # diff --git a/modules/SaliencyDetection.cpp b/modules/SaliencyDetection.cpp index 88ffaf3..ed1b3f7 100644 --- a/modules/SaliencyDetection.cpp +++ b/modules/SaliencyDetection.cpp @@ -30,7 +30,7 @@ using cv::Mat; using cv::Ptr; -using cv::saliency::Saliency; +using namespace cv::saliency; SaliencyDetectionModule::SaliencyDetectionModule() { @@ -91,7 +91,7 @@ Bool SaliencyDetectionSpectral::create( std::vector apcFrameList if( !bRet ) return bRet; - m_ptrSaliencyAlgorithm = cv::saliency::StaticSaliencySpectralResidual::create(); + m_ptrSaliencyAlgorithm = StaticSaliencySpectralResidual::create(); return true; } @@ -101,13 +101,18 @@ PlaYUVerFrame* SaliencyDetectionSpectral::process( std::vector a if( commonProcess( apcFrameList ) ) { Mat matBinaryMap; - cv::saliency::StaticSaliencySpectralResidual spec; + StaticSaliencySpectralResidual spec; spec.computeBinaryMap( m_matSaliency, matBinaryMap ); - if( m_bBinaryMap ) + { m_pcSaliencyFrame->fromMat( matBinaryMap ); + } else + { + m_matSaliency *= 255; + m_matSaliency.convertTo( m_matSaliency, CV_8UC1 ); m_pcSaliencyFrame->fromMat( m_matSaliency ); + } } return m_pcSaliencyFrame; } @@ -135,3 +140,34 @@ PlaYUVerFrame* SaliencyDetectionFineGrained::process( std::vectorfromMat( m_matSaliency ); return m_pcSaliencyFrame; } + +SaliencyDetectionBinWangApr2014::SaliencyDetectionBinWangApr2014() +{ + /* Module Definition */ + m_pchModuleName = "SaliencyDetectionBinWangApr2014"; + m_pchModuleLongName = "Fast Self-tuning Background Subtraction Algorithm"; + m_pchModuleTooltip = "Measure saliency using a fast self-tuning background subtraction algorithm"; +} + +Bool SaliencyDetectionBinWangApr2014::create( std::vector apcFrameList ) +{ + Bool bRet = commonCreate( apcFrameList ); + if( !bRet ) + return bRet; + m_ptrSaliencyAlgorithm = MotionSaliencyBinWangApr2014::create(); + m_ptrSaliencyAlgorithm.dynamicCast()->setImagesize( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight() ); + m_ptrSaliencyAlgorithm.dynamicCast()->init(); + return true; +} + +PlaYUVerFrame* SaliencyDetectionBinWangApr2014::process( std::vector apcFrameList ) +{ + if( commonProcess( apcFrameList ) ) + { + m_matSaliency *= 255; + m_matSaliency.convertTo( m_matSaliency, CV_8UC1 ); + //cv::cvtColor(m_matSaliency, m_matSaliency, cv::COLOR_BGR2GRAY); + m_pcSaliencyFrame->fromMat( m_matSaliency ); + } + return m_pcSaliencyFrame; +} diff --git a/modules/SaliencyDetection.h b/modules/SaliencyDetection.h index 1624c23..1fd37fb 100644 --- a/modules/SaliencyDetection.h +++ b/modules/SaliencyDetection.h @@ -32,6 +32,14 @@ // PlaYUVerLib #include "lib/PlaYUVerModuleIf.h" +/** + * \ingroup PlaYUVer_Modules + * @defgroup PlaYUVer_Modules_Saliency Saliency + * @{ + * Frame processing modules for saliency detection + * @} + */ + class SaliencyDetectionModule : public PlaYUVerModuleIf { protected: @@ -49,6 +57,15 @@ public: Void destroy(); }; +/** + * \ingroup PlaYUVer_Modules_Saliency + * \class SaliencyDetectionSpectral + * \brief Starting from the principle of natural image statistics, + * this method simulate the behavior of pre-attentive visual search. + * The algorithm analyze the log spectrum of each image and obtain the + * spectral residual. Then transform the spectral residual to spatial + * domain to obtain the saliency map, which suggests the positions of proto-objects. + */ class SaliencyDetectionSpectral : public SaliencyDetectionModule { REGISTER_CLASS_FACTORY( SaliencyDetectionSpectral ) @@ -62,6 +79,16 @@ public: PlaYUVerFrame* process( std::vector apcFrameList ); }; +/** + * \ingroup PlaYUVer_Modules_Saliency + * \class SaliencyDetectionFineGrained + * \brief This method calculates saliency based on center-surround + * differences. High resolution saliency maps are generated in real + * time by using integral images. + * Xiaodi Hou and Liqing Zhang. Saliency detection: A spectral residual + * approach. In Computer Vision and Pattern Recognition, 2007. + * CVPR'07. IEEE Conference on, pages 1–8. IEEE, 2007. + */ class SaliencyDetectionFineGrained : public SaliencyDetectionModule { REGISTER_CLASS_FACTORY( SaliencyDetectionFineGrained ) @@ -72,4 +99,21 @@ public: PlaYUVerFrame* process( std::vector apcFrameList ); }; +/** + * \ingroup PlaYUVer_Modules_Saliency + * \class SaliencyDetectionBinWangApr2014 + * \brief Fast Self-tuning Background Subtraction Algorithm based on the work + * Wang and P. Dudek “A Fast Self-tuning Background Subtraction Algorithm”, + * in proc of IEEE Workshop on Change Detection, 2014 + */ +class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule +{ + REGISTER_CLASS_FACTORY( SaliencyDetectionBinWangApr2014 ) +public: + SaliencyDetectionBinWangApr2014(); + virtual ~SaliencyDetectionBinWangApr2014() {} + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); +}; + #endif // __SALIENCYDETECTION_H__