Finish new api for pixels and change project tree
This commit is contained in:
1 parent
3ed163a44f
commit
a8958a1e43
97 files changed
+456
-677
No files matched your search
@@ -0,0 +1,47 @@
|
||||
###
|
||||
### CMakeLists for playuver modules component
|
||||
###
|
||||
|
||||
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
|
||||
|
||||
# set(plaYUver_Mod_SRCS
|
||||
# PlaYUVerModuleIf.cpp
|
||||
# )
|
||||
|
||||
|
||||
#
|
||||
# Init header
|
||||
#
|
||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "// This files defines the macro to \n"
|
||||
"// define a list of modules\n"
|
||||
"#ifndef __MODULESLISTMACRO_H__\n#define __MODULESLISTMACRO_H__\n"
|
||||
"#define REGISTER_ALL_MODULES ")
|
||||
|
||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "// This files add the header files of each module\n"
|
||||
|
||||
"#ifndef __MODULESLISTHEADER_H__\n#define __MODULESLISTHEADER_H__\n" )
|
||||
|
||||
|
||||
#
|
||||
# Modules List
|
||||
#
|
||||
ADD_MODULE( FilterComponentLuma "FilterComponent" )
|
||||
ADD_MODULE( FilterComponentChromaU "FilterComponent" )
|
||||
ADD_MODULE( FilterComponentChromaV "FilterComponent" )
|
||||
ADD_MODULE( FrameDifference "FrameDifference" )
|
||||
ADD_MODULE( MeasurePSNR "MeasurePSNR" )
|
||||
# IF( USE_OPENCV )
|
||||
# ADD_MODULE( DisparityStereoVar "DisparityStereoVar" )
|
||||
# ENDIF()
|
||||
|
||||
|
||||
#
|
||||
# Finish header
|
||||
#
|
||||
file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "\n#endif // __MODULESLISTMACRO_H__\n" )
|
||||
file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#endif // __MODULESLISTHEADER_H__\n" )
|
||||
|
||||
ADD_LIBRARY( PlaYUVerModules ${plaYUver_Mod_SRCS} )
|
||||
|
||||
|
||||
status("Modules List:" "${MODULES_LIST}" )
|
||||
@@ -0,0 +1,99 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file DisparityStereoVar.cpp
|
||||
* \brief Measure the disparity between two images using the Stereo Var method (OpenCV)
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "DisparityStereoVar.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
static PlaYUVerModuleDefinition DisparityStereoVarDef =
|
||||
{
|
||||
FRAME_PROCESSING_MODULE,
|
||||
"Disparity",
|
||||
"StereoVar",
|
||||
"Measure the disparity between two images using the Stereo Var method (OpenCV)",
|
||||
MODULE_REQUIRES_TWO_FRAMES,
|
||||
MODULE_REQUIRES_NEW_WINDOW,
|
||||
!APPLY_WHILE_PLAYING,
|
||||
};
|
||||
|
||||
DisparityStereoVar::DisparityStereoVar()
|
||||
{
|
||||
m_iModuleType = FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Disparity";
|
||||
m_pchModuleName = "StereoVar";
|
||||
m_pchModuleTooltip = "Measure the disparity between two images using the Stereo Var method (OpenCV)";
|
||||
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
|
||||
m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW;
|
||||
m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING;
|
||||
|
||||
setModuleDefinition( DisparityStereoVarDef );
|
||||
m_pcDisparityFrame = NULL;
|
||||
m_cStereoVar.levels = 3; // ignored with USE_AUTO_PARAMS
|
||||
m_cStereoVar.pyrScale = 0.5; // ignored with USE_AUTO_PARAMS
|
||||
m_cStereoVar.nIt = 25;
|
||||
|
||||
m_cStereoVar.maxDisp = 0;
|
||||
m_cStereoVar.poly_n = 3;
|
||||
m_cStereoVar.poly_sigma = 0.0;
|
||||
m_cStereoVar.fi = 15.0f;
|
||||
m_cStereoVar.lambda = 0.03f;
|
||||
m_cStereoVar.penalization = m_cStereoVar.PENALIZATION_TICHONOV; // ignored with USE_AUTO_PARAMS
|
||||
m_cStereoVar.cycle = m_cStereoVar.CYCLE_V; // ignored with USE_AUTO_PARAMS
|
||||
m_cStereoVar.flags = m_cStereoVar.USE_SMART_ID | m_cStereoVar.USE_AUTO_PARAMS | m_cStereoVar.USE_INITIAL_DISPARITY | m_cStereoVar.USE_MEDIAN_FILTERING;
|
||||
}
|
||||
|
||||
Void DisparityStereoVar::create( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
m_pcDisparityFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY );
|
||||
m_cStereoVar.minDisp = -( ( ( InputFrame->getWidth() / 8 ) + 15 ) & -16 );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* DisparityStereoVar::process( PlaYUVerFrame* InputLeft, PlaYUVerFrame* InputRight )
|
||||
{
|
||||
cv::Mat* leftImage;
|
||||
InputLeft->getCvMat( (Void**)&leftImage );
|
||||
cv::Mat* rightImage;
|
||||
InputRight->getCvMat( (Void**)&rightImage );
|
||||
cv::Mat disparityImage, disparityImage8;
|
||||
|
||||
m_cStereoVar(*leftImage,*rightImage,disparityImage);
|
||||
disparityImage.convertTo(disparityImage8,CV_8U);
|
||||
|
||||
m_pcDisparityFrame->fromCvMat( (Void*)&disparityImage8);
|
||||
return m_pcDisparityFrame;
|
||||
}
|
||||
|
||||
Void DisparityStereoVar::destroy()
|
||||
{
|
||||
if( m_pcDisparityFrame )
|
||||
delete m_pcDisparityFrame;
|
||||
m_pcDisparityFrame = NULL;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file DisparityStereoVar.h
|
||||
* \brief Measure the disparity between two images using the Stereo Var method (OpenCV)
|
||||
*/
|
||||
|
||||
#ifndef __DISPARITYSTEREOVAR_H__
|
||||
#define __DISPARITYSTEREOVAR_H__
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class DisparityStereoVar: public PlaYUVerModuleIf
|
||||
{
|
||||
private:
|
||||
PlaYUVerFrame* m_pcDisparityFrame;
|
||||
cv::StereoVar m_cStereoVar;
|
||||
public:
|
||||
DisparityStereoVar();
|
||||
virtual ~DisparityStereoVar()
|
||||
{
|
||||
}
|
||||
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputLeft, PlaYUVerFrame* InputRight );
|
||||
Void destroy();
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __DISPARITYSTEREOVAR_H__
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FilterComponent.cpp
|
||||
* \brief Filter component frame module
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "FilterComponent.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
FilterComponent::FilterComponent()
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
Void FilterComponent::createFilter( UInt uiWidth, UInt uiHeight )
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int Component )
|
||||
{
|
||||
Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV();
|
||||
Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
|
||||
memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[Component][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) );
|
||||
return m_pcFilteredFrame;
|
||||
}
|
||||
|
||||
Void FilterComponent::destroy()
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
|
||||
PlaYUVerModuleDefinition FilterComponentLumaDef = {
|
||||
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
|
||||
// Currently only support for frame
|
||||
"Filter Component", // Category (sub-menu)
|
||||
"Luma", // Name
|
||||
"Filter Y matrix of YUV frame", // Description
|
||||
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
APPLY_WHILE_PLAYING, // Apply module while playing
|
||||
};
|
||||
|
||||
FilterComponentLuma::FilterComponentLuma()
|
||||
{
|
||||
setModuleDefinition( FilterComponentLumaDef );
|
||||
}
|
||||
|
||||
Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
createFilter( InputFrame->getWidth(), InputFrame->getHeight() );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterComponentLuma::process( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
return filterComponent( InputFrame, LUMA );
|
||||
}
|
||||
|
||||
PlaYUVerModuleDefinition FilterComponentCbDef = {
|
||||
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
|
||||
// Currently only support for frame
|
||||
"Filter Component", // Category (sub-menu)
|
||||
"Chroma U", // Name
|
||||
"Filter Y matrix of YUV frame", // Description
|
||||
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
APPLY_WHILE_PLAYING, // Apply module while playing
|
||||
};
|
||||
|
||||
FilterComponentChromaU::FilterComponentChromaU()
|
||||
{
|
||||
setModuleDefinition( FilterComponentCbDef );
|
||||
}
|
||||
|
||||
Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
return filterComponent( InputFrame, CHROMA_U );
|
||||
}
|
||||
|
||||
PlaYUVerModuleDefinition FilterComponentCrDef = {
|
||||
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
|
||||
// Currently only support for frame
|
||||
"Filter Component", // Category (sub-menu)
|
||||
"Chroma R", // Name
|
||||
"Filter Y matrix of YUV frame", // Description
|
||||
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
APPLY_WHILE_PLAYING, // Apply module while playing
|
||||
};
|
||||
|
||||
FilterComponentChromaV::FilterComponentChromaV()
|
||||
{
|
||||
setModuleDefinition( FilterComponentCrDef );
|
||||
}
|
||||
|
||||
Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterComponentChromaV::process( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
return filterComponent( InputFrame, CHROMA_V );
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FilterComponent.h
|
||||
* \brief Filter component frame module
|
||||
*/
|
||||
|
||||
#ifndef __FILTERCOMPONENT_H__
|
||||
#define __FILTERCOMPONENT_H__
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class FilterComponent
|
||||
{
|
||||
private:
|
||||
PlaYUVerFrame* m_pcFilteredFrame;
|
||||
public:
|
||||
FilterComponent();
|
||||
virtual ~FilterComponent()
|
||||
{
|
||||
}
|
||||
Void createFilter( UInt uiWidth, UInt uiHeight );
|
||||
PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component );
|
||||
Void destroy();
|
||||
};
|
||||
|
||||
class FilterComponentLuma: public FilterComponent, public PlaYUVerModuleIf
|
||||
{
|
||||
public:
|
||||
FilterComponentLuma();
|
||||
virtual ~FilterComponentLuma()
|
||||
{
|
||||
}
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
|
||||
};
|
||||
|
||||
class FilterComponentChromaU: public FilterComponent, public PlaYUVerModuleIf
|
||||
{
|
||||
public:
|
||||
FilterComponentChromaU();
|
||||
virtual ~FilterComponentChromaU()
|
||||
{
|
||||
}
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
|
||||
};
|
||||
|
||||
class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf
|
||||
{
|
||||
public:
|
||||
FilterComponentChromaV();
|
||||
virtual ~FilterComponentChromaV()
|
||||
{
|
||||
}
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __FILTERFRAME_H__
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FrameDifference.cpp
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "FrameDifference.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
static PlaYUVerModuleDefinition FrameDifferenceDef =
|
||||
{
|
||||
FRAME_PROCESSING_MODULE,
|
||||
"Measurements",
|
||||
"AbsoluteFrameDifference",
|
||||
"Measure the difference between two images (Y plane), e. g., abs( Y1 - Y2 )",
|
||||
MODULE_REQUIRES_TWO_FRAMES,
|
||||
MODULE_REQUIRES_NEW_WINDOW,
|
||||
APPLY_WHILE_PLAYING,
|
||||
};
|
||||
|
||||
FrameDifference::FrameDifference()
|
||||
{
|
||||
m_pcFrameDifference = NULL;
|
||||
setModuleDefinition( FrameDifferenceDef );
|
||||
}
|
||||
|
||||
Void FrameDifference::create( PlaYUVerFrame* Input )
|
||||
{
|
||||
m_pcFrameDifference = new PlaYUVerFrame( Input->getWidth(), Input->getHeight(), PlaYUVerFrame::GRAY );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 )
|
||||
{
|
||||
Pel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0];
|
||||
Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0];
|
||||
Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0];
|
||||
Int aux_pel_1, aux_pel_2;
|
||||
|
||||
for( UInt y = 0; y < m_pcFrameDifference->getHeight(); y++ )
|
||||
for( UInt x = 0; x < m_pcFrameDifference->getWidth(); x++ )
|
||||
{
|
||||
aux_pel_1 = *pInput1PelYUV++;
|
||||
aux_pel_2 = *pInput2PelYUV++;
|
||||
*pOutputPelYUV++ = abs( aux_pel_1 - aux_pel_2 );
|
||||
}
|
||||
return m_pcFrameDifference;
|
||||
}
|
||||
|
||||
Void FrameDifference::destroy()
|
||||
{
|
||||
if( m_pcFrameDifference )
|
||||
delete m_pcFrameDifference;
|
||||
m_pcFrameDifference = NULL;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FrameDifference.h
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#ifndef __FRAMEDIFFERENCE_H__
|
||||
#define __FRAMEDIFFERENCE_H__
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class FrameDifference: public PlaYUVerModuleIf
|
||||
{
|
||||
private:
|
||||
PlaYUVerFrame* m_pcFrameDifference;
|
||||
|
||||
public:
|
||||
FrameDifference();
|
||||
virtual ~FrameDifference()
|
||||
{
|
||||
}
|
||||
Void create( PlaYUVerFrame* Input );
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 );
|
||||
Void destroy();
|
||||
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __FRAMEDIFFERENCE_H__
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file MeasurePSNR.cpp
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "MeasurePSNR.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
static PlaYUVerModuleDefinition MeasurePSNRDef =
|
||||
{
|
||||
FRAME_MEASUREMENT_MODULE,
|
||||
"Quality",
|
||||
"PSNR Y",
|
||||
"Measure the PSNR between two images",
|
||||
MODULE_REQUIRES_TWO_FRAMES,
|
||||
MODULE_REQUIRES_SIDEBAR,
|
||||
APPLY_WHILE_PLAYING, };
|
||||
|
||||
MeasurePSNR::MeasurePSNR()
|
||||
{
|
||||
setModuleDefinition( MeasurePSNRDef );
|
||||
}
|
||||
|
||||
Void MeasurePSNR::create( PlaYUVerFrame* Org )
|
||||
{
|
||||
}
|
||||
|
||||
Double MeasurePSNR::getMSE( PlaYUVerFrame* Org, PlaYUVerFrame* Rec, Int component )
|
||||
{
|
||||
Pel* pInput1PelYUV = Org->getPelBufferYUV()[component][0];
|
||||
Pel* pInput2PelYUV = Rec->getPelBufferYUV()[component][0];
|
||||
|
||||
Int aux_pel_1, aux_pel_2;
|
||||
Int diff = 0;
|
||||
Double ssd = 0;
|
||||
|
||||
for( UInt y = 0; y < Org->getHeight(); y++ )
|
||||
for( UInt x = 0; x < Org->getWidth(); x++ )
|
||||
{
|
||||
aux_pel_1 = *pInput1PelYUV++;
|
||||
aux_pel_2 = *pInput2PelYUV++;
|
||||
diff = aux_pel_1 - aux_pel_2;
|
||||
ssd += ( Double )( diff * diff );
|
||||
}
|
||||
if( ssd == 0.0 )
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return ssd / ( Org->getWidth() * Org->getHeight() );
|
||||
}
|
||||
|
||||
Double MeasurePSNR::measure( PlaYUVerFrame* Org, PlaYUVerFrame* Rec )
|
||||
{
|
||||
Double psnrY = 100;
|
||||
Double mseY = MeasurePSNR::getMSE( Org, Rec, LUMA );
|
||||
|
||||
if( mseY != 0 )
|
||||
psnrY = 10 * log10( 65025 / mseY );
|
||||
|
||||
return psnrY;
|
||||
}
|
||||
|
||||
Void MeasurePSNR::destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file MeasurePSNR.h
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREPSNR_H__
|
||||
#define __MEASUREPSNR_H__
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class MeasurePSNR: public PlaYUVerModuleIf
|
||||
{
|
||||
private:
|
||||
public:
|
||||
MeasurePSNR();
|
||||
virtual ~MeasurePSNR()
|
||||
{
|
||||
}
|
||||
Void create( PlaYUVerFrame* );
|
||||
Double measure( PlaYUVerFrame*, PlaYUVerFrame* );
|
||||
Void destroy();
|
||||
|
||||
static Double getMSE( PlaYUVerFrame* Org, PlaYUVerFrame* Rec, Int component );
|
||||
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __MEASUREPSNR_H__
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file PlaYUVerModuleIf.h
|
||||
* \brief PlaYUVer modules interface
|
||||
*/
|
||||
|
||||
#ifndef __PLAYUVERMODULESIF_H__
|
||||
#define __PLAYUVERMODULESIF_H__
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerStream.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
#define REGISTER_MODULE(X) \
|
||||
{ \
|
||||
X *pMod = new X(); \
|
||||
appendModule( pMod ); \
|
||||
}
|
||||
|
||||
enum // Module type
|
||||
{
|
||||
FRAME_PROCESSING_MODULE,
|
||||
FRAME_MEASUREMENT_MODULE,
|
||||
};
|
||||
|
||||
#define APPLY_WHILE_PLAYING true
|
||||
#define MAX_NUMBER_FRAMES 3
|
||||
|
||||
enum // Number of frames
|
||||
{
|
||||
MODULE_REQUIRES_ONE_FRAME = 1,
|
||||
MODULE_REQUIRES_TWO_FRAMES = 2,
|
||||
MODULE_REQUIRES_THREE_FRAMES = 3,
|
||||
};
|
||||
|
||||
enum // Requirements
|
||||
{
|
||||
MODULE_REQUIRES_NOTHING = 0,
|
||||
MODULE_REQUIRES_NEW_WINDOW = 2,
|
||||
MODULE_REQUIRES_SIDEBAR = 4,
|
||||
MODULES_REQUIREMENTS_TOTAL,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Int m_iModuleType;
|
||||
const Char* m_pchModuleCategory;
|
||||
const Char* m_pchModuleName;
|
||||
const Char* m_pchModuleTooltip;
|
||||
UInt m_uiNumberOfFrames;
|
||||
UInt m_uiModuleRequirements;
|
||||
Bool m_bApplyWhilePlaying;
|
||||
} PlaYUVerModuleDefinition;
|
||||
|
||||
class PlaYUVerModuleIf
|
||||
{
|
||||
public:
|
||||
|
||||
Int m_iModuleType;
|
||||
const Char* m_pchModuleCategory;
|
||||
const Char* m_pchModuleName;
|
||||
const Char* m_pchModuleTooltip;
|
||||
UInt m_uiNumberOfFrames;
|
||||
UInt m_uiModuleRequirements;
|
||||
Bool m_bApplyWhilePlaying;
|
||||
|
||||
PlaYUVerModuleDefinition m_cModuleDef;
|
||||
|
||||
PlaYUVerModuleIf() {}
|
||||
virtual ~PlaYUVerModuleIf() {}
|
||||
|
||||
virtual Void create() {}
|
||||
virtual Void create( PlaYUVerFrame* ) {}
|
||||
|
||||
virtual PlaYUVerFrame* process( PlaYUVerFrame* ) { return NULL; }
|
||||
virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame* ) { return NULL; }
|
||||
virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) { return NULL; }
|
||||
|
||||
virtual Double measure( PlaYUVerFrame* ) { return 0; }
|
||||
virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame* ) { return 0; }
|
||||
virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) { return 0; }
|
||||
|
||||
virtual Void destroy() { }
|
||||
|
||||
Void setModuleDefinition( PlaYUVerModuleDefinition def ) { m_cModuleDef = def; }
|
||||
PlaYUVerModuleDefinition getModuleDefinition() { return m_cModuleDef; }
|
||||
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __PLAYUVERMODULESIF_H__
|
||||
|
||||
Reference in new issue
Block a user