Add motion based saliency and improve documentation

This commit is contained in:
jfmcarreira committed 2018-02-02 04:56:11 +00:00
1 parent 50cc22cb46
commit 2958c03249
4 files changed
+92 -12

No files matched your search

+7 -8
View File
@@ -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
+1
View File
@@ -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 )
#
+40 -4
View File
@@ -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<PlaYUVerFrame*> 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<PlaYUVerFrame*> 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::vector<PlaYUVerFrame*
m_pcSaliencyFrame->fromMat( 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<PlaYUVerFrame*> apcFrameList )
{
Bool bRet = commonCreate( apcFrameList );
if( !bRet )
return bRet;
m_ptrSaliencyAlgorithm = MotionSaliencyBinWangApr2014::create();
m_ptrSaliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight() );
m_ptrSaliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
return true;
}
PlaYUVerFrame* SaliencyDetectionBinWangApr2014::process( std::vector<PlaYUVerFrame*> 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;
}
+44
View File
@@ -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<PlaYUVerFrame*> 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<PlaYUVerFrame*> 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<PlaYUVerFrame*> apcFrameList );
PlaYUVerFrame* process( std::vector<PlaYUVerFrame*> apcFrameList );
};
#endif // __SALIENCYDETECTION_H__