Author SHA1 Message Date
jfmcarreira dd49089309 Add new functions to stream modules 2018-11-21 21:22:33 +00:00
jfmcarreira 3489deda20 Changes to start implement stream modules 2018-10-18 21:59:36 +01:00
6 changed files with 179 additions and 52 deletions
+25 -25
View File
@@ -74,19 +74,19 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
bool bRet = false;
QApplication::setOverrideCursor( Qt::WaitCursor );
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
{
if( m_pcDisplaySubWindow )
{
m_pcDisplaySubWindow->setFillWindow( true );
}
else
{
m_pcSubWindow[0]->setFillWindow( true );
}
}
if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) )
{
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
{
if( m_pcDisplaySubWindow )
{
m_pcDisplaySubWindow->setFillWindow( true );
}
else
{
m_pcSubWindow[0]->setFillWindow( true );
}
}
#ifdef CALYP_THREADED_MODULES
if( !disableThreads )
{
@@ -123,27 +123,27 @@ void CalypAppModuleIf::run()
apcFrameList.push_back( m_pcSubWindow[i]->getCurrFrame() );
}
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_1 )
{
if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 )
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
{
m_pcProcessedFrame = m_pcModule->process( apcFrameList[0] );
}
else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
{
m_dMeasurementResult = m_pcModule->measure( apcFrameList[0] );
}
}
else if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 )
{
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
{
m_pcProcessedFrame = m_pcModule->process( apcFrameList );
}
else
{
m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() );
}
}
else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
{
if( m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 )
else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
{
m_dMeasurementResult = m_pcModule->measure( apcFrameList );
}
else
{
m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() );
}
}
else
{
+38 -25
View File
@@ -325,9 +325,9 @@ void ModulesHandle::activateModule()
}
}
}
// Check for same fmt in more than one frame modules
if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_1 )
{
// Check for same fmt in more than one frame modules
for( int i = 1; i < videoSubWindowList.size(); i++ )
{
if( !videoSubWindowList.at( i )->getCurrFrame()->haveSameFmt( videoSubWindowList.at( 0 )->getCurrFrame() ) )
@@ -369,28 +369,31 @@ void ModulesHandle::activateModule()
}
}
bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() | bTmpForceNewWindow;
bool bRequiresWindow = ( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_STREAM_PROCESSING_MODULE ) ||
( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) ||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() ||
bTmpForceNewWindow;
bool bRequiresDock = ( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE );
QString windowName;
VideoSubWindow* pcModuleSubWindow = NULL;
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
if( bRequiresWindow )
{
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
{
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
windowName.append( QStringLiteral( "Module " ) );
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
// connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
// SLOT( updateSelectionArea( QRect ) ) );
// connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
// SLOT( zoomToFactorAll( double, QPoint ) ) );
// connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
// SLOT( moveAllScrollBars( const QPoint ) ) );
}
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
windowName.append( QStringLiteral( "Module " ) );
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
// connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
// SLOT( updateSelectionArea( QRect ) ) );
// connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
// SLOT( zoomToFactorAll( double, QPoint ) ) );
// connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
// SLOT( moveAllScrollBars( const QPoint ) ) );
}
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
if( bRequiresDock )
{
pcCurrAppModuleIf->m_pcDisplaySubWindow = NULL;
pcCurrAppModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrAppModuleIf );
@@ -420,20 +423,30 @@ void ModulesHandle::activateModule()
}
}
std::vector<CalypStream*> apcStreamList;
for( int i = 0; i < videoSubWindowList.size(); i++ )
{
apcStreamList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrStream() );
}
std::vector<CalypFrame*> apcFrameList;
for( int i = 0; i < videoSubWindowList.size(); i++ )
{
apcFrameList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrFrame() );
}
// Create Module
bool moduleCreated = false;
if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 )
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_STREAM_PROCESSING_MODULE )
{
moduleCreated = pcCurrAppModuleIf->m_pcModule->create( apcStreamList );
}
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_2 )
{
std::vector<CalypFrame*> apcFrameList;
for( int i = 0; i < videoSubWindowList.size(); i++ )
{
apcFrameList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrFrame() );
}
moduleCreated = pcCurrAppModuleIf->m_pcModule->create( apcFrameList );
}
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == CLP_MODULE_API_1 )
{
pcCurrAppModuleIf->m_pcModule->create( pcCurrAppModuleIf->m_pcSubWindow[0]->getCurrFrame() );
pcCurrAppModuleIf->m_pcModule->create( apcFrameList[0] );
moduleCreated = true;
}
+6 -1
View File
@@ -36,6 +36,7 @@
#include "CalypFrame.h"
#include "CalypOptions.h"
#include "CalypStream.h"
#define REGISTER_CLASS_MAKER( X ) \
extern "C" CalypModuleIf* Maker() { return new X; }
@@ -70,6 +71,7 @@ enum Module_Type
{
CLP_FRAME_PROCESSING_MODULE,
CLP_FRAME_MEASUREMENT_MODULE,
CLP_STREAM_PROCESSING_MODULE,
CLP_MODULE_TYPE_MAX = 255,
};
@@ -144,11 +146,14 @@ public:
/**
* Module API version 2
*/
virtual bool create( std::vector<CalypFrame*> apcFrameList ) { return false; }
virtual bool create( std::vector<CalypFrame*> ) { return false; }
virtual CalypFrame* process( std::vector<CalypFrame*> ) { return NULL; }
virtual double measure( std::vector<CalypFrame*> ) { return 0; }
virtual bool keyPressed( enum Module_Key_Supported ) { return false; }
virtual ClpString moduleInfo() { return ClpString(); }
virtual bool create( std::vector<CalypStream*> ) { return false; };
virtual CalypStream* process( std::vector<CalypStream*> ) { return NULL; }
};
#endif // __CALYPMODULESIF_H__
+5 -1
View File
@@ -42,6 +42,10 @@ ADD_MODULE_USE_OPENCV( SaliencyDetectionSpectral "SaliencyDetection" VERSION 3.3
ADD_MODULE_USE_OPENCV( SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3.3.0 MODULES saliency )
ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.3.0 MODULES saliency )
IF( USE_FFMPEG )
ADD_MODULE( StreamCodingH264 "StreamCodingH264" )
ENDIF()
#
# Create header and auxiliar files
@@ -49,7 +53,7 @@ ADD_MODULE_USE_OPENCV( SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSI
CREATE_MODULE_MACROS()
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )
ADD_LIBRARY( CalypModules ${Calyp_Mod_SRCS} )
TARGET_LINK_LIBRARIES( CalypModules ${PROJECT_LIBRARY} ${OpenCV_LIBRARIES} )
TARGET_LINK_LIBRARIES( CalypModules ${PROJECT_LIBRARY} ${OpenCV_LIBRARIES} ${FFMPEG_LIBRARIES} )
IF( USE_DYNLOAD )
TARGET_LINK_LIBRARIES( CalypModules -ldl )
ENDIF()
+58
View File
@@ -0,0 +1,58 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2018 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 StreamCodingH264.cpp
* \brief Compress a stream using H.264
*/
#include "StreamCodingH264.h"
StreamCodingH264::StreamCodingH264()
{
/* Module Definition */
m_iModuleAPI = CLP_MODULE_API_2;
m_iModuleType = CLP_STREAM_PROCESSING_MODULE;
m_pchModuleCategory = "Video Coding";
m_pchModuleLongName = "H.264/AVC";
m_pchModuleName = "H264StreamCoding";
m_pchModuleTooltip = "Encode video stream using H.264/AVC standard (libx264)";
m_uiNumberOfFrames = 1;
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
m_cModuleOptions.addOptions() /**/
( "QP", m_iCRF, "Quantization parameter" );
m_pcProcessedFrame = NULL;
m_iCRF = 23;
}
bool StreamCodingH264::create( std::vector<CalypStream*> apcStreamList )
{
return false;
}
CalypStream* StreamCodingH264::process( std::vector<CalypStream*> apcStreamList )
{
return NULL;
}
void StreamCodingH264::destroy()
{
}
+47
View File
@@ -0,0 +1,47 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2018 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 StreamCodingH264.h
* \brief Compress a stream using H.264
*/
#ifndef __STREAMCODINGH264_H__
#define __STREAMCODINGH264_H__
// CalypLib
#include "lib/CalypModuleIf.h"
class StreamCodingH264 : public CalypModuleIf
{
REGISTER_CLASS_FACTORY( StreamCodingH264 )
private:
CalypFrame* m_pcProcessedFrame;
int m_iCRF;
public:
StreamCodingH264();
virtual ~StreamCodingH264() {}
bool create( std::vector<CalypStream*> apcStreamList );
CalypStream* process( std::vector<CalypStream*> apcFrameList );
void destroy();
};
#endif // __STREAMCODINGH264_H__