Fix warnings to build with Werror flag
This commit is contained in:
@@ -32,55 +32,61 @@
|
||||
SaliencyBasedFiltering::SaliencyBasedFiltering()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = MODULE_API_2;
|
||||
m_iModuleType = FRAME_PROCESSING_MODULE;
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "SaliencyBasedFiltering";
|
||||
m_pchModuleTooltip = "Image filter based on a map";
|
||||
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = 2;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
}
|
||||
|
||||
Bool SaliencyBasedFiltering::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
bool SaliencyBasedFiltering::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
for( UInt i = 0; i < apcFrameList.size(); i++ )
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_RESOLUTION ) )
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_RESOLUTION ) )
|
||||
return false;
|
||||
}
|
||||
if( apcFrameList[1]->getNumberChannels() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pcProcessedFrame = new PlaYUVerFrame( apcFrameList[0] );
|
||||
|
||||
m_pcProcessedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static cv::Mat* getCvFrame( Pel* pInputPel, UInt uiWidth, UInt uiHeight )
|
||||
static cv::Mat* getCvFrame( ClpPel* pInputPel, unsigned uiWidth, unsigned uiHeight )
|
||||
{
|
||||
cv::Mat* cvInput = new cv::Mat( uiHeight, uiWidth, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
UChar* pCvPel = cvInput->data;
|
||||
for( UInt i = 0; i < uiWidth * uiHeight; i++ )
|
||||
unsigned char* pCvPel = cvInput->data;
|
||||
for( unsigned i = 0; i < uiWidth * uiHeight; i++ )
|
||||
{
|
||||
*pCvPel++ = *pInputPel++;
|
||||
}
|
||||
return cvInput;
|
||||
}
|
||||
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, UInt kernelSize )
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, unsigned kernelSize )
|
||||
{
|
||||
cv::Mat* cvFiltered = new cv::Mat( cvFrame->rows, cvFrame->cols, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
/// Initialize arguments for the filter
|
||||
cv::Point anchor = cv::Point( -1, -1 );
|
||||
Double delta = 0;
|
||||
Int ddepth = -1;
|
||||
double delta = 0;
|
||||
int ddepth = -1;
|
||||
|
||||
/// Update kernel size for a normalized box filter
|
||||
cv::Mat kernel = cv::Mat::ones( kernelSize, kernelSize, CV_32F ) / (Double)( kernelSize * kernelSize );
|
||||
cv::Mat kernel = cv::Mat::ones( kernelSize, kernelSize, CV_32F ) / static_cast<double>( kernelSize * kernelSize );
|
||||
|
||||
/// Apply filter
|
||||
cv::filter2D( *cvFrame, *cvFiltered, ddepth, kernel, anchor, delta, cv::BORDER_DEFAULT );
|
||||
@@ -88,44 +94,42 @@ static cv::Mat* filterframe( cv::Mat* cvFrame, UInt kernelSize )
|
||||
return cvFiltered;
|
||||
}
|
||||
|
||||
static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaYUVerFrame* Map, UInt uiComp )
|
||||
static void filterComponent( CalypFrame* pInput, CalypFrame* pOutput, CalypFrame* Map, unsigned uiComp )
|
||||
{
|
||||
Pel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
Int iMapStep = 1;
|
||||
Pel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
Pel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
Int iHeight = pInput->getHeight();
|
||||
Int iWidth = pInput->getWidth();
|
||||
ClpPel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
int iMapStep = 1;
|
||||
ClpPel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
ClpPel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
std::int64_t iHeight = pInput->getHeight( uiComp );
|
||||
std::int64_t iWidth = pInput->getWidth( uiComp );
|
||||
|
||||
if( uiComp > 0 )
|
||||
{
|
||||
iHeight = pInput->getChromaHeight();
|
||||
iWidth = pInput->getChromaWidth();
|
||||
iMapStep = 2;
|
||||
}
|
||||
|
||||
cv::Mat* cvInput = getCvFrame( pInputPel, iWidth, iHeight );
|
||||
|
||||
UInt numberFilters = 1;
|
||||
UChar* pCvPel[3];
|
||||
unsigned numberFilters = 1;
|
||||
unsigned char* pCvPel[3];
|
||||
cv::Mat* cvOutput[3];
|
||||
for( UInt i = 0; i < numberFilters; i++ )
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
{
|
||||
cvOutput[i] = filterframe( cvInput, ( 1 << ( 2 * i + 7 ) ) + 1 );
|
||||
pCvPel[i] = cvOutput[i]->data;
|
||||
}
|
||||
|
||||
Int iCheckNeighbour = 8;
|
||||
UInt uiRelevance = 0;
|
||||
for( Int y = 0; y < iHeight; y++ )
|
||||
int iCheckNeighbour = 8;
|
||||
unsigned uiRelevance = 0;
|
||||
for( int y = 0; y < iHeight; y++ )
|
||||
{
|
||||
for( Int x = 0; x < iWidth; x++ )
|
||||
for( int x = 0; x < iWidth; x++ )
|
||||
{
|
||||
uiRelevance = 0;
|
||||
// uiRelevance = *pMapPel;
|
||||
for( Int j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
for( std::int64_t j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
{
|
||||
for( Int i = CLAMP_RANGE( x - iCheckNeighbour, 0, iWidth ); i < CLAMP_RANGE( x + iCheckNeighbour + 1, 0, iWidth ); i++ )
|
||||
for( std::int64_t i = CLAMP_RANGE( x - iCheckNeighbour, 0, iWidth ); i < CLAMP_RANGE( x + iCheckNeighbour + 1, 0, iWidth ); i++ )
|
||||
{
|
||||
uiRelevance += *( pMapPel + ( ( j - y ) * iWidth ) + ( i - x ) );
|
||||
}
|
||||
@@ -141,7 +145,7 @@ static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaY
|
||||
//*pOutputPel = 0;
|
||||
}
|
||||
|
||||
for( UInt i = 0; i < numberFilters; i++ )
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
pCvPel[i]++;
|
||||
pInputPel++;
|
||||
pOutputPel++;
|
||||
@@ -151,16 +155,16 @@ static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaY
|
||||
}
|
||||
}
|
||||
|
||||
PlaYUVerFrame* SaliencyBasedFiltering::process( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
CalypFrame* SaliencyBasedFiltering::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
PlaYUVerFrame* pcInputFrame = apcFrameList[0];
|
||||
CalypFrame* pcInputFrame = apcFrameList[0];
|
||||
|
||||
for( UInt c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame, apcFrameList[1], c );
|
||||
for( unsigned c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame.get(), apcFrameList[1], c );
|
||||
|
||||
return m_pcProcessedFrame;
|
||||
return m_pcProcessedFrame.get();
|
||||
}
|
||||
|
||||
Void SaliencyBasedFiltering::destroy()
|
||||
void SaliencyBasedFiltering::destroy()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user