Add support for module operation (only measurement modules are supported)
This commit is contained in:
1 parent
db4b6fa1a1
commit
c3ec5268db
4 files changed
+163
-10
No files matched your search
+99
-7
@@ -23,6 +23,8 @@
|
||||
*/
|
||||
|
||||
#include "PlaYUVerTools.h"
|
||||
#include "modules/PlaYUVerModuleIf.h"
|
||||
#include "modules/PlaYUVerModuleFactory.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
@@ -31,6 +33,10 @@ PlaYUVerTools::PlaYUVerTools()
|
||||
{
|
||||
m_uiOperation = INVALID_OPERATION;
|
||||
m_uiNumberOfFrames = -1;
|
||||
|
||||
m_uiQualityMetric = -1;
|
||||
|
||||
m_pcCurrModuleIf = NULL;
|
||||
}
|
||||
|
||||
PlaYUVerTools::~PlaYUVerTools()
|
||||
@@ -52,7 +58,7 @@ Int PlaYUVerTools::openInputs()
|
||||
*/
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "input" ) )
|
||||
{
|
||||
std::string resolutionString("");
|
||||
std::string resolutionString( "" );
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "size" ) )
|
||||
{
|
||||
resolutionString = m_cCommandLineParser.getOptionsMap()["size"].as<std::string>();
|
||||
@@ -116,7 +122,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
Int iRet = 0;
|
||||
|
||||
m_cCommandLineParser.Config( argc, argv );
|
||||
if( ( iRet = m_cCommandLineParser.ParseToolsArgs() ) > 0 )
|
||||
if( ( iRet = m_cCommandLineParser.parseToolsArgs() ) > 0 )
|
||||
{
|
||||
return iRet;
|
||||
}
|
||||
@@ -131,7 +137,6 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
*/
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "quality" ) )
|
||||
{
|
||||
m_uiOperationIndex = -1;
|
||||
std::string qualityMetric = m_cCommandLineParser.getOptionsMap()["quality"].as<std::string>();
|
||||
if( m_apcInputStreams.size() != 2 )
|
||||
{
|
||||
@@ -142,16 +147,17 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
{
|
||||
if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) )
|
||||
{
|
||||
m_uiOperationIndex = i;
|
||||
m_uiQualityMetric = i;
|
||||
}
|
||||
}
|
||||
if( m_uiOperationIndex == -1 )
|
||||
if( m_uiQualityMetric == -1 )
|
||||
{
|
||||
printf( "Invalid quality metric! " );
|
||||
return 2;
|
||||
}
|
||||
m_uiOperation = QUALITY_OPERATION;
|
||||
m_fpProcess = &PlaYUVerTools::QualityOperation;
|
||||
printf( "PlaYUVer Quality\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +165,30 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
*/
|
||||
if( m_cCommandLineParser.getOptionsMap().count( "module" ) )
|
||||
{
|
||||
std::string moduleName = m_cCommandLineParser.getOptionsMap()["module"].as<std::string>();
|
||||
|
||||
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
|
||||
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
|
||||
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ )
|
||||
{
|
||||
if( strcmp( it->first, moduleName.c_str() ) == 0 )
|
||||
{
|
||||
m_pcCurrModuleIf = it->second();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_apcInputStreams.size() != m_pcCurrModuleIf->m_uiNumberOfFrames )
|
||||
{
|
||||
printf( "Invalid number of inputs! " );
|
||||
return 2;
|
||||
}
|
||||
|
||||
m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() );
|
||||
|
||||
m_uiOperation = MODULE_OPERATION;
|
||||
m_fpProcess = &PlaYUVerTools::ModuleOperation;
|
||||
printf( "PlaYUVer Module\n" );
|
||||
}
|
||||
|
||||
if( m_uiOperation == INVALID_OPERATION )
|
||||
@@ -188,7 +217,7 @@ Int PlaYUVerTools::QualityOperation()
|
||||
Double adAverageQuality[m_apcInputStreams.size() - 1][m_uiNumberOfComponents];
|
||||
Double dQuality;
|
||||
|
||||
printf( " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiOperationIndex].c_str() );
|
||||
printf( " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str() );
|
||||
|
||||
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
|
||||
{
|
||||
@@ -209,7 +238,7 @@ Int PlaYUVerTools::QualityOperation()
|
||||
printf( " " );
|
||||
for( UInt c = 0; c < m_uiNumberOfComponents; c++ )
|
||||
{
|
||||
dQuality = apcCurrFrame[s]->getQuality( m_uiOperationIndex, apcCurrFrame[0], c );
|
||||
dQuality = apcCurrFrame[s]->getQuality( m_uiQualityMetric, apcCurrFrame[0], c );
|
||||
adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * Double( frame ) + dQuality ) / Double( frame + 1 );
|
||||
printf( " %5.3f", dQuality );
|
||||
}
|
||||
@@ -237,4 +266,67 @@ Int PlaYUVerTools::QualityOperation()
|
||||
return 0;
|
||||
}
|
||||
|
||||
Int PlaYUVerTools::ModuleOperation()
|
||||
{
|
||||
printf( " Applying Module %s/%s ... \n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName );
|
||||
|
||||
PlaYUVerFrame* pcProcessedFrame = NULL;
|
||||
Double dMeasurementResult = 0.0;
|
||||
Double dAveragedMeasurementResult = 0;
|
||||
Bool abEOF[m_apcInputStreams.size()];
|
||||
|
||||
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
|
||||
{
|
||||
abEOF[s] = false;
|
||||
}
|
||||
|
||||
for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ )
|
||||
{
|
||||
|
||||
if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
switch( m_pcCurrModuleIf->m_uiNumberOfFrames )
|
||||
{
|
||||
case MODULE_REQUIRES_ONE_FRAME:
|
||||
pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame() );
|
||||
break;
|
||||
case MODULE_REQUIRES_TWO_FRAMES:
|
||||
pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
switch( m_pcCurrModuleIf->m_uiNumberOfFrames )
|
||||
{
|
||||
case MODULE_REQUIRES_ONE_FRAME:
|
||||
dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() );
|
||||
break;
|
||||
case MODULE_REQUIRES_TWO_FRAMES:
|
||||
dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() );
|
||||
break;
|
||||
}
|
||||
printf( " %3d %8.3f \n", frame, dMeasurementResult );
|
||||
dAveragedMeasurementResult = ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 );
|
||||
}
|
||||
|
||||
for( UInt s = 0; s < m_apcInputStreams.size(); s++ )
|
||||
{
|
||||
m_apcInputStreams[s]->setNextFrame();
|
||||
if( !abEOF[s] )
|
||||
{
|
||||
m_apcInputStreams[s]->readFrame();
|
||||
abEOF[s] = m_apcInputStreams[s]->checkErrors( PlaYUVerStream::LAST_FRAME );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
printf( "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
Reference in new issue
Block a user