Merge lot of cool stuff in master

Make it stable and release it
This commit is contained in:
jfmcarreira committed 2015-01-17 03:52:19 +00:00
1 parent 3e6b04e983
commit 58a0b11c8f
69 files changed
+1854 -2487

No files matched your search

+11 -14
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -27,21 +27,18 @@
namespace plaYUVer
{
static PlaYUVerModuleDefinition AbsoluteFrameDifferenceDef =
{
FRAME_PROCESSING_MODULE,
"Measurements",
"AbsoluteFrameDifference",
"Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )",
MODULE_REQUIRES_TWO_FRAMES,
MODULE_REQUIRES_NEW_WINDOW,
APPLY_WHILE_PLAYING,
};
AbsoluteFrameDifference::AbsoluteFrameDifference()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Measurements";
m_pchModuleName = "AbsoluteFrameDifference";
m_pchModuleTooltip = "Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )";
m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW;
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING;
m_pcFrameDifference = NULL;
setModuleDefinition( AbsoluteFrameDifferenceDef );
}
Void AbsoluteFrameDifference::create( PlaYUVerFrame* Input )
+4 -2
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -34,6 +34,8 @@ namespace plaYUVer
class AbsoluteFrameDifference: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( AbsoluteFrameDifference )
private:
PlaYUVerFrame* m_pcFrameDifference;
+14 -12
View File
@@ -2,7 +2,11 @@
### CMakeLists for playuver modules component
###
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
set(plaYUver_Mod_SRCS
PlaYUVerModuleFactory.cpp
)
MACRO(ADD_MODULE name file )
set(__modulename "Module${name}")
@@ -18,15 +22,6 @@ MACRO(ADD_MODULE name file )
ENDMACRO()
#
# 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" )
@@ -35,13 +30,20 @@ file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "// This files add
#
# Modules List
#
INCLUDE( ModulesList.cmake )
ADD_MODULE( FilterComponentLuma "FilterComponent" )
ADD_MODULE( FilterComponentChromaU "FilterComponent" )
ADD_MODULE( FilterComponentChromaV "FilterComponent" )
ADD_MODULE( FrameDifference "FrameDifference" )
ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" )
ADD_MODULE( LumaAverage "LumaAverage" )
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} )
+3 -14
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -29,19 +29,9 @@
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()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Disparity";
m_pchModuleName = "StereoVar";
@@ -50,7 +40,6 @@ DisparityStereoVar::DisparityStereoVar()
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
+4 -2
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -36,6 +36,8 @@ namespace plaYUVer
class DisparityStereoVar: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( DisparityStereoVar )
private:
PlaYUVerFrame* m_pcDisparityFrame;
cv::StereoVar m_cStereoVar;
+32 -46
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -28,18 +28,18 @@
namespace plaYUVer
{
FilterComponent::FilterComponent()
FilterComponentModule::FilterComponentModule()
{
m_pcFilteredFrame = NULL;
}
Void FilterComponent::createFilter( UInt uiWidth, UInt uiHeight )
Void FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight )
{
m_pcFilteredFrame = NULL;
m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY );
}
PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int Component )
PlaYUVerFrame* FilterComponentModule::filterComponent( PlaYUVerFrame* InputFrame, Int Component )
{
Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV();
Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
@@ -47,29 +47,25 @@ PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int
return m_pcFilteredFrame;
}
Void FilterComponent::destroy()
Void FilterComponentModule::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 );
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence.
// Currently only support for frame
m_pchModuleCategory = "Filter Component"; // Category (sub-menu)
m_pchModuleName = "Luma"; // Name
m_pchModuleTooltip = "Filter Y matrix of YUV frame"; // Description
m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; // Module requirements (check PlaYUVerModulesIf.h).
// Several requirements should be "or" between each others.
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; // Apply module while playing
}
Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame )
@@ -82,21 +78,16 @@ 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 );
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Filter Component";
m_pchModuleName = "Chroma U";
m_pchModuleTooltip = "Filter U matrix of YUV frame";
m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME;
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING;
m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING;
}
Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame )
@@ -109,21 +100,16 @@ 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 );
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Filter Component";
m_pchModuleName = "Chroma V";
m_pchModuleTooltip = "Filter V matrix of YUV frame";
m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME;
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING;
m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING;
}
Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame )
+15 -9
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -30,22 +30,26 @@
namespace plaYUVer
{
class FilterComponent
class FilterComponentModule: public PlaYUVerModuleIf
{
private:
PlaYUVerFrame* m_pcFilteredFrame;
public:
FilterComponent();
virtual ~FilterComponent()
FilterComponentModule();
virtual ~FilterComponentModule()
{
}
Void create( PlaYUVerFrame* ) = 0;
PlaYUVerFrame* process( PlaYUVerFrame* ) = 0;
Void destroy();
Void createFilter( UInt uiWidth, UInt uiHeight );
PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component );
Void destroy();
};
class FilterComponentLuma: public FilterComponent, public PlaYUVerModuleIf
class FilterComponentLuma: public FilterComponentModule
{
REGISTER_CLASS_FACTORY( FilterComponentLuma )
public:
FilterComponentLuma();
virtual ~FilterComponentLuma()
@@ -55,8 +59,9 @@ public:
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
};
class FilterComponentChromaU: public FilterComponent, public PlaYUVerModuleIf
class FilterComponentChromaU: public FilterComponentModule
{
REGISTER_CLASS_FACTORY( FilterComponentChromaU )
public:
FilterComponentChromaU();
virtual ~FilterComponentChromaU()
@@ -66,8 +71,9 @@ public:
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
};
class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf
class FilterComponentChromaV: public FilterComponentModule
{
REGISTER_CLASS_FACTORY( FilterComponentChromaV )
public:
FilterComponentChromaV();
virtual ~FilterComponentChromaV()
+11 -14
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -28,21 +28,18 @@
namespace plaYUVer
{
static PlaYUVerModuleDefinition FrameDifferenceDef =
{
FRAME_PROCESSING_MODULE,
"Measurements",
"FrameDifference",
"Measure the difference between two images (Y plane), Y1 - Y2, with max absolute diff of 128",
MODULE_REQUIRES_TWO_FRAMES,
MODULE_REQUIRES_NEW_WINDOW,
APPLY_WHILE_PLAYING,
};
FrameDifference::FrameDifference()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Measurements";
m_pchModuleName = "FrameDifference";
m_pchModuleTooltip = "Measure the difference between two images (Y plane), Y1 - Y2, with max absolute diff of 128";
m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW;
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING;
m_pcFrameDifference = NULL;
setModuleDefinition( FrameDifferenceDef );
}
Void FrameDifference::create( PlaYUVerFrame* Input )
+4 -2
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -34,6 +34,8 @@ namespace plaYUVer
class FrameDifference: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FrameDifference )
private:
PlaYUVerFrame* m_pcFrameDifference;
+64
View File
@@ -0,0 +1,64 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 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 LumaAverage.cpp
* \brief Luma frame average
*/
#include "LumaAverage.h"
namespace plaYUVer
{
LumaAverage::LumaAverage()
{
/* Module Definition */
m_iModuleType = FRAME_MEASUREMENT_MODULE;
m_pchModuleCategory = "Measurements";
m_pchModuleName = "Luma Average";
m_pchModuleTooltip = "Measure the average of luma component";
m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME;
m_uiModuleRequirements = MODULE_REQUIRES_SIDEBAR;
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING;
}
Void LumaAverage::create( PlaYUVerFrame* frame )
{
}
Double LumaAverage::measure( PlaYUVerFrame* frame )
{
Double average = 0;
Pel* pPel = frame->getPelBufferYUV()[0][0];
for( UInt y = 0; y < frame->getHeight(); y++ )
for( UInt x = 0; x < frame->getWidth(); x++ )
{
average += *pPel;
}
return average / Double( frame->getHeight() * frame->getWidth() );
}
Void LumaAverage::destroy()
{
}
} // NAMESPACE
+14 -13
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -18,35 +18,36 @@
*/
/**
* \file MeasurePSNR.h
* \brief Frame Difference module
* \file LumaAverage.h
* \brief Luma frame average
*/
#ifndef __MEASUREPSNR_H__
#define __MEASUREPSNR_H__
#ifndef __LUMAAVERAGE_H__
#define __LUMAAVERAGE_H__
#include "PlaYUVerModuleIf.h"
namespace plaYUVer
{
class MeasurePSNR: public PlaYUVerModuleIf
class LumaAverage: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( LumaAverage )
private:
public:
MeasurePSNR();
virtual ~MeasurePSNR()
LumaAverage();
virtual ~LumaAverage()
{
}
Void create( PlaYUVerFrame* );
Double measure( PlaYUVerFrame*, PlaYUVerFrame* );
Double measure( PlaYUVerFrame* );
Void destroy();
static Double getMSE( PlaYUVerFrame* Org, PlaYUVerFrame* Rec, Int component );
};
} // NAMESPACE
#endif // __MEASUREPSNR_H__
#endif // __LUMAAVERAGE_H__
-90
View File
@@ -1,90 +0,0 @@
/* 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 "MeasurePSNR.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
-13
View File
@@ -1,13 +0,0 @@
###
### Modules List
###
ADD_MODULE( FilterComponentLuma "FilterComponent" )
ADD_MODULE( FilterComponentChromaU "FilterComponent" )
ADD_MODULE( FilterComponentChromaV "FilterComponent" )
ADD_MODULE( FrameDifference "FrameDifference" )
ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" )
#ADD_MODULE( MeasurePSNR "MeasurePSNR" )
IF( USE_OPENCV )
ADD_MODULE( DisparityStereoVar "DisparityStereoVar" )
ENDIF()
+71
View File
@@ -0,0 +1,71 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 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 PlaYUVerModuleFactory.cpp
* \brief PlaYUVer modules factory
*/
#include <functional>
#include <cstring>
#include "PlaYUVerModuleFactory.h"
#include "ModulesListHeader.h"
namespace plaYUVer
{
PlaYUVerModuleFactory::PlaYUVerModuleFactory()
{
Register( "FilterComponentLuma", &FilterComponentLuma::Create );
Register( "FilterComponentChromaU", &FilterComponentChromaU::Create );
Register( "FilterComponentChromaV", &FilterComponentChromaV::Create );
Register( "FrameDifference", &FrameDifference::Create );
Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create );
Register( "LumaAverage", &LumaAverage::Create );
#ifdef USE_OPENCV
Register( "DisparityStereoVar", &DisparityStereoVar::Create );
#endif
}
PlaYUVerModuleFactory::~PlaYUVerModuleFactory()
{
m_FactoryMap.clear();
}
Void PlaYUVerModuleFactory::Register( const char* moduleName, CreateModuleFn pfnCreate )
{
m_FactoryMap[moduleName] = pfnCreate;
}
PlaYUVerModuleIf *PlaYUVerModuleFactory::CreateModule( const char* moduleName )
{
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
for( ; it != PlaYUVerModuleFactoryMap.end(); ++it)
{
if( !strcmp( it->first, moduleName ) )
{
return it->second();
}
}
return NULL;
}
} // NAMESPACE
+69
View File
@@ -0,0 +1,69 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 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 PlaYUVerModuleFactory.h
* \brief PlaYUVer modules factory
*/
#ifndef __PLAYUVERMODULESFACTORY_H__
#define __PLAYUVERMODULESFACTORY_H__
#include <functional>
#include "PlaYUVerModuleIf.h"
namespace plaYUVer
{
#define REGISTER_MODULE(X) Register( "X", &(X::Create) );
typedef PlaYUVerModuleIf* (*CreateModuleFn)( void );
typedef std::map<const char *, CreateModuleFn> PlaYUVerModuleFactoryMap;
// Factory for creating instances of IAnimal
class PlaYUVerModuleFactory
{
private:
PlaYUVerModuleFactory();
PlaYUVerModuleFactory &operator=( const PlaYUVerModuleFactory & ) { return *this; }
PlaYUVerModuleFactoryMap m_FactoryMap;
public:
~PlaYUVerModuleFactory();
static PlaYUVerModuleFactory *Get()
{
static PlaYUVerModuleFactory instance;
return &instance;
}
Void Register( const char* moduleName, CreateModuleFn pfnCreate );
PlaYUVerModuleIf *CreateModule( const char *animalName );
PlaYUVerModuleFactoryMap& getMap(){ return m_FactoryMap; }
};
//// typedef to make it easier to set up our factory
//typedef PlaYUVerModuleIf *PlaYUVerModuleMaker();
//// our global factory
//extern std::map<std::string, PlaYUVerModuleMaker *, std::less<std::string> > PlaYUVerModuleFactory;
}// NAMESPACE
#endif // __PLAYUVERMODULESFACTORY_H__
+9 -13
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
* Copyright (C) 2014-2015 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
@@ -32,11 +32,10 @@
namespace plaYUVer
{
#define REGISTER_MODULE(X) \
{ \
X *pMod = new X(); \
appendModule( pMod ); \
}
#define REGISTER_CLASS_FACTORY(X) \
public: \
static PlaYUVerModuleIf* Create() { return new X(); } \
void Delete() { delete this; }
enum // Module type
{
@@ -85,11 +84,11 @@ public:
UInt m_uiModuleRequirements;
Bool m_bApplyWhilePlaying;
PlaYUVerModuleDefinition m_cModuleDef;
PlaYUVerModuleIf() {}
virtual ~PlaYUVerModuleIf() {}
virtual void Delete() = 0;
virtual Void create() {}
virtual Void create( PlaYUVerFrame* ) {}
@@ -101,10 +100,7 @@ public:
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; }
virtual Void destroy() = 0;
};