Fix warnings to build with Werror flag
This commit is contained in:
51 files changed
+338
-407
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=OFF
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
|
||||
+1
-1
@@ -243,7 +243,7 @@ IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
ENDIF()
|
||||
|
||||
IF(USE_WERROR)
|
||||
|
||||
+2
-1
@@ -53,7 +53,6 @@ SET(Calyp_App_SRCS
|
||||
# Module Quality
|
||||
QualityHandle.cpp
|
||||
PlotSubWindow.cpp
|
||||
external/qcustomplot/qcustomplot.cpp
|
||||
# Module Plugins
|
||||
ModulesHandle.cpp
|
||||
CalypAppModuleIf.cpp
|
||||
@@ -127,6 +126,8 @@ QT5_ADD_RESOURCES(Calyp_App_RCC ${Calyp_App_RCC})
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-enum-enum-conversion")
|
||||
|
||||
# Windows application icon
|
||||
IF(WIN32)
|
||||
SET(WINDOWS_RES_FILE ${CMAKE_CURRENT_BINARY_DIR}/resources.obj)
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ MainWindow::MainWindow()
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
setCentralWidget( m_pcWindowHandle );
|
||||
setAcceptDrops( true );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::windowActivated, this, &MainWindow::update );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
|
||||
@@ -32,7 +32,7 @@ MdiSubWindow::MdiSubWindow( QWidget* parent )
|
||||
: QMdiSubWindow( parent )
|
||||
{
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
}
|
||||
|
||||
QSize MdiSubWindow::sizeHint() const
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <QSize>
|
||||
|
||||
#include "qcustomplot.h"
|
||||
//#include "external/qcustomplot/qcustomplot.h"
|
||||
|
||||
void PlotSubWindow::definePlotColors()
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
QualityHandle::QualityHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
|
||||
+1
-1
@@ -25,11 +25,11 @@
|
||||
#ifndef __QUALITYMEASUREMENT_H__
|
||||
#define __QUALITYMEASUREMENT_H__
|
||||
|
||||
#include <QFuture>
|
||||
#include <QtCore>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "QFuture"
|
||||
#include "QualityMeasurementSidebar.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ SubWindowAbstract::SubWindowAbstract( QWidget* parent, unsigned int category )
|
||||
// setFocusPolicy( Qt::WheelFocus );
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
|
||||
setWindowIcon( QIcon( ":/logos/calyp-icon.png" ) );
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
MdiArea( QWidget* parent = 0 )
|
||||
: QMdiArea( parent ), m_pixmapLogo( ":/logos/calyp-logo.png" )
|
||||
{
|
||||
setBackgroundRole( QPalette::Background );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
}
|
||||
|
||||
void appendLogMessage( const QString& msg )
|
||||
|
||||
+1
-1
@@ -675,7 +675,7 @@ void VideoHandle::calculateRealFrameRate()
|
||||
|
||||
void VideoHandle::playEvent()
|
||||
{
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
// auto start = std::chrono::steady_clock::now();
|
||||
|
||||
// This value should only be true if it is really needed to refresh the UI after this play event
|
||||
// Lets assume the current window is not playing. Nothing changes in the UI expect the playing windows
|
||||
|
||||
@@ -518,10 +518,10 @@ bool VideoSubWindow::guessFormat( QString filename, unsigned int& rWidth, unsign
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
QVector<ClpString> formats_list = QVector<ClpString>::fromStdVector( CalypFrame::supportedPixelFormatListNames() );
|
||||
for( int i = 0; i < formats_list.size(); i++ )
|
||||
auto formats_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( std::size_t i = 0; i < formats_list.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list.at( i ).c_str(), Qt::CaseInsensitive ) )
|
||||
if( FilenameShort.contains( formats_list[i].c_str(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
@@ -779,7 +779,7 @@ bool VideoSubWindow::disableAllModules()
|
||||
bool VideoSubWindow::hasRunningModule()
|
||||
{
|
||||
bool bRet = false;
|
||||
for( int i = 0; i < m_associatedModules.size() && !bRet; i++ )
|
||||
for( std::size_t i = 0; i < m_associatedModules.size() && !bRet; i++ )
|
||||
{
|
||||
bRet |= m_associatedModules.at( i )->isRunning();
|
||||
}
|
||||
|
||||
+5
-3
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "ViewArea.h"
|
||||
|
||||
#include <qnamespace.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -729,10 +731,10 @@ void ViewArea::wheelEvent( QWheelEvent* event )
|
||||
|
||||
QWidget* p = parentWidget();
|
||||
QSize minimumSize = QSize( p->size().width() - 5, p->size().height() - 5 );
|
||||
usedScale = scaleZoomFactor( scale, event->pos(), minimumSize );
|
||||
usedScale = scaleZoomFactor( scale, event->position().toPoint(), minimumSize );
|
||||
if( usedScale != 1.0 )
|
||||
{
|
||||
emit zoomFactorChanged_byWheel( usedScale, event->pos() );
|
||||
emit zoomFactorChanged_byWheel( usedScale, event->position().toPoint() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -743,7 +745,7 @@ void ViewArea::mousePressEvent( QMouseEvent* event )
|
||||
|
||||
QPoint vpos = windowToView( event->pos() );
|
||||
|
||||
if( event->button() == Qt::MidButton )
|
||||
if( event->button() == Qt::MiddleButton )
|
||||
{
|
||||
}
|
||||
if( event->button() == Qt::LeftButton )
|
||||
|
||||
+4
-1
@@ -6,7 +6,10 @@ FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
|
||||
|
||||
SET(qcustomplot_SRCS qcustomplot.cpp qcustomplot.h)
|
||||
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-enum-enum-conversion")
|
||||
|
||||
ADD_LIBRARY(QCustomPlotLib STATIC ${qcustomplot_SRCS})
|
||||
TARGET_LINK_LIBRARIES(QCustomPlotLib Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(QCustomPlotLib PUBLIC .)
|
||||
+2
-10
@@ -6,7 +6,7 @@ INCLUDE(GNUInstallDirs)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp)
|
||||
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp CalypPlane.h)
|
||||
|
||||
SET(Calyp_Lib_Stream_SRCS
|
||||
CalypStream.h
|
||||
@@ -22,15 +22,7 @@ SET(Calyp_Lib_OptionParser_SRCS CalypOptions.h CalypOptions.cpp)
|
||||
|
||||
SET(Calyp_Lib_Modules_SRCS CalypOptions.h CalypOptions.cpp)
|
||||
|
||||
SET(Calyp_Lib_SRCS
|
||||
LibMemory.h
|
||||
CalypLib.h
|
||||
CalypDefs.h
|
||||
${Calyp_Lib_Frame_SRCS}
|
||||
${Calyp_Lib_Stream_SRCS}
|
||||
${Calyp_Lib_OptionParser_SRCS}
|
||||
${Calyp_Lib_Modules_SRCS}
|
||||
)
|
||||
SET(Calyp_Lib_SRCS CalypLib.h CalypDefs.h ${Calyp_Lib_Frame_SRCS} ${Calyp_Lib_Stream_SRCS} ${Calyp_Lib_OptionParser_SRCS} ${Calyp_Lib_Modules_SRCS})
|
||||
|
||||
LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${PROJECT_LIBRARY})
|
||||
LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
+17
-6
@@ -27,11 +27,10 @@
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "LibMemory.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
@@ -40,6 +39,18 @@
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#endif
|
||||
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free
|
||||
#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
|
||||
#define xMalloc( len ) _aligned_malloc( len, 32 )
|
||||
#define xFreeMem( ptr ) _aligned_free( ptr )
|
||||
#else
|
||||
#define xMalloc( len ) malloc( len )
|
||||
#define xFreeMem( ptr ) free( ptr )
|
||||
#endif
|
||||
|
||||
constexpr auto kMinBitsPerPixel = 8;
|
||||
constexpr auto kMaxBitsPerPixel = 16;
|
||||
|
||||
@@ -166,7 +177,7 @@ public:
|
||||
}
|
||||
mem_size += num_of_ptrs * sizeof( ClpPel* ) + sizeof( ClpPel** ) * iNumberChannels;
|
||||
|
||||
m_pppcInputPel = (ClpPel***)xMallocMem( mem_size );
|
||||
m_pppcInputPel = (ClpPel***)xMalloc( mem_size );
|
||||
|
||||
ClpPel** pelPtrMem = (ClpPel**)( m_pppcInputPel + iNumberChannels );
|
||||
ClpPel* pelMem = (ClpPel*)( pelPtrMem + num_of_ptrs );
|
||||
@@ -675,7 +686,7 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
|
||||
}
|
||||
|
||||
xMemSet( ClpPel, getTotalNumberOfPixels(), d->m_pppcInputPel[0][0] );
|
||||
memset( d->m_pppcInputPel[0][0], 0, getTotalNumberOfPixels() * sizeof( ClpPel ) );
|
||||
|
||||
for( unsigned ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
@@ -850,7 +861,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
uint32_t* pARGBLine = pARGB;
|
||||
uint32_t* pARGBAux;
|
||||
|
||||
for( int y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
for( unsigned y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
{
|
||||
for( int i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
|
||||
{
|
||||
@@ -858,7 +869,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pU = pLineU;
|
||||
ClpPel* pV = pLineV;
|
||||
pARGBAux = pARGBLine;
|
||||
for( int x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
for( unsigned x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
{
|
||||
int iU = *pU++;
|
||||
iU >>= shiftBits;
|
||||
|
||||
+24
-23
@@ -42,9 +42,16 @@
|
||||
|
||||
#define REGISTER_CLASS_MAKER( X ) \
|
||||
extern "C" CalypModulePtr Maker() { return std::make_unique<X>(); }
|
||||
#define REGISTER_CLASS_FACTORY( X ) \
|
||||
public: \
|
||||
#define REGISTER_CLASS_FACTORY( X ) \
|
||||
public: \
|
||||
X( const X& buffer ) \
|
||||
noexcept = delete; \
|
||||
X( X&& buffer ) \
|
||||
noexcept = delete; \
|
||||
auto operator=( const X& buffer )->X& = delete; \
|
||||
auto operator=( X&& buffer ) noexcept->X& = delete; \
|
||||
static CalypModulePtr Create() { return std::make_unique<X>(); }
|
||||
|
||||
#define _BASIC_MODULE_API_2_CHECK_ \
|
||||
if( apcFrameList.size() != m_uiNumberOfFrames ) \
|
||||
return false; \
|
||||
@@ -76,8 +83,9 @@ enum Module_API_Version
|
||||
*/
|
||||
enum Module_Type
|
||||
{
|
||||
CLP_FRAME_PROCESSING_MODULE,
|
||||
CLP_FRAME_MEASUREMENT_MODULE,
|
||||
CLP_INVALID_MODULE = -1,
|
||||
CLP_FRAME_PROCESSING_MODULE = 0,
|
||||
CLP_FRAME_MEASUREMENT_MODULE = 1,
|
||||
CLP_MODULE_TYPE_MAX = 255,
|
||||
};
|
||||
|
||||
@@ -114,31 +122,24 @@ enum Module_Key_Supported
|
||||
class CalypModuleIf
|
||||
{
|
||||
public:
|
||||
int m_iModuleAPI;
|
||||
int m_iModuleType;
|
||||
const char* m_pchModuleCategory;
|
||||
const char* m_pchModuleName;
|
||||
const char* m_pchModuleTooltip;
|
||||
const char* m_pchModuleLongName;
|
||||
int m_iModuleAPI{ CLP_MODULE_API_1 };
|
||||
int m_iModuleType{ CLP_INVALID_MODULE };
|
||||
const char* m_pchModuleCategory{ "" };
|
||||
const char* m_pchModuleName{ "" };
|
||||
const char* m_pchModuleTooltip{ "" };
|
||||
const char* m_pchModuleLongName{ "" };
|
||||
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames;
|
||||
unsigned int m_uiNumberOfFrames{ 1 };
|
||||
//! Features/Requirements
|
||||
unsigned int m_uiModuleRequirements;
|
||||
unsigned int m_uiModuleRequirements{ CLP_MODULE_REQUIRES_NOTHING };
|
||||
|
||||
unsigned int m_iFrameBufferCount;
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
unsigned int m_iFrameBufferCount{ 0 };
|
||||
//CalypFrame* m_pcOutputFrame;
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
|
||||
CalypModuleIf()
|
||||
{
|
||||
m_iModuleAPI = CLP_MODULE_API_1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_pchModuleLongName = NULL;
|
||||
m_pcOutputFrame = NULL;
|
||||
m_iFrameBufferCount = 0;
|
||||
}
|
||||
CalypModuleIf() = default;
|
||||
virtual ~CalypModuleIf() {}
|
||||
virtual void destroy() = 0;
|
||||
|
||||
@@ -164,7 +165,7 @@ public:
|
||||
/**
|
||||
* Module API version 3
|
||||
*/
|
||||
virtual CalypFrame* getProcessedFrame() { return m_pcOutputFrame; }
|
||||
virtual CalypFrame* getProcessedFrame() { return nullptr; }
|
||||
virtual bool needFrame() { return m_iFrameBufferCount == 0 ? true : false; };
|
||||
virtual bool flush()
|
||||
{
|
||||
|
||||
@@ -25,59 +25,45 @@
|
||||
#include "CalypOpenCVModuleIf.h"
|
||||
|
||||
// OpenCV
|
||||
#include <memory>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using cv::Mat;
|
||||
|
||||
bool CalypOpenCVModuleIf::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
bool bRet = false;
|
||||
std::vector<Mat*> acMatList( apcFrameList.size() );
|
||||
std::vector<Mat> acMatList( apcFrameList.size() );
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
acMatList[i] = new Mat;
|
||||
apcFrameList[i]->toMat( *acMatList[i], m_bConvertToGray );
|
||||
apcFrameList[i]->toMat( acMatList[i], m_bConvertToGray );
|
||||
}
|
||||
Mat* outputMat = create_using_opencv( acMatList );
|
||||
if( outputMat )
|
||||
{
|
||||
unsigned pelFormat = m_bConvertToGray ? CalypFrame::findPixelFormat( "GRAY" ) : apcFrameList[0]->getPelFormat();
|
||||
m_pcOutputFrame = new CalypFrame( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
m_pcOutputFrame = std::make_unique<CalypFrame>( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
bRet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
delete acMatList[i];
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
CalypFrame* CalypOpenCVModuleIf::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
std::vector<Mat*> acMatList( apcFrameList.size() );
|
||||
std::vector<Mat> acMatList( apcFrameList.size() );
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
acMatList[i] = new Mat;
|
||||
apcFrameList[i]->toMat( *acMatList[i], m_bConvertToGray );
|
||||
apcFrameList[i]->toMat( acMatList[i], m_bConvertToGray );
|
||||
}
|
||||
Mat* cvOutput = process_using_opencv( acMatList );
|
||||
m_pcOutputFrame->fromMat( *cvOutput );
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
delete acMatList[i];
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
return m_pcOutputFrame.get();
|
||||
}
|
||||
|
||||
void CalypOpenCVModuleIf::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -26,6 +26,8 @@
|
||||
#ifndef __CALYPOPENCVMODULEIF_H__
|
||||
#define __CALYPOPENCVMODULEIF_H__
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "CalypModuleIf.h"
|
||||
|
||||
namespace cv
|
||||
@@ -40,8 +42,11 @@ class Mat;
|
||||
*/
|
||||
class CalypOpenCVModuleIf : public CalypModuleIf
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
protected:
|
||||
const char* m_pchPythonFunctionName;
|
||||
//const char* m_pchPythonFunctionName;
|
||||
std::unique_ptr<CalypFrame> m_pcOutputFrame;
|
||||
bool m_bConvertToGray;
|
||||
|
||||
public:
|
||||
@@ -57,8 +62,8 @@ public:
|
||||
void destroy();
|
||||
|
||||
// API using OpenCV
|
||||
virtual cv::Mat* create_using_opencv( std::vector<cv::Mat*> apcFrameList ) { return NULL; };
|
||||
virtual cv::Mat* process_using_opencv( std::vector<cv::Mat*> apcFrameList ) = 0;
|
||||
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList ) { return nullptr; };
|
||||
virtual Mat* process_using_opencv( const std::vector<Mat>& apcFrameList ) = 0;
|
||||
virtual void destroy_using_opencv(){};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2021 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 CalypPlane.h
|
||||
* \ingroup CalypFrameGrp
|
||||
* \brief Video Frame Plane handling
|
||||
*/
|
||||
|
||||
#ifndef __CALYPPLANE_H__
|
||||
#define __CALYPPLANE_H__
|
||||
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
|
||||
/**
|
||||
* \class CalypPlane
|
||||
* \ingroup CalypLibGrp CalypPlaneGrp
|
||||
* \brief Frame handling class
|
||||
*/
|
||||
template <typename T>
|
||||
class CalypPlane
|
||||
{
|
||||
public:
|
||||
CalypPlane() noexcept = default;
|
||||
CalypPlane( std::size_t width, std::size_t height ) noexcept { resize( width, height ); }
|
||||
|
||||
~CalypPlane() noexcept = default;
|
||||
CalypPlane( const CalypPlane& buffer ) noexcept = default;
|
||||
CalypPlane( CalypPlane&& buffer ) noexcept = default;
|
||||
auto operator=( const CalypPlane& buffer ) -> CalypPlane& = default;
|
||||
auto operator=( CalypPlane&& buffer ) noexcept -> CalypPlane& = default;
|
||||
|
||||
auto operator[]( std::size_t row ) const& noexcept -> const std::span<T>& { return m_rows[row]; }
|
||||
auto operator[]( std::size_t row ) & noexcept -> std::span<T>& { return m_rows[row]; }
|
||||
|
||||
auto operator[]( std::size_t row ) const&& noexcept { return m_rows[row]; }
|
||||
auto operator[]( std::size_t row ) && noexcept { return m_rows[row]; }
|
||||
|
||||
auto data() noexcept { return std::span<T>( m_data ); }
|
||||
auto data() const noexcept { return std::span<const T>( m_data ); }
|
||||
|
||||
void resize( std::size_t width, std::size_t height ) noexcept
|
||||
{
|
||||
m_data.resize( width * height );
|
||||
m_rows.resize( height );
|
||||
for( std::size_t y = 0; y < height; y++ )
|
||||
{
|
||||
m_rows[y] = std::span<T>( m_data ).subspan( y * width, width );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
std::vector<std::span<T>> m_rows;
|
||||
};
|
||||
|
||||
#endif // __CALYPPLANE_H__
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStreamHandlerIf.h"
|
||||
#include "LibMemory.h"
|
||||
#include "StreamHandlerPortableMap.h"
|
||||
#include "StreamHandlerRaw.h"
|
||||
#include "config.h"
|
||||
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2021 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 LibMemory.cpp
|
||||
* \ingroup CalypLib
|
||||
* \brief Memory allocation functions
|
||||
*/
|
||||
|
||||
#ifndef __LIBMEMORY_H__
|
||||
#define __LIBMEMORY_H__
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free
|
||||
#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
|
||||
#define xMalloc( len ) _aligned_malloc( len, 32 )
|
||||
#define xFreeMem( ptr ) _aligned_free( ptr )
|
||||
#else
|
||||
#define xMalloc( len ) malloc( len )
|
||||
#define xFreeMem( ptr ) free( ptr )
|
||||
#endif
|
||||
#define xMemSet( type, len, ptr ) memset( ptr, 0, ( len ) * sizeof( type ) )
|
||||
|
||||
[[deprecated]] static inline void* xMallocMem( size_t nitems )
|
||||
{
|
||||
void* d;
|
||||
if( ( d = xMalloc( nitems ) ) == NULL )
|
||||
{
|
||||
printf( "malloc failed.\n" );
|
||||
return NULL;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
[[deprecated]] static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
{
|
||||
size_t padded_size = nitems * size;
|
||||
void* d = xMallocMem( padded_size );
|
||||
if( d )
|
||||
memset( d, 0, (int)padded_size );
|
||||
return d;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[deprecated]] int getMem1D( T** array1D, int dim0 )
|
||||
{
|
||||
if( ( *array1D = (T*)xCallocMem( dim0, sizeof( T ) ) ) == NULL )
|
||||
return 0;
|
||||
|
||||
return ( sizeof( T* ) + dim0 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[deprecated]] void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem2D( T*** array2D, int dim0, int dim1 )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( ( *array2D = (T**)xMallocMem( dim0 * sizeof( T* ) ) ) == NULL )
|
||||
printf( "get_mem2Dint: array2D" );
|
||||
if( ( *( *array2D ) = (T*)xCallocMem( dim0 * dim1, sizeof( T ) ) ) == NULL )
|
||||
printf( "get_mem2Dint: array2D" );
|
||||
|
||||
for( i = 1; i < dim0; i++ )
|
||||
( *array2D )[i] = ( *array2D )[i - 1] + dim1;
|
||||
|
||||
return dim0 * ( sizeof( T* ) + dim1 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem2D( T**& array2D )
|
||||
{
|
||||
if( *array2D )
|
||||
{
|
||||
if( *array2D )
|
||||
xFreeMem( *array2D );
|
||||
else
|
||||
printf( "free_mem2Dint: trying to free unused memory" );
|
||||
|
||||
xFreeMem( array2D );
|
||||
array2D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem2Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __LIBMEMORY_H__
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_FFMPEG
|
||||
#include "StreamHandlerLibav.h"
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#if( ( LIBAVCODEC_VERSION_MAJOR > 57 ) || ( LIBAVCODEC_VERSION_MAJOR == 57 ) && ( LIBAVCODEC_VERSION_MINOR >= 37 ) )
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#if CV_MAJOR_VERSION >= 3
|
||||
#include <opencv2/videoio.hpp>
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerPortableMap::supportedReadFormats()
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerRaw::supportedReadFormats()
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ ADD_MODULE_USE_OPENCV(SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3
|
||||
ADD_MODULE_USE_OPENCV(SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.3.0 MODULES saliency)
|
||||
|
||||
ADD_MODULE_USE_OPENCV(FrameResampling "FrameResampling" VERSION 3.3.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(SaliencyBasedFiltering "SaliencyBasedFiltering" VERSION 3.1.0 MODULES core)
|
||||
|
||||
ADD_MODULE_USE_OPENCV(ThreeSixtySpatialtoTemporal "ThreeSixtySpatialtoTemporal" VERSION 3.1.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(ThreeSixtyFaceExtraction "ThreeSixtyFaceExtraction" VERSION 3.1.0 MODULES core)
|
||||
|
||||
@@ -80,26 +80,24 @@ bool FrameResampling::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_iHeight = apcFrameList[0]->getHeight() * double( m_iWidth ) / double( apcFrameList[0]->getWidth() );
|
||||
}
|
||||
m_pcOutputFrame = new CalypFrame( m_iWidth, m_iHeight, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
return m_pcOutputFrame;
|
||||
m_resamplingFrame = std::make_unique<CalypFrame>( m_iWidth, m_iHeight, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
return true;
|
||||
}
|
||||
|
||||
CalypFrame* FrameResampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
m_resamplingFrame->reset();
|
||||
for( unsigned ch = 0; ch < apcFrameList[0]->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat inputFrame, outputFrame;
|
||||
cv::Size outSize( m_pcOutputFrame->getWidth( ch ), m_pcOutputFrame->getHeight( ch ) );
|
||||
cv::Size outSize( m_resamplingFrame->getWidth( ch ), m_resamplingFrame->getHeight( ch ) );
|
||||
apcFrameList[0]->toMat( inputFrame, true, false, ch );
|
||||
cv::resize( inputFrame, outputFrame, outSize, 0, 0, m_iInterpolation );
|
||||
m_pcOutputFrame->fromMat( outputFrame, ch );
|
||||
m_resamplingFrame->fromMat( outputFrame, ch );
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
return m_resamplingFrame.get();
|
||||
}
|
||||
|
||||
void FrameResampling::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
}
|
||||
@@ -43,6 +43,7 @@ private:
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iInterpolation;
|
||||
std::unique_ptr<CalypFrame> m_resamplingFrame;
|
||||
|
||||
public:
|
||||
FrameResampling();
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
HEVCIntraPrediction::HEVCIntraPrediction()
|
||||
{
|
||||
/* Module Definition */
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "InterFrameVariance.h"
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
InterFrameVariance::InterFrameVariance()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -56,7 +54,8 @@ bool InterFrameVariance::create( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
m_pcFrameVariance =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, 8 );
|
||||
getMem2D( &m_pVariance, apcFrameList[0]->getHeight(), apcFrameList[0]->getWidth() );
|
||||
|
||||
m_pVariance = CalypPlane<double>{ apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight() };
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -105,9 +104,6 @@ CalypFrame* InterFrameVariance::process( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
void InterFrameVariance::destroy()
|
||||
{
|
||||
if( m_pVariance )
|
||||
freeMem2D( m_pVariance );
|
||||
m_pVariance = NULL;
|
||||
if( m_pcFrameVariance )
|
||||
delete m_pcFrameVariance;
|
||||
m_pcFrameVariance = NULL;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
#include "lib/CalypPlane.h"
|
||||
|
||||
class InterFrameVariance : public CalypModuleIf
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class InterFrameVariance : public CalypModuleIf
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrameVariance;
|
||||
double** m_pVariance;
|
||||
CalypPlane<double> m_pVariance;
|
||||
|
||||
public:
|
||||
InterFrameVariance();
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
OptimiseDisplay::OptimiseDisplay()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -53,11 +51,11 @@ bool OptimiseDisplay::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
m_pcOptimisedFrame = new CalypFrame{ apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() };
|
||||
m_pcOptimisedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() );
|
||||
m_pcOptimisedFrame->reset();
|
||||
|
||||
return true;
|
||||
@@ -95,11 +93,9 @@ CalypFrame* OptimiseDisplay::process( std::vector<CalypFrame*> apcFrameList )
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_pcOptimisedFrame;
|
||||
return m_pcOptimisedFrame.get();
|
||||
}
|
||||
|
||||
void OptimiseDisplay::destroy()
|
||||
{
|
||||
delete m_pcOptimisedFrame;
|
||||
m_pcOptimisedFrame = nullptr;
|
||||
}
|
||||
@@ -34,14 +34,14 @@ class OptimiseDisplay : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( OptimiseDisplay )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcOptimisedFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcOptimisedFrame;
|
||||
|
||||
public:
|
||||
OptimiseDisplay();
|
||||
virtual ~OptimiseDisplay() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
bool create( std::vector<CalypFrame*> apcFrameList ) final;
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList ) final;
|
||||
void destroy() final;
|
||||
};
|
||||
|
||||
#endif // __OPTIMISEDISPLAY_H__
|
||||
@@ -32,55 +32,61 @@
|
||||
SaliencyBasedFiltering::SaliencyBasedFiltering()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = MODULE_API_2;
|
||||
m_iModuleType = FRAME_PROCESSING_MODULE;
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "SaliencyBasedFiltering";
|
||||
m_pchModuleTooltip = "Image filter based on a map";
|
||||
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = 2;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
}
|
||||
|
||||
Bool SaliencyBasedFiltering::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
bool SaliencyBasedFiltering::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
for( UInt i = 0; i < apcFrameList.size(); i++ )
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_RESOLUTION ) )
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_RESOLUTION ) )
|
||||
return false;
|
||||
}
|
||||
if( apcFrameList[1]->getNumberChannels() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pcProcessedFrame = new PlaYUVerFrame( apcFrameList[0] );
|
||||
|
||||
m_pcProcessedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static cv::Mat* getCvFrame( Pel* pInputPel, UInt uiWidth, UInt uiHeight )
|
||||
static cv::Mat* getCvFrame( ClpPel* pInputPel, unsigned uiWidth, unsigned uiHeight )
|
||||
{
|
||||
cv::Mat* cvInput = new cv::Mat( uiHeight, uiWidth, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
UChar* pCvPel = cvInput->data;
|
||||
for( UInt i = 0; i < uiWidth * uiHeight; i++ )
|
||||
unsigned char* pCvPel = cvInput->data;
|
||||
for( unsigned i = 0; i < uiWidth * uiHeight; i++ )
|
||||
{
|
||||
*pCvPel++ = *pInputPel++;
|
||||
}
|
||||
return cvInput;
|
||||
}
|
||||
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, UInt kernelSize )
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, unsigned kernelSize )
|
||||
{
|
||||
cv::Mat* cvFiltered = new cv::Mat( cvFrame->rows, cvFrame->cols, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
/// Initialize arguments for the filter
|
||||
cv::Point anchor = cv::Point( -1, -1 );
|
||||
Double delta = 0;
|
||||
Int ddepth = -1;
|
||||
double delta = 0;
|
||||
int ddepth = -1;
|
||||
|
||||
/// Update kernel size for a normalized box filter
|
||||
cv::Mat kernel = cv::Mat::ones( kernelSize, kernelSize, CV_32F ) / (Double)( kernelSize * kernelSize );
|
||||
cv::Mat kernel = cv::Mat::ones( kernelSize, kernelSize, CV_32F ) / static_cast<double>( kernelSize * kernelSize );
|
||||
|
||||
/// Apply filter
|
||||
cv::filter2D( *cvFrame, *cvFiltered, ddepth, kernel, anchor, delta, cv::BORDER_DEFAULT );
|
||||
@@ -88,44 +94,42 @@ static cv::Mat* filterframe( cv::Mat* cvFrame, UInt kernelSize )
|
||||
return cvFiltered;
|
||||
}
|
||||
|
||||
static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaYUVerFrame* Map, UInt uiComp )
|
||||
static void filterComponent( CalypFrame* pInput, CalypFrame* pOutput, CalypFrame* Map, unsigned uiComp )
|
||||
{
|
||||
Pel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
Int iMapStep = 1;
|
||||
Pel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
Pel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
Int iHeight = pInput->getHeight();
|
||||
Int iWidth = pInput->getWidth();
|
||||
ClpPel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
int iMapStep = 1;
|
||||
ClpPel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
ClpPel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
std::int64_t iHeight = pInput->getHeight( uiComp );
|
||||
std::int64_t iWidth = pInput->getWidth( uiComp );
|
||||
|
||||
if( uiComp > 0 )
|
||||
{
|
||||
iHeight = pInput->getChromaHeight();
|
||||
iWidth = pInput->getChromaWidth();
|
||||
iMapStep = 2;
|
||||
}
|
||||
|
||||
cv::Mat* cvInput = getCvFrame( pInputPel, iWidth, iHeight );
|
||||
|
||||
UInt numberFilters = 1;
|
||||
UChar* pCvPel[3];
|
||||
unsigned numberFilters = 1;
|
||||
unsigned char* pCvPel[3];
|
||||
cv::Mat* cvOutput[3];
|
||||
for( UInt i = 0; i < numberFilters; i++ )
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
{
|
||||
cvOutput[i] = filterframe( cvInput, ( 1 << ( 2 * i + 7 ) ) + 1 );
|
||||
pCvPel[i] = cvOutput[i]->data;
|
||||
}
|
||||
|
||||
Int iCheckNeighbour = 8;
|
||||
UInt uiRelevance = 0;
|
||||
for( Int y = 0; y < iHeight; y++ )
|
||||
int iCheckNeighbour = 8;
|
||||
unsigned uiRelevance = 0;
|
||||
for( int y = 0; y < iHeight; y++ )
|
||||
{
|
||||
for( Int x = 0; x < iWidth; x++ )
|
||||
for( int x = 0; x < iWidth; x++ )
|
||||
{
|
||||
uiRelevance = 0;
|
||||
// uiRelevance = *pMapPel;
|
||||
for( Int j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
for( std::int64_t j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
{
|
||||
for( Int i = CLAMP_RANGE( x - iCheckNeighbour, 0, iWidth ); i < CLAMP_RANGE( x + iCheckNeighbour + 1, 0, iWidth ); i++ )
|
||||
for( std::int64_t i = CLAMP_RANGE( x - iCheckNeighbour, 0, iWidth ); i < CLAMP_RANGE( x + iCheckNeighbour + 1, 0, iWidth ); i++ )
|
||||
{
|
||||
uiRelevance += *( pMapPel + ( ( j - y ) * iWidth ) + ( i - x ) );
|
||||
}
|
||||
@@ -141,7 +145,7 @@ static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaY
|
||||
//*pOutputPel = 0;
|
||||
}
|
||||
|
||||
for( UInt i = 0; i < numberFilters; i++ )
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
pCvPel[i]++;
|
||||
pInputPel++;
|
||||
pOutputPel++;
|
||||
@@ -151,16 +155,16 @@ static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaY
|
||||
}
|
||||
}
|
||||
|
||||
PlaYUVerFrame* SaliencyBasedFiltering::process( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
CalypFrame* SaliencyBasedFiltering::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
PlaYUVerFrame* pcInputFrame = apcFrameList[0];
|
||||
CalypFrame* pcInputFrame = apcFrameList[0];
|
||||
|
||||
for( UInt c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame, apcFrameList[1], c );
|
||||
for( unsigned c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame.get(), apcFrameList[1], c );
|
||||
|
||||
return m_pcProcessedFrame;
|
||||
return m_pcProcessedFrame.get();
|
||||
}
|
||||
|
||||
Void SaliencyBasedFiltering::destroy()
|
||||
void SaliencyBasedFiltering::destroy()
|
||||
{
|
||||
}
|
||||
@@ -24,25 +24,21 @@
|
||||
#ifndef __SALIENCYBASEDFILTERING_H__
|
||||
#define __SALIENCYBASEDFILTERING_H__
|
||||
|
||||
#include <cassert>
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
|
||||
class SaliencyBasedFiltering : public PlaYUVerModuleIf
|
||||
class SaliencyBasedFiltering : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( SaliencyBasedFiltering )
|
||||
|
||||
private:
|
||||
PlaYUVerFrame* m_pcProcessedFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcProcessedFrame;
|
||||
|
||||
public:
|
||||
SaliencyBasedFiltering();
|
||||
virtual ~SaliencyBasedFiltering()
|
||||
{
|
||||
}
|
||||
Bool create( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
PlaYUVerFrame* process( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
Void destroy();
|
||||
virtual ~SaliencyBasedFiltering() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __SALIENCYBASEDFILTERING_H__
|
||||
@@ -45,7 +45,6 @@ SaliencyDetectionModule::SaliencyDetectionModule()
|
||||
|
||||
void SaliencyDetectionModule::destroy_using_opencv()
|
||||
{
|
||||
delete m_pcvSaliency;
|
||||
}
|
||||
|
||||
SaliencyDetectionSpectral::SaliencyDetectionSpectral()
|
||||
@@ -63,17 +62,17 @@ SaliencyDetectionSpectral::SaliencyDetectionSpectral()
|
||||
m_bBinaryMap = false;
|
||||
}
|
||||
|
||||
cv::Mat* SaliencyDetectionSpectral::create_using_opencv( std::vector<Mat*> apcMatList )
|
||||
cv::Mat* SaliencyDetectionSpectral::create_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_ptrSaliencyAlgorithm = StaticSaliencySpectralResidual::create();
|
||||
m_pcvSaliency = new Mat( apcMatList[0]->rows, apcMatList[0]->cols, CV_8UC1 );
|
||||
return m_pcvSaliency;
|
||||
m_pcvSaliency = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
|
||||
Mat* SaliencyDetectionSpectral::process_using_opencv( std::vector<Mat*> apcMatList )
|
||||
Mat* SaliencyDetectionSpectral::process_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
Mat cvSaliency;
|
||||
m_ptrSaliencyAlgorithm->computeSaliency( *apcMatList[0], cvSaliency );
|
||||
m_ptrSaliencyAlgorithm->computeSaliency( apcMatList[0], cvSaliency );
|
||||
Mat cvBinaryMap;
|
||||
StaticSaliencySpectralResidual spec;
|
||||
spec.computeBinaryMap( cvSaliency, *m_pcvSaliency );
|
||||
@@ -82,7 +81,7 @@ Mat* SaliencyDetectionSpectral::process_using_opencv( std::vector<Mat*> apcMatLi
|
||||
cvSaliency *= 255;
|
||||
cvSaliency.convertTo( *m_pcvSaliency, CV_8UC1 );
|
||||
}
|
||||
return m_pcvSaliency;
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
|
||||
SaliencyDetectionFineGrained::SaliencyDetectionFineGrained()
|
||||
@@ -93,17 +92,17 @@ SaliencyDetectionFineGrained::SaliencyDetectionFineGrained()
|
||||
m_pchModuleTooltip = "Measure saliency using fine grained method";
|
||||
}
|
||||
|
||||
Mat* SaliencyDetectionFineGrained::create_using_opencv( std::vector<Mat*> apcMatList )
|
||||
Mat* SaliencyDetectionFineGrained::create_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_ptrSaliencyAlgorithm = cv::saliency::StaticSaliencyFineGrained::create();
|
||||
m_pcvSaliency = new Mat( apcMatList[0]->rows, apcMatList[0]->cols, CV_8UC1 );
|
||||
return m_pcvSaliency;
|
||||
m_pcvSaliency = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
|
||||
Mat* SaliencyDetectionFineGrained::process_using_opencv( std::vector<Mat*> apcMatList )
|
||||
Mat* SaliencyDetectionFineGrained::process_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_ptrSaliencyAlgorithm->computeSaliency( *apcMatList[0], *m_pcvSaliency );
|
||||
return m_pcvSaliency;
|
||||
m_ptrSaliencyAlgorithm->computeSaliency( apcMatList[0], *m_pcvSaliency );
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
|
||||
SaliencyDetectionBinWangApr2014::SaliencyDetectionBinWangApr2014()
|
||||
@@ -114,22 +113,22 @@ SaliencyDetectionBinWangApr2014::SaliencyDetectionBinWangApr2014()
|
||||
m_pchModuleTooltip = "Measure saliency using a fast self-tuning background subtraction algorithm";
|
||||
}
|
||||
|
||||
Mat* SaliencyDetectionBinWangApr2014::create_using_opencv( std::vector<Mat*> apcMatList )
|
||||
Mat* SaliencyDetectionBinWangApr2014::create_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_ptrSaliencyAlgorithm = MotionSaliencyBinWangApr2014::create();
|
||||
m_ptrSaliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( apcMatList[0]->cols, apcMatList[0]->rows );
|
||||
m_ptrSaliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->setImagesize( apcMatList[0].cols, apcMatList[0].rows );
|
||||
m_ptrSaliencyAlgorithm.dynamicCast<MotionSaliencyBinWangApr2014>()->init();
|
||||
m_pcvSaliency = new Mat( apcMatList[0]->rows, apcMatList[0]->cols, CV_8UC1 );
|
||||
return m_pcvSaliency;
|
||||
m_pcvSaliency = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
|
||||
Mat* SaliencyDetectionBinWangApr2014::process_using_opencv( std::vector<Mat*> apcMatList )
|
||||
Mat* SaliencyDetectionBinWangApr2014::process_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
if( m_ptrSaliencyAlgorithm->computeSaliency( *apcMatList[0], *m_pcvSaliency ) )
|
||||
if( m_ptrSaliencyAlgorithm->computeSaliency( apcMatList[0], *m_pcvSaliency ) )
|
||||
{
|
||||
*m_pcvSaliency *= 255;
|
||||
m_pcvSaliency->convertTo( *m_pcvSaliency, CV_8UC1 );
|
||||
//cv::cvtColor(m_matSaliency, m_matSaliency, cv::COLOR_BGR2GRAY);
|
||||
}
|
||||
return m_pcvSaliency;
|
||||
return m_pcvSaliency.get();
|
||||
}
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/saliency.hpp>
|
||||
|
||||
using cv::Mat;
|
||||
|
||||
/**
|
||||
* \ingroup Calyp_Modules
|
||||
* @defgroup Calyp_Modules_Saliency Saliency
|
||||
@@ -44,8 +42,10 @@ using cv::Mat;
|
||||
|
||||
class SaliencyDetectionModule : public CalypOpenCVModuleIf
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
protected:
|
||||
Mat* m_pcvSaliency;
|
||||
std::unique_ptr<Mat> m_pcvSaliency;
|
||||
cv::Ptr<cv::saliency::Saliency> m_ptrSaliencyAlgorithm;
|
||||
|
||||
public:
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
*/
|
||||
class SaliencyDetectionSpectral : public SaliencyDetectionModule
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionSpectral )
|
||||
private:
|
||||
bool m_bBinaryMap;
|
||||
@@ -75,8 +77,8 @@ private:
|
||||
public:
|
||||
SaliencyDetectionSpectral();
|
||||
virtual ~SaliencyDetectionSpectral() {}
|
||||
Mat* create_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* process_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -91,12 +93,14 @@ public:
|
||||
*/
|
||||
class SaliencyDetectionFineGrained : public SaliencyDetectionModule
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionFineGrained )
|
||||
public:
|
||||
SaliencyDetectionFineGrained();
|
||||
virtual ~SaliencyDetectionFineGrained() {}
|
||||
Mat* create_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* process_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -108,12 +112,14 @@ public:
|
||||
*/
|
||||
class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionBinWangApr2014 )
|
||||
public:
|
||||
SaliencyDetectionBinWangApr2014();
|
||||
virtual ~SaliencyDetectionBinWangApr2014() {}
|
||||
Mat* create_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* process_using_opencv( std::vector<Mat*> apcMatList );
|
||||
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
};
|
||||
|
||||
#endif // __SALIENCYDETECTION_H__
|
||||
@@ -75,7 +75,7 @@ ThreeSixtyDownsampling::ThreeSixtyDownsampling()
|
||||
m_bForceIntSlope = 0;
|
||||
m_iRearrange = 0;
|
||||
m_iWidth = -1;
|
||||
m_pcOutputFrame = NULL;
|
||||
m_pcResultedFrame = NULL;
|
||||
m_pcDownsampled = NULL;
|
||||
m_dPixelRatio = 0;
|
||||
|
||||
@@ -589,17 +589,17 @@ bool ThreeSixtyDownsampling::createDownsamplingMask( CalypFrame* pcInputFrame )
|
||||
switch( m_uiDownsampling )
|
||||
{
|
||||
case 0:
|
||||
m_pcOutputFrame = new CalypFrame( m_pcDownsampled->getWidth(), m_pcDownsampled->getHeight(), pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
m_pcResultedFrame = new CalypFrame( m_pcDownsampled->getWidth(), m_pcDownsampled->getHeight(), pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
break;
|
||||
case 1:
|
||||
m_pcOutputFrame = new CalypFrame( m_cvReshapePoints[0]->cols, m_cvReshapePoints[0]->rows, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
m_pcResultedFrame = new CalypFrame( m_cvReshapePoints[0]->cols, m_cvReshapePoints[0]->rows, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
break;
|
||||
case 2:
|
||||
m_pcOutputFrame = new CalypFrame{ pcInputFrame->getWidth(),
|
||||
pcInputFrame->getHeight(),
|
||||
pcInputFrame->getPelFormat(),
|
||||
pcInputFrame->getBitsPel(),
|
||||
pcInputFrame->getHasNegativeValues() };
|
||||
m_pcResultedFrame = new CalypFrame{ pcInputFrame->getWidth(),
|
||||
pcInputFrame->getHeight(),
|
||||
pcInputFrame->getPelFormat(),
|
||||
pcInputFrame->getBitsPel(),
|
||||
pcInputFrame->getHasNegativeValues() };
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@@ -609,7 +609,7 @@ void ThreeSixtyDownsampling::downsamplingOperation( CalypFrame* pcInputFrame )
|
||||
{
|
||||
unsigned numBytes = m_pcDownsampled->getBitsPel() > 8 ? 2 : 1;
|
||||
m_pcDownsampled->reset();
|
||||
m_pcOutputFrame->reset();
|
||||
m_pcResultedFrame->reset();
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
{
|
||||
int imH = int( m_pcDownsampled->getHeight( ch ) );
|
||||
@@ -640,12 +640,12 @@ void ThreeSixtyDownsampling::downsamplingOperation( CalypFrame* pcInputFrame )
|
||||
}
|
||||
Mat_<Point> reshapePoints = *( m_cvReshapePoints[ch] );
|
||||
ClpPel** downSampPelBuff = m_pcDownsampled->getPelBufferYUV()[ch];
|
||||
ClpPel* pelOutputPtr = m_pcOutputFrame->getPelBufferYUV()[ch][0];
|
||||
ClpPel* pelOutputPtr = m_pcResultedFrame->getPelBufferYUV()[ch][0];
|
||||
|
||||
Mat outputMask( m_pcOutputFrame->getHeight( ch ), m_pcOutputFrame->getWidth( ch ), CV_8UC1, Scalar( 1 ) );
|
||||
for( unsigned y = 0; y < m_pcOutputFrame->getHeight( ch ); y++ )
|
||||
Mat outputMask( m_pcResultedFrame->getHeight( ch ), m_pcResultedFrame->getWidth( ch ), CV_8UC1, Scalar( 1 ) );
|
||||
for( unsigned y = 0; y < m_pcResultedFrame->getHeight( ch ); y++ )
|
||||
{
|
||||
for( unsigned x = 0; x < m_pcOutputFrame->getWidth( ch ); x++ )
|
||||
for( unsigned x = 0; x < m_pcResultedFrame->getWidth( ch ); x++ )
|
||||
{
|
||||
Point pt = reshapePoints.at<Point>( y, x );
|
||||
if( pt.x > -1 )
|
||||
@@ -659,9 +659,9 @@ void ThreeSixtyDownsampling::downsamplingOperation( CalypFrame* pcInputFrame )
|
||||
if( m_iInpaintMethod )
|
||||
{
|
||||
Mat outputFrameUnfilled, outputFrame;
|
||||
m_pcOutputFrame->toMat( outputFrameUnfilled, true, false, ch );
|
||||
m_pcResultedFrame->toMat( outputFrameUnfilled, true, false, ch );
|
||||
cv::inpaint( outputFrameUnfilled, outputMask, outputFrame, 16, m_iInpaintMethod );
|
||||
m_pcOutputFrame->fromMat( outputFrame, ch );
|
||||
m_pcResultedFrame->fromMat( outputFrame, ch );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,7 +670,7 @@ void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
{
|
||||
unsigned numBytes = m_pcDownsampled->getBitsPel() > 8 ? 2 : 1;
|
||||
m_pcDownsampled->reset();
|
||||
m_pcOutputFrame->reset();
|
||||
m_pcResultedFrame->reset();
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat_<Point> reshapePoints = *( m_cvReshapePoints[ch] );
|
||||
@@ -689,7 +689,7 @@ void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
|
||||
Mat cvDownsampled;
|
||||
m_pcDownsampled->toMat( cvDownsampled, true, false, ch );
|
||||
int imH = m_pcOutputFrame->getHeight( ch );
|
||||
int imH = m_pcResultedFrame->getHeight( ch );
|
||||
Mat cvUpsample( 1, 2 * imH, numBytes > 2 ? CV_16UC1 : CV_8UC1 );
|
||||
for( int y = 0; y < imH; y++ )
|
||||
{
|
||||
@@ -700,7 +700,7 @@ void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
cv::resize( cvDownsampled.row( y ).colRange( xpos, xpos + lineWidth ), cvUpsample, cvUpsample.size(), 0, 0, m_iInterpolation );
|
||||
|
||||
// copy to output
|
||||
ClpPel* outpel = &m_pcOutputFrame->getPelBufferYUV()[ch][y][0];
|
||||
ClpPel* outpel = &m_pcResultedFrame->getPelBufferYUV()[ch][y][0];
|
||||
unsigned char* cv_data = cvUpsample.data;
|
||||
for( int i = 0; i < 2 * imH; i++ )
|
||||
{
|
||||
@@ -713,7 +713,7 @@ void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
}
|
||||
}
|
||||
}
|
||||
//m_pcOutputFrame->copyFrom( m_pcDownsampled );
|
||||
//m_pcResultedFrame->copyFrom( m_pcDownsampled );
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
@@ -725,9 +725,9 @@ CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameLi
|
||||
}
|
||||
if( m_uiDownsampling == 0 || m_uiDownsampling == 2 )
|
||||
{
|
||||
upsamplingOperation( m_uiDownsampling == 2 ? m_pcOutputFrame : apcFrameList[0] );
|
||||
upsamplingOperation( m_uiDownsampling == 2 ? m_pcResultedFrame : apcFrameList[0] );
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
return m_pcResultedFrame;
|
||||
}
|
||||
|
||||
bool ThreeSixtyDownsampling::keyPressed( enum Module_Key_Supported value )
|
||||
@@ -761,7 +761,7 @@ void ThreeSixtyDownsampling::destroy()
|
||||
if( m_pcDownsampled )
|
||||
delete m_pcDownsampled;
|
||||
m_pcDownsampled = NULL;
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
if( m_pcResultedFrame )
|
||||
delete m_pcResultedFrame;
|
||||
m_pcResultedFrame = NULL;
|
||||
}
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
|
||||
double m_dPixelRatio;
|
||||
|
||||
CalypFrame* m_pcResultedFrame;
|
||||
CalypFrame* m_pcDownsampled;
|
||||
|
||||
// Values one per channel
|
||||
|
||||
@@ -55,6 +55,8 @@ private:
|
||||
unsigned m_uiFaceWidth;
|
||||
unsigned m_uiFaceHeight;
|
||||
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
|
||||
public:
|
||||
ThreeSixtyDynamicDownsampling();
|
||||
virtual ~ThreeSixtyDynamicDownsampling() {}
|
||||
|
||||
@@ -56,8 +56,6 @@ ThreeSixtyFaceConcatenation::ThreeSixtyFaceConcatenation()
|
||||
m_uiNumberOfPartitionsPerFace = 1;
|
||||
m_uiFacesX = 0;
|
||||
m_uiFacesY = 0;
|
||||
|
||||
m_pcTmpFrame = NULL;
|
||||
}
|
||||
|
||||
bool ThreeSixtyFaceConcatenation::create( std::vector<CalypFrame*> apcFrameList )
|
||||
@@ -90,14 +88,14 @@ bool ThreeSixtyFaceConcatenation::create( std::vector<CalypFrame*> apcFrameList
|
||||
unsigned int width = apcFrameList[0]->getWidth() * m_uiFacesX;
|
||||
unsigned int height = apcFrameList[0]->getHeight() * m_uiFacesY;
|
||||
|
||||
m_pcOutputFrame = new CalypFrame( width, height, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
m_pcConcatenatedFaces = std::make_unique<CalypFrame>( width, height, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyFaceConcatenation::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
m_pcConcatenatedFaces->reset();
|
||||
|
||||
switch( m_uiProjectionType )
|
||||
{
|
||||
@@ -107,19 +105,16 @@ CalypFrame* ThreeSixtyFaceConcatenation::process( std::vector<CalypFrame*> apcFr
|
||||
CalypFrame* pcFrame = apcFrameList[i];
|
||||
unsigned x = i % m_uiFacesX * pcFrame->getWidth();
|
||||
unsigned y = i / m_uiFacesX * pcFrame->getHeight();
|
||||
m_pcOutputFrame->copyTo( pcFrame, x, y );
|
||||
m_pcConcatenatedFaces->copyTo( pcFrame, x, y );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
return m_pcOutputFrame;
|
||||
return m_pcConcatenatedFaces.get();
|
||||
}
|
||||
|
||||
void ThreeSixtyFaceConcatenation::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class ThreeSixtyFaceConcatenation : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyFaceConcatenation )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcTmpFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcConcatenatedFaces;
|
||||
unsigned m_uiProjectionType;
|
||||
unsigned m_uiNumberOfPartitionsPerFace;
|
||||
unsigned m_uiFacesX;
|
||||
|
||||
@@ -77,14 +77,14 @@ bool ThreeSixtyFaceExtraction::create( std::vector<CalypFrame*> apcFrameList )
|
||||
unsigned int width = apcFrameList[0]->getWidth() / m_uiFacesX;
|
||||
unsigned int height = apcFrameList[0]->getHeight() / m_uiFacesY;
|
||||
|
||||
m_pcOutputFrame = new CalypFrame( width, height, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
m_pcFrameExtractionFrame = std::make_unique<CalypFrame>( width, height, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyFaceExtraction::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
m_pcFrameExtractionFrame->reset();
|
||||
|
||||
unsigned x = -1;
|
||||
unsigned y = -1;
|
||||
@@ -92,20 +92,17 @@ CalypFrame* ThreeSixtyFaceExtraction::process( std::vector<CalypFrame*> apcFrame
|
||||
switch( m_uiProjectionType )
|
||||
{
|
||||
case 1: // Cube-map
|
||||
x = m_uiFaceNum % m_uiFacesX * m_pcOutputFrame->getWidth();
|
||||
y = ( m_uiFaceNum / m_uiFacesX ) * m_pcOutputFrame->getHeight();
|
||||
x = m_uiFaceNum % m_uiFacesX * m_pcFrameExtractionFrame->getWidth();
|
||||
y = ( m_uiFaceNum / m_uiFacesX ) * m_pcFrameExtractionFrame->getHeight();
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
m_pcOutputFrame->copyFrom( apcFrameList[0], x, y );
|
||||
return m_pcOutputFrame;
|
||||
m_pcFrameExtractionFrame->copyFrom( apcFrameList[0], x, y );
|
||||
return m_pcFrameExtractionFrame.get();
|
||||
}
|
||||
|
||||
void ThreeSixtyFaceExtraction::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -32,7 +32,8 @@ class ThreeSixtyFaceExtraction : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyFaceExtraction )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcTmpFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcFrameExtractionFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcTmpFrame;
|
||||
unsigned m_uiFaceNum;
|
||||
unsigned m_uiProjectionType;
|
||||
unsigned m_uiNumberOfPartitionsPerFace;
|
||||
|
||||
@@ -25,14 +25,10 @@
|
||||
#include "ThreeSixtyNxN.h"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
//#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/photo.hpp>
|
||||
#include <vector>
|
||||
|
||||
//using cv::InputArray;
|
||||
//using cv::OutputArray;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
using cv::Size;
|
||||
@@ -147,7 +143,6 @@ void ThreeSixtyNxN::downsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
ClpPel* in = &pcInputFrame->getPelBufferYUV()[ch][0][0];
|
||||
ClpPel* out = &m_pcOutputFrame->getPelBufferYUV()[ch][0][0];
|
||||
|
||||
unsigned long nn = N * N;
|
||||
int n_2 = N / 2;
|
||||
int n1 = N - 1;
|
||||
double dist_y;
|
||||
@@ -175,7 +170,6 @@ void ThreeSixtyNxN::downsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
rx = x + y * N + out;
|
||||
|
||||
*( rx ) = interpol_lanczos3( tx_y, tx_x, N * 2, max_value );
|
||||
//*( rx ) = interpol_cub( tx_y, tx_x, N * 2, max_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,9 +196,7 @@ void ThreeSixtyNxN::upsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
double Dj;
|
||||
double tx;
|
||||
ClpPel* rx;
|
||||
ClpPel* linhaY;
|
||||
|
||||
getMem1D( &linhaY, n2 );
|
||||
std::vector<ClpPel> linhaY( n2, 0 );
|
||||
|
||||
for( y = 0; y < N; y++ )
|
||||
{
|
||||
@@ -220,7 +212,7 @@ void ThreeSixtyNxN::upsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
novo_x = ( dist_x > dist_y ? dist_y : ( dist_x + 1 < -dist_y ? -dist_y - 1 : dist_x ) ) + N / 2;
|
||||
novo_y = abs( dist_x ) > dist_y ? ( y < N / 2 ? dist_Lj : N - dist_Lj - 1 ) : y;
|
||||
|
||||
*( linhaY + x ) = *( in + (int)novo_x + (int)novo_y * N );
|
||||
linhaY[x] = *( in + (int)novo_x + (int)novo_y * N );
|
||||
}
|
||||
|
||||
for( x = 0; x < n2; x++ )
|
||||
@@ -228,10 +220,9 @@ void ThreeSixtyNxN::upsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
tx = ( x + 1 ) / Dj - 1;
|
||||
rx = x + y * n2 + out;
|
||||
|
||||
*( rx ) = interpol_lanczos3( linhaY, tx, Lj, max_value );
|
||||
*( rx ) = interpol_lanczos3( linhaY.data(), tx, Lj, max_value );
|
||||
}
|
||||
}
|
||||
freeMem1D( linhaY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class ThreeSixtyNxN : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyNxN )
|
||||
private:
|
||||
unsigned m_uiDownsampling;
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
void downsamplingOperation( const CalypFrame* pcInputFrame );
|
||||
void upsamplingOperation( const CalypFrame* pcInputFrame );
|
||||
|
||||
|
||||
@@ -75,12 +75,17 @@ bool ThreeSixtySpatialtoTemporal::needFrame()
|
||||
return false;
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtySpatialtoTemporal::getProcessedFrame()
|
||||
{
|
||||
return m_pcTempSpatialFrame != nullptr ? m_pcTempSpatialFrame.get() : nullptr;
|
||||
}
|
||||
|
||||
bool ThreeSixtySpatialtoTemporal::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
unsigned int iWidth;
|
||||
unsigned int iHeight;
|
||||
unsigned int iWidth{ 0 };
|
||||
unsigned int iHeight{ 0 };
|
||||
|
||||
if( m_uiSpatial2Temporal )
|
||||
{
|
||||
@@ -93,10 +98,10 @@ bool ThreeSixtySpatialtoTemporal::create( std::vector<CalypFrame*> apcFrameList
|
||||
iWidth = apcFrameList[0]->getWidth() / m_uiFacesX;
|
||||
iHeight = apcFrameList[0]->getHeight() / m_uiFacesY;
|
||||
|
||||
m_pcTmpInputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
m_pcTmpFace = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
m_pcTmpInputFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
m_pcTmpFace = std::make_unique<CalypFrame>( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
iWidth *= m_uiFacesPerFrame;
|
||||
}
|
||||
else
|
||||
@@ -104,8 +109,8 @@ bool ThreeSixtySpatialtoTemporal::create( std::vector<CalypFrame*> apcFrameList
|
||||
iWidth = apcFrameList[0]->getWidth() * m_uiFacesX / m_uiFacesPerFrame;
|
||||
iHeight = apcFrameList[0]->getHeight() * m_uiFacesY;
|
||||
}
|
||||
m_pcOutputFrame = new CalypFrame( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
m_pcTempSpatialFrame = std::make_unique<CalypFrame>( iWidth, iHeight, apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel() );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,8 +130,8 @@ CalypFrame* ThreeSixtySpatialtoTemporal::process( std::vector<CalypFrame*> apcFr
|
||||
|
||||
for( unsigned i = 0; i < m_uiFacesPerFrame; i++ )
|
||||
{
|
||||
m_pcTmpFace->copyFrom( m_pcTmpInputFrame, m_uiCopyX, m_uiCopyY );
|
||||
m_pcOutputFrame->copyTo( m_pcTmpFace, m_pcTmpFace->getWidth() * i, 0 );
|
||||
m_pcTmpFace->copyFrom( *m_pcTmpInputFrame, m_uiCopyX, m_uiCopyY );
|
||||
m_pcTempSpatialFrame->copyTo( *m_pcTmpFace, m_pcTmpFace->getWidth() * i, 0 );
|
||||
m_iFrameBufferCount--;
|
||||
m_uiCopyX += m_pcTmpFace->getWidth();
|
||||
if( m_uiCopyX >= m_pcTmpInputFrame->getWidth() )
|
||||
@@ -138,40 +143,28 @@ CalypFrame* ThreeSixtySpatialtoTemporal::process( std::vector<CalypFrame*> apcFr
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcOutputFrame->copyTo( apcFrameList[0], m_uiCopyX, m_uiCopyY );
|
||||
m_pcTempSpatialFrame->copyTo( apcFrameList[0], m_uiCopyX, m_uiCopyY );
|
||||
m_uiFacesCount += m_uiFacesPerFrame;
|
||||
|
||||
m_uiCopyX += apcFrameList[0]->getWidth();
|
||||
if( m_uiCopyX >= m_pcOutputFrame->getWidth() )
|
||||
if( m_uiCopyX >= m_pcTempSpatialFrame->getWidth() )
|
||||
{
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY += apcFrameList[0]->getHeight();
|
||||
}
|
||||
if( m_uiFacesCount < ( m_uiFacesX * m_uiFacesY ) )
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
m_iFrameBufferCount = 0;
|
||||
m_uiCopyX = 0;
|
||||
m_uiCopyY = 0;
|
||||
m_uiFacesCount = 0;
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
return m_pcOutputFrame;
|
||||
return m_pcTempSpatialFrame.get();
|
||||
}
|
||||
|
||||
void ThreeSixtySpatialtoTemporal::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
|
||||
if( m_pcTmpInputFrame )
|
||||
delete m_pcTmpInputFrame;
|
||||
m_pcTmpInputFrame = NULL;
|
||||
|
||||
if( m_pcTmpFace )
|
||||
delete m_pcTmpFace;
|
||||
m_pcTmpFace = NULL;
|
||||
}
|
||||
@@ -33,8 +33,9 @@ class ThreeSixtySpatialtoTemporal : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtySpatialtoTemporal )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcTmpInputFrame;
|
||||
CalypFrame* m_pcTmpFace;
|
||||
std::unique_ptr<CalypFrame> m_pcTempSpatialFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcTmpInputFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcTmpFace;
|
||||
bool m_uiSpatial2Temporal;
|
||||
unsigned int m_uiFacesX;
|
||||
unsigned int m_uiFacesY;
|
||||
@@ -46,11 +47,12 @@ private:
|
||||
public:
|
||||
ThreeSixtySpatialtoTemporal();
|
||||
virtual ~ThreeSixtySpatialtoTemporal() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
bool needFrame();
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
bool flush();
|
||||
void destroy();
|
||||
bool create( std::vector<CalypFrame*> apcFrameList ) override;
|
||||
CalypFrame* getProcessedFrame() override;
|
||||
bool needFrame() override;
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList ) override;
|
||||
bool flush() override;
|
||||
void destroy() override;
|
||||
};
|
||||
|
||||
#endif // __THREESIXTYSPATIALTOTEMPORAL_H__
|
||||
Reference in new issue
Block a user