Initial definition of a module to measure PSNR and to display results on a dock
This commit is contained in:
1 parent
3a09163a38
commit
4fc7218c79
6 files changed
+54
-30
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
ADD_MODULE( FilterFrame "FilterFrame.cpp" )
|
||||
ADD_MODULE( FrameDifference "FrameDifference.cpp" )
|
||||
#ADD_MODULE( MeasurePSNR "MeasurePSNR.cpp" )
|
||||
ADD_MODULE( MeasurePSNR "MeasurePSNR.cpp" )
|
||||
|
||||
IF( USE_OPENCV )
|
||||
ADD_MODULE( DisparityStereoVar "DisparityStereoVar.cpp" )
|
||||
|
||||
@@ -106,7 +106,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf
|
||||
QString windowName;
|
||||
|
||||
UInt numberOfFrames = pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames;
|
||||
if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME )
|
||||
if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows
|
||||
{
|
||||
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMdiArea, numberOfFrames );
|
||||
if( dialogWindowsSelection.exec() == QDialog::Accepted )
|
||||
@@ -141,18 +141,30 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf
|
||||
windowName.append( ">" );
|
||||
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
|
||||
if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
|
||||
if( pcCurrModuleIf->m_cModuleDef.m_iModuleType == FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
interfaceChild = new SubWindowHandle( m_pcParent, true );
|
||||
interfaceChild->setWindowName( windowName );
|
||||
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent,
|
||||
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild;
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf );
|
||||
if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
|
||||
{
|
||||
interfaceChild = new SubWindowHandle( m_pcParent, true );
|
||||
interfaceChild->setWindowName( windowName );
|
||||
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent,
|
||||
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild;
|
||||
pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf );
|
||||
}
|
||||
}
|
||||
if( pcCurrModuleIf->m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
if( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_SIDEBAR )
|
||||
{
|
||||
pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent );
|
||||
}
|
||||
}
|
||||
|
||||
// Create Module
|
||||
pcCurrModuleIf->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() );
|
||||
|
||||
// Associate module with subwindows
|
||||
for( UInt i = 0; i < numberOfFrames; i++ )
|
||||
{
|
||||
pcCurrModuleIf->m_pcSubWindow[i]->enableModule( pcCurrModuleIf );
|
||||
@@ -251,7 +263,6 @@ Void ModulesHandle::openModuleIfStream( PlaYUVerModuleIf *pcCurrModuleIf )
|
||||
UInt Width = 0, Height = 0, FrameRate = 30;
|
||||
Int InputFormat = -1;
|
||||
|
||||
|
||||
QString supported = tr( "Supported Files (" );
|
||||
QStringList formatsList;
|
||||
QStringList formatsExt = PlaYUVerStream::supportedWriteFormatsExt();
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace plaYUVer
|
||||
PlaYUVerModuleIf::PlaYUVerModuleIf() :
|
||||
m_pcAction( NULL ),
|
||||
m_pcDisplaySubWindow( NULL ),
|
||||
m_pcModuleDock( NULL ),
|
||||
m_pcModuleStream( NULL ),
|
||||
m_pcProcessedFrame( NULL )
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerStream.h"
|
||||
#include "ModuleHandleDock.h"
|
||||
|
||||
class QAction;
|
||||
|
||||
@@ -40,7 +41,6 @@ namespace plaYUVer
|
||||
enum // Module type
|
||||
{
|
||||
FRAME_PROCESSING_MODULE,
|
||||
VIDEO_PROCESSING_MODULE,
|
||||
FRAME_MEASUREMENT_MODULE,
|
||||
};
|
||||
|
||||
@@ -96,7 +96,10 @@ class PlaYUVerModuleIf
|
||||
private:
|
||||
QAction* m_pcAction;
|
||||
SubWindowHandle* m_pcSubWindow[MAX_NUMBER_FRAMES];
|
||||
|
||||
SubWindowHandle* m_pcDisplaySubWindow;
|
||||
ModuleHandleDock* m_pcModuleDock;
|
||||
|
||||
PlaYUVerModuleDefinition m_cModuleDef;
|
||||
|
||||
PlaYUVerStream* m_pcModuleStream;
|
||||
@@ -126,11 +129,14 @@ public:
|
||||
virtual Void create() {}
|
||||
virtual Void create( PlaYUVerFrame* ) {}
|
||||
|
||||
virtual Void process() {}
|
||||
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; }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
/**
|
||||
* \file MeasurePSNR.cpp
|
||||
* \brief Measure PSNR module
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
@@ -37,32 +37,41 @@ static PlaYUVerModuleDefinition MeasurePSNRDef =
|
||||
"PSNR",
|
||||
"Measure the PSNR between two images",
|
||||
MODULE_REQUIRES_TWO_FRAMES,
|
||||
MODULE_REQUIRES_NEW_WINDOW,
|
||||
MODULE_REQUIRES_SIDEBAR,
|
||||
APPLY_WHILE_PLAYING,
|
||||
};
|
||||
|
||||
MeasurePSNR::MeasurePSNR()
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
setModuleDefinition( MeasurePSNRDef );
|
||||
}
|
||||
|
||||
Void MeasurePSNR::create( PlaYUVerFrame* InputFrame )
|
||||
Void MeasurePSNR::create( PlaYUVerFrame* Org )
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* MeasurePSNR::process( PlaYUVerFrame* InputFrame )
|
||||
Double MeasurePSNR::measure( PlaYUVerFrame* Org, PlaYUVerFrame* Rec )
|
||||
{
|
||||
return m_pcFilteredFrame;
|
||||
Pel* pInput1PelYUV = Org->getPelBufferYUV()[0][0];
|
||||
Pel* pInput2PelYUV = Rec->getPelBufferYUV()[0][0];
|
||||
|
||||
Int aux_pel_1, aux_pel_2;
|
||||
Double diff = 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 += abs( aux_pel_1 - aux_pel_2 );
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
Void MeasurePSNR::destroy()
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = NULL;
|
||||
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -19,17 +19,16 @@
|
||||
|
||||
/**
|
||||
* \file MeasurePSNR.h
|
||||
* \brief Measure PSNR module
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREPSNR_H__
|
||||
#define __MEASUREPSNR_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "TypeDef.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
@@ -47,10 +46,8 @@ public:
|
||||
virtual ~MeasurePSNR()
|
||||
{
|
||||
}
|
||||
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
|
||||
Void create( PlaYUVerFrame* );
|
||||
Double measure( PlaYUVerFrame*, PlaYUVerFrame* );
|
||||
Void destroy();
|
||||
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user