Add module to reverse transform from video to cube map projection
Add module and fix bug in CalypFrame and add new feature to modules API 3
This commit is contained in:
9 files changed
+196
-34
No files matched your search
+2
-2
@@ -119,7 +119,7 @@ public:
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
*/
|
||||
void init( unsigned int width, unsigned int height, int pel_format, int bitsPixel )
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel )
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bHasRGBPel = false;
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
* \brief Constructors
|
||||
*/
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, int bitsPixel )
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel )
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel );
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public:
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, int bitsPixel = 8 );
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
|
||||
+8
-2
@@ -125,6 +125,7 @@ public:
|
||||
unsigned int m_uiModuleRequirements;
|
||||
|
||||
unsigned int m_iFrameBufferCount;
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
|
||||
@@ -133,6 +134,8 @@ public:
|
||||
m_iModuleAPI = CLP_MODULE_API_1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_pchModuleLongName = NULL;
|
||||
m_pcOutputFrame = NULL;
|
||||
m_iFrameBufferCount = 0;
|
||||
}
|
||||
virtual ~CalypModuleIf() {}
|
||||
virtual void Delete() = 0;
|
||||
@@ -157,8 +160,11 @@ public:
|
||||
virtual double measure( std::vector<CalypFrame*> ) { return 0; }
|
||||
virtual bool keyPressed( enum Module_Key_Supported ) { return false; }
|
||||
virtual ClpString moduleInfo() { return ClpString(); }
|
||||
|
||||
virtual bool needFrame() { return true; };
|
||||
/**
|
||||
* Module API version 3
|
||||
*/
|
||||
virtual CalypFrame* getProcessedFrame() { return m_pcOutputFrame; }
|
||||
virtual bool needFrame() { return m_iFrameBufferCount == 0? true : false; };
|
||||
virtual bool flush()
|
||||
{
|
||||
m_iFrameBufferCount = 0;
|
||||
|
||||
@@ -31,6 +31,8 @@ ADD_MODULE( LumaAverage "LumaAverage" )
|
||||
ADD_MODULE( WeightedPSNR "WeightedPSNR" )
|
||||
ADD_MODULE( HEVCIntraPrediction "HEVCIntraPrediction" )
|
||||
ADD_MODULE( ThreeSixtySpatialtoTemporal "ThreeSixtySpatialtoTemporal" )
|
||||
ADD_MODULE( ThreeSixtyTemporaltoSpatial "ThreeSixtyTemporaltoSpatial" )
|
||||
|
||||
|
||||
ADD_MODULE_USE_OPENCV( MeasureOpticalFlowDualTVL1 "MeasureOpticalFlowDualTVL1" VERSION 2.4.13.0 MODULES video )
|
||||
ADD_MODULE_USE_OPENCV( DisparityStereoBM "DisparityStereoBM" VERSION 2.4.13.0 MODULES calib3d )
|
||||
|
||||
@@ -36,19 +36,17 @@ ThreeSixtySpatialtoTemporal::ThreeSixtySpatialtoTemporal()
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY;
|
||||
|
||||
m_pcFrameProcessed = NULL;
|
||||
|
||||
uiFacesX = 3;
|
||||
uiFacesY = 2;
|
||||
m_uiFacesX = 3;
|
||||
m_uiFacesY = 2;
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
bool ThreeSixtySpatialtoTemporal::flush()
|
||||
{
|
||||
m_iFrameBufferCount = 0;
|
||||
uiCopyX = 0;
|
||||
uiCopyY = 0;
|
||||
CalypModuleIf::flush();
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY = 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -68,10 +66,10 @@ bool ThreeSixtySpatialtoTemporal::create( std::vector<CalypFrame*> apcFrameList
|
||||
unsigned int iWidth;
|
||||
unsigned int iHeight;
|
||||
|
||||
iWidth = apcFrameList[0]->getWidth() / uiFacesX;
|
||||
iHeight = apcFrameList[0]->getHeight() / uiFacesY;
|
||||
iWidth = apcFrameList[0]->getWidth() / m_uiFacesX;
|
||||
iHeight = apcFrameList[0]->getHeight() / m_uiFacesY;
|
||||
|
||||
m_pcFrameProcessed = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
m_pcOutputFrame = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
|
||||
m_pcTmpFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(),
|
||||
@@ -86,30 +84,30 @@ CalypFrame* ThreeSixtySpatialtoTemporal::process( std::vector<CalypFrame*> apcFr
|
||||
if( m_iFrameBufferCount == 0 )
|
||||
{
|
||||
m_pcTmpFrame->copyFrom( apcFrameList[0] );
|
||||
uiCopyX = 0;
|
||||
uiCopyY = 0;
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY = 0;
|
||||
|
||||
m_iFrameBufferCount = uiFacesX * uiFacesY;
|
||||
m_iFrameBufferCount = m_uiFacesX * m_uiFacesY;
|
||||
}
|
||||
|
||||
m_pcFrameProcessed->copyFrom( m_pcTmpFrame, uiCopyX, uiCopyY );
|
||||
m_pcOutputFrame->copyFrom( m_pcTmpFrame, m_uiCopyX, m_uiCopyY );
|
||||
m_iFrameBufferCount--;
|
||||
|
||||
uiCopyX += m_pcFrameProcessed->getWidth();
|
||||
if( uiCopyX >= m_pcTmpFrame->getWidth() )
|
||||
m_uiCopyX += m_pcOutputFrame->getWidth();
|
||||
if( m_uiCopyX >= m_pcTmpFrame->getWidth() )
|
||||
{
|
||||
uiCopyX = 0;
|
||||
uiCopyY += m_pcFrameProcessed->getHeight();
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY += m_pcOutputFrame->getHeight();
|
||||
}
|
||||
|
||||
return m_pcFrameProcessed;
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void ThreeSixtySpatialtoTemporal::destroy()
|
||||
{
|
||||
if( m_pcFrameProcessed )
|
||||
delete m_pcFrameProcessed;
|
||||
m_pcFrameProcessed = NULL;
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
if( m_pcTmpFrame )
|
||||
delete m_pcTmpFrame;
|
||||
m_pcTmpFrame = NULL;
|
||||
|
||||
@@ -33,12 +33,11 @@ class ThreeSixtySpatialtoTemporal : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtySpatialtoTemporal )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrameProcessed;
|
||||
CalypFrame* m_pcTmpFrame;
|
||||
unsigned int uiFacesX;
|
||||
unsigned int uiFacesY;
|
||||
unsigned int uiCopyX;
|
||||
unsigned int uiCopyY;
|
||||
unsigned int m_uiFacesX;
|
||||
unsigned int m_uiFacesY;
|
||||
unsigned int m_uiCopyX;
|
||||
unsigned int m_uiCopyY;
|
||||
|
||||
public:
|
||||
ThreeSixtySpatialtoTemporal();
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 by Joao Carreira (jfmcarreira@gmail.com)
|
||||
* Luis Lucas (luisfrlucas@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 FrameRotate.cpp
|
||||
* \brief Frame Difference module
|
||||
*/
|
||||
|
||||
#include "ThreeSixtyTemporaltoSpatial.h"
|
||||
|
||||
ThreeSixtyTemporaltoSpatial::ThreeSixtyTemporaltoSpatial()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_3;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Temporal to Spatial";
|
||||
m_pchModuleName = "TemporaltoSpatial";
|
||||
m_pchModuleTooltip = "Convert 360 video from temporal frames to Cube Map Projection";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY;
|
||||
|
||||
m_uiFacesX = 3;
|
||||
m_uiFacesY = 2;
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
bool ThreeSixtyTemporaltoSpatial::flush()
|
||||
{
|
||||
CalypModuleIf::flush();
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY = 0;
|
||||
m_uiFacesCount = 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
bool ThreeSixtyTemporaltoSpatial::needFrame()
|
||||
{
|
||||
return CalypModuleIf::needFrame();
|
||||
};
|
||||
|
||||
bool ThreeSixtyTemporaltoSpatial::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
unsigned int iWidth;
|
||||
unsigned int iHeight;
|
||||
|
||||
iWidth = apcFrameList[0]->getWidth() * m_uiFacesX;
|
||||
iHeight = apcFrameList[0]->getHeight() * m_uiFacesY;
|
||||
|
||||
m_pcOutputFrame = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
return true;
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyTemporaltoSpatial::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_3_BREAK_CONDITION_
|
||||
|
||||
m_pcOutputFrame->copyTo( apcFrameList[0], m_uiCopyX, m_uiCopyY );
|
||||
|
||||
m_uiCopyX += apcFrameList[0]->getWidth();
|
||||
if( m_uiCopyX >= m_pcOutputFrame->getWidth() )
|
||||
{
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY += apcFrameList[0]->getHeight();
|
||||
}
|
||||
if( ++m_uiFacesCount < (m_uiFacesX * m_uiFacesY) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY = 0;
|
||||
m_uiFacesCount = 0;
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void ThreeSixtyTemporaltoSpatial::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 by Joao Carreira (jfmcarreira@gmail.com)
|
||||
* Luis Lucas (luisfrlucas@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 FrameRotate.h
|
||||
* \brief Module to aapply a mask to an image
|
||||
*/
|
||||
|
||||
#ifndef __THREESIXTYTEMPORALTOSPATIAL_H__
|
||||
#define __THREESIXTYTEMPORALTOSPATIAL_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
class ThreeSixtyTemporaltoSpatial : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyTemporaltoSpatial )
|
||||
|
||||
private:
|
||||
unsigned int m_uiFacesX;
|
||||
unsigned int m_uiFacesY;
|
||||
unsigned int m_uiCopyX;
|
||||
unsigned int m_uiCopyY;
|
||||
unsigned int m_uiFacesCount;
|
||||
|
||||
public:
|
||||
ThreeSixtyTemporaltoSpatial();
|
||||
virtual ~ThreeSixtyTemporaltoSpatial() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
bool needFrame();
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
bool flush();
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __THREESIXTYTEMPORALTOSPATIAL_H__
|
||||
@@ -341,8 +341,12 @@ int CalypTools::Open( int argc, char* argv[] )
|
||||
CalypFrame* pcModFrame;
|
||||
if( m_pcCurrModuleIf->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
{
|
||||
pcModFrame = m_pcCurrModuleIf->process( apcFrameList );
|
||||
m_pcCurrModuleIf->flush();
|
||||
pcModFrame = m_pcCurrModuleIf->getProcessedFrame();
|
||||
if( !pcModFrame )
|
||||
{
|
||||
pcModFrame = m_pcCurrModuleIf->process( apcFrameList );
|
||||
m_pcCurrModuleIf->flush();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user