Compare commits
36
Commits
b7ad00a4c5
..
2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b4cdddde4 | ||
|
|
c43cb2bd0a | ||
|
|
e6970fb953 | ||
|
|
aac02a9959 | ||
|
|
500e0e85ba | ||
|
|
d4886a7fee | ||
|
|
f3919ac8e8 | ||
|
|
562fd915fe | ||
|
|
f3df40cdf7 | ||
|
|
1bb2773abc | ||
|
|
a5e0554286 | ||
|
|
dc56de6f30 | ||
|
|
0cc89ab949 | ||
|
|
480a7f1d38 | ||
|
|
bb2a1ac228 | ||
|
|
90a5c32bb6 | ||
|
|
acc9d8ea98 | ||
|
|
6f91b6c04f | ||
|
|
b1ca7dff0b | ||
|
|
f5df1b3f9d | ||
|
|
bd1bbef22b | ||
|
|
3a9aa5e498 | ||
|
|
5499312fca | ||
|
|
93cf60e34a | ||
|
|
09ec5213c3 | ||
|
|
26f3dc7612 | ||
|
|
6ce220be82 | ||
|
|
cc84c42fd4 | ||
|
|
8d2a9e6100 | ||
|
|
c05aa73e86 | ||
|
|
ddc9f40329 | ||
|
|
e87049dccf | ||
|
|
1c1afa7bfc | ||
|
|
366d69b5c9 | ||
|
|
26a718a06a | ||
|
|
3b31453221 |
No files matched your search
+3
-1
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, -cppcoreguidelines-pro-bounds-constant-array-index, -readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
@@ -41,3 +41,5 @@ CheckOptions:
|
||||
value: '0'
|
||||
- key: google-readability-function-size.StatementThreshold
|
||||
value: '800'
|
||||
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
|
||||
value: '1'
|
||||
@@ -13,7 +13,7 @@ env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
check-build:
|
||||
# The CMake configure and build commands are platform agnostic and should work equally
|
||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||
# cross-platform coverage.
|
||||
@@ -26,12 +26,36 @@ jobs:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build with default options
|
||||
# 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 -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON; cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build without threads
|
||||
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON -DCALYP_MANAGED_RESOURCES=OFF -DCALYP_THREADED_MODULES=OFF; cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
check-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install gcc-10 g++-10 cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Check out tests data
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
repository: 'pixlra/calyp-testdata'
|
||||
path: ${{github.workspace}}/tests_data
|
||||
|
||||
- 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 -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
|
||||
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON -DCALYP_TEST_DATA_DIR=${{github.workspace}}/tests_data
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: CalypLib tests
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t test
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Created by https://www.gitignore.io/api/c++,clion,linux
|
||||
# Edit at https://www.gitignore.io/?templates=c++,clion,linux
|
||||
|
||||
deps/**
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
@@ -146,4 +146,4 @@ doc/
|
||||
compile_commands.json
|
||||
|
||||
# Build dirs
|
||||
build*
|
||||
build*
|
||||
+39
-13
@@ -18,8 +18,8 @@ SET(PROJECT_LIBRARY
|
||||
)
|
||||
|
||||
SET(CALYP_VERSION_MAJOR "2")
|
||||
SET(CALYP_VERSION_MINOR "0")
|
||||
SET(CALYP_VERSION_PATCH "1")
|
||||
SET(CALYP_VERSION_MINOR "1")
|
||||
SET(CALYP_VERSION_PATCH "0")
|
||||
SET(CALYP_VERSION
|
||||
"${CALYP_VERSION_MAJOR}.${CALYP_VERSION_MINOR}.${CALYP_VERSION_PATCH}"
|
||||
CACHE INTERNAL "" FORCE
|
||||
@@ -47,7 +47,7 @@ OPTION(BUILD_APP "Build GUI Application" ON)
|
||||
OPTION(BUILD_TOOLS "Build Command Line Application" ON)
|
||||
OPTION(BUILD_EXAMPLES "Build Examples" OFF)
|
||||
OPTION(BUILD_DOC "Build Documentation" OFF)
|
||||
OPTION(BUILD_TESTS "Build Google Tests" OFF)
|
||||
OPTION(BUILD_TESTS "Build Tests" OFF)
|
||||
OPTION(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
|
||||
OPTION(BUILD_WITH_THREAD_SANITIZER "Build with thread sanitizer" OFF)
|
||||
|
||||
@@ -102,7 +102,11 @@ SET(UPDATE_CHANNEL
|
||||
# ####################################################################################################################################################
|
||||
# Dependencies
|
||||
# ####################################################################################################################################################
|
||||
INCLUDE(FetchContent)
|
||||
|
||||
SET(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/deps")
|
||||
|
||||
# Doxygen
|
||||
IF(BUILD_DOC)
|
||||
FIND_PACKAGE(Doxygen)
|
||||
SET(BUILD_DOC ${Doxygen_FOUND})
|
||||
@@ -114,15 +118,38 @@ SET_PACKAGE_PROPERTIES(
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
# Type safe
|
||||
FETCHCONTENT_DECLARE(
|
||||
type_safe
|
||||
GIT_REPOSITORY https://github.com/foonathan/type_safe
|
||||
GIT_TAG v0.2.2
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/deps/type_safe"
|
||||
)
|
||||
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
type_safe PROPERTIES
|
||||
URL "https://github.com/foonathan/type_safe"
|
||||
DESCRIPTION "Zero overhead abstractions that use the C++ type system to prevent bugs."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(type_safe)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/deps/type_safe/include/ ${CMAKE_BINARY_DIR}/deps/type_safe/external/debug_assert/)
|
||||
ADD_DEFINITIONS(-DTYPE_SAFE_ENABLE_ASSERTIONS=0 -DTYPE_SAFE_ENABLE_PRECONDITION_CHECKS=0 -DDEBUG_ASSERT_DISABLE)
|
||||
|
||||
# Catch2 and Google Tests
|
||||
IF(BUILD_TESTS)
|
||||
INCLUDE(FetchContent)
|
||||
FETCHCONTENT_DECLARE(googletest URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
SET(gtest_force_shared_crt
|
||||
ON
|
||||
CACHE BOOL "" FORCE
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(googletest)
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.1
|
||||
)
|
||||
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
googletest PROPERTIES
|
||||
URL "https://github.com/google/googletest"
|
||||
@@ -130,19 +157,15 @@ IF(BUILD_TESTS)
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.1
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(Catch2)
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
Catch2 PROPERTIES
|
||||
URL "https://github.com/catchorg/Catch2"
|
||||
DESCRIPTION "Catch2 unit tests"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake)
|
||||
FETCHCONTENT_MAKEAVAILABLE(googletest Catch2)
|
||||
|
||||
INCLUDE(${CMAKE_BINARY_DIR}/deps/catch2-src/contrib/Catch.cmake)
|
||||
INCLUDE(CTest)
|
||||
ENABLE_TESTING()
|
||||
|
||||
@@ -152,6 +175,8 @@ IF(BUILD_TESTS)
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# OpenCV
|
||||
OPTION(USE_OPENCV "Add OpenCV support" ON)
|
||||
IF(USE_OPENCV)
|
||||
|
||||
@@ -177,6 +202,7 @@ SET_PACKAGE_PROPERTIES(
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
# FFmpeg
|
||||
OPTION(USE_FFMPEG "Add FFMPEG support" ON)
|
||||
IF(USE_FFMPEG)
|
||||
FIND_PACKAGE(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
|
||||
@@ -242,7 +268,7 @@ IF(USE_WERROR)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DCLP_DEBUG")
|
||||
IF(BUILD_WITH_SANITIZERS)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
|
||||
ENDIF()
|
||||
|
||||
@@ -97,7 +97,7 @@ void CalypAppModuleIf::update( bool isPlaying )
|
||||
// }
|
||||
// }
|
||||
|
||||
bool CalypAppModuleIf::isRunning()
|
||||
bool CalypAppModuleIf::isRunning() const
|
||||
{
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
return QThread::isRunning();
|
||||
@@ -119,7 +119,7 @@ void CalypAppModuleIf::run()
|
||||
bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
{
|
||||
bool moduleExecuted = false;
|
||||
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
@@ -130,7 +130,8 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
m_pcSubWindow[0]->setFillWindow( true );
|
||||
}
|
||||
}
|
||||
if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) )
|
||||
|
||||
if( !( isPlaying && m_pcModule->m_uiModuleRequirements.is_set( ClpModuleFeature::SkipWhilePlaying ) ) )
|
||||
{
|
||||
m_frameList.clear();
|
||||
for( unsigned int i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ )
|
||||
@@ -178,7 +179,7 @@ bool CalypAppModuleIf::process()
|
||||
m_frameListPtr.push_back( frame.get() );
|
||||
}
|
||||
|
||||
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
CalypFrame* framePtr{ nullptr };
|
||||
if( m_pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
@@ -192,7 +193,7 @@ bool CalypAppModuleIf::process()
|
||||
assert( framePtr != nullptr );
|
||||
m_pcProcessedFrame = std::shared_ptr<CalypFrame>{ framePtr, []( CalypFrame* ptr ) {} };
|
||||
}
|
||||
else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
else if( m_pcModule->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
{
|
||||
if( m_pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
{
|
||||
@@ -213,11 +214,13 @@ bool CalypAppModuleIf::process()
|
||||
|
||||
void CalypAppModuleIf::show()
|
||||
{
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
if( m_canceling )
|
||||
return;
|
||||
#endif
|
||||
switch( m_pcModule->m_iModuleType )
|
||||
{
|
||||
case CLP_FRAME_PROCESSING_MODULE: {
|
||||
case ClpModuleType::FrameProcessing: {
|
||||
auto displayWindow = qobject_cast<VideoSubWindow*>( m_pcDisplaySubWindow );
|
||||
if( displayWindow == nullptr )
|
||||
displayWindow = m_pcSubWindow[0];
|
||||
@@ -234,9 +237,11 @@ void CalypAppModuleIf::show()
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CLP_FRAME_MEASUREMENT_MODULE:
|
||||
case ClpModuleType::FrameMeasurement:
|
||||
m_pcModuleDock->setModuleReturnValue( m_dMeasurementResult );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ class QDockWidget;
|
||||
class CalypStream;
|
||||
class CalypFrame;
|
||||
|
||||
#define CLP_MODULE_MAX_NUM_FRAMES 5
|
||||
|
||||
class VideoSubWindow;
|
||||
class ModuleSubWindow;
|
||||
|
||||
@@ -60,7 +58,6 @@ class CalypAppModuleIf : std::enable_shared_from_this<CalypAppModuleIf>,
|
||||
#else
|
||||
public QObject
|
||||
#endif
|
||||
|
||||
{
|
||||
friend class ModulesHandle;
|
||||
friend class ModuleHandleDock;
|
||||
@@ -81,16 +78,16 @@ public:
|
||||
CalypAppModuleIf( QObject* parent, QAction* action, CalypModulePtr&& module );
|
||||
~CalypAppModuleIf();
|
||||
|
||||
auto getSubWindowList() -> const std::vector<VideoSubWindow*>& { return m_pcSubWindow; }
|
||||
auto getSubWindowList() const -> const std::vector<VideoSubWindow*>& { return m_pcSubWindow; }
|
||||
|
||||
CalypModuleIf* getModule() { return m_pcModule.get(); }
|
||||
unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
|
||||
std::string moduleInfo() { return m_pcModule->moduleInfo(); }
|
||||
auto getModuleRequirements() const -> ClpModuleFeatures { return m_pcModule->m_uiModuleRequirements; }
|
||||
std::string moduleInfo() const { return m_pcModule->moduleInfo(); }
|
||||
void update( bool isPlaying );
|
||||
bool apply( bool isPlaying = false, bool disableThreads = false );
|
||||
bool process();
|
||||
// void setPlaying( bool isPlaying );
|
||||
bool isRunning();
|
||||
bool isRunning() const;
|
||||
void show();
|
||||
void disable();
|
||||
|
||||
|
||||
+52
-31
@@ -79,15 +79,15 @@ MainWindow::MainWindow()
|
||||
setWindowTitle( QApplication::applicationName() );
|
||||
setWindowIcon( QIcon( ":logos/calyp-icon.png" ) );
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
setCentralWidget( m_pcWindowHandle );
|
||||
setCentralWidget( m_pcWindowHandle->getWidget() );
|
||||
setAcceptDrops( true );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::windowActivated, this, &MainWindow::update );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleVideo, &VideoHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleQuality, &QualityHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleExtensions, &ModulesHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::windowActivated, this, &MainWindow::updateMainWindow );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleVideo, &VideoHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleQuality, &QualityHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleExtensions, &ModulesHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
bool MainWindow::parseArgs( int argc, char* argv[] )
|
||||
@@ -185,7 +185,13 @@ void MainWindow::closeAll()
|
||||
m_pcWindowHandle->removeAllSubWindow();
|
||||
}
|
||||
|
||||
void MainWindow::loadFile( QString fileName, CalypFileInfo* pStreamInfo )
|
||||
void MainWindow::loadFile( CalypFileInfo pStreamInfo )
|
||||
{
|
||||
QString filename{ pStreamInfo.m_cFilename };
|
||||
loadFile( std::move( filename ), std::move( pStreamInfo ) );
|
||||
}
|
||||
|
||||
void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> streamInfo )
|
||||
{
|
||||
if( !QFileInfo( fileName ).exists() )
|
||||
{
|
||||
@@ -201,20 +207,30 @@ void MainWindow::loadFile( QString fileName, CalypFileInfo* pStreamInfo )
|
||||
videoSubWindow = new VideoStreamSubWindow(); // createSubWindow();
|
||||
videoSubWindow->setResourceManaget( m_appResourceHandle.get() );
|
||||
|
||||
if( !pStreamInfo )
|
||||
if( !streamInfo.has_value() )
|
||||
{
|
||||
int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
|
||||
pStreamInfo = (CalypFileInfo*)( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL );
|
||||
auto idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
|
||||
if( idx >= 0 )
|
||||
streamInfo = m_aRecentFileStreamInfo.at( idx );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
bool opened = false;
|
||||
|
||||
if( !pStreamInfo )
|
||||
if( streamInfo.has_value() )
|
||||
{
|
||||
try
|
||||
{
|
||||
opened = videoSubWindow->loadFile( std::move( *streamInfo ) );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if( !opened )
|
||||
opened = videoSubWindow->loadFile( fileName );
|
||||
else
|
||||
opened = videoSubWindow->loadFile( pStreamInfo );
|
||||
|
||||
if( opened )
|
||||
{
|
||||
@@ -304,7 +320,7 @@ void MainWindow::open()
|
||||
{
|
||||
if( !fileNameList.at( i ).isEmpty() )
|
||||
{
|
||||
loadFile( fileNameList.at( i ) );
|
||||
loadFile( std::move( fileNameList.at( i ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,9 +333,10 @@ void MainWindow::open()
|
||||
void MainWindow::openRecent()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>( sender() );
|
||||
CalypFileInfo recentFile = action->data().value<CalypFileInfo>();
|
||||
if( action )
|
||||
loadFile( recentFile.m_cFilename, &recentFile );
|
||||
{
|
||||
loadFile( action->data().value<CalypFileInfo>() );
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveFrame()
|
||||
@@ -399,7 +416,7 @@ void MainWindow::format()
|
||||
m_pcCurrentSubWindow->close();
|
||||
}
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
updateMainWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,7 +426,7 @@ void MainWindow::reload()
|
||||
{
|
||||
m_pcCurrentSubWindow->refreshSubWindow();
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
updateMainWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +447,7 @@ void MainWindow::reloadAll()
|
||||
}
|
||||
}
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
updateMainWindow();
|
||||
}
|
||||
|
||||
void MainWindow::loadAll()
|
||||
@@ -544,7 +561,7 @@ VideoStreamSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandl
|
||||
|
||||
// ----------------------- Update Functions -----------------------
|
||||
|
||||
void MainWindow::update()
|
||||
void MainWindow::updateMainWindow()
|
||||
{
|
||||
SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
QCoreApplication::processEvents();
|
||||
@@ -598,10 +615,17 @@ void MainWindow::updateMenus()
|
||||
{
|
||||
bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 );
|
||||
|
||||
bool hasVideoStreamSubWindow = false;
|
||||
if( m_pcCurrentSubWindow )
|
||||
if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
hasVideoStreamSubWindow = true;
|
||||
bool hasVideoStreamSubWindow{ false };
|
||||
bool supportsFormat{ false };
|
||||
if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
{
|
||||
hasVideoStreamSubWindow = true;
|
||||
|
||||
if( auto* pcVideoSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
supportsFormat = pcVideoSubWindow->supportsFormatConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
|
||||
|
||||
@@ -611,7 +635,7 @@ void MainWindow::updateMenus()
|
||||
m_arrayActions[RELOAD_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasSubWindow );
|
||||
|
||||
m_arrayActions[FORMAT_ACT]->setEnabled( hasVideoStreamSubWindow );
|
||||
m_arrayActions[FORMAT_ACT]->setEnabled( supportsFormat );
|
||||
m_arrayActions[LOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow );
|
||||
|
||||
m_arrayActions[ZOOM_IN_ACT]->setEnabled( hasSubWindow );
|
||||
@@ -805,12 +829,9 @@ void MainWindow::createMenus()
|
||||
|
||||
menuBar()->addMenu( m_appModuleVideo->createVideoMenu() );
|
||||
menuBar()->addMenu( m_appModuleVideo->createImageMenu() );
|
||||
QMenu* QualityMenu = m_appModuleQuality->createMenu();
|
||||
menuBar()->addMenu( QualityMenu );
|
||||
QMenu* ModuleMenu = m_appModuleExtensions->createMenu();
|
||||
menuBar()->addMenu( ModuleMenu );
|
||||
QMenu* windowMenu = m_pcWindowHandle->createMenu();
|
||||
menuBar()->addMenu( windowMenu );
|
||||
menuBar()->addMenu( m_appModuleQuality->createMenu() );
|
||||
menuBar()->addMenu( m_appModuleExtensions->createMenu() );
|
||||
menuBar()->addMenu( m_pcWindowHandle->createMenu() );
|
||||
|
||||
menuBar()->addSeparator();
|
||||
|
||||
|
||||
+4
-2
@@ -39,6 +39,7 @@
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <optional>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoStreamSubWindow.h"
|
||||
@@ -76,7 +77,8 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
MainWindow();
|
||||
bool parseArgs( int argc, char* argv[] );
|
||||
void loadFile( QString fileName, CalypFileInfo* pStreamInfo = NULL );
|
||||
void loadFile( CalypFileInfo pStreamInfo );
|
||||
void loadFile( QString fileName, std::optional<CalypFileInfo> pStreamInfo = {} );
|
||||
|
||||
public Q_SLOTS:
|
||||
void printMessage( const QString& msg );
|
||||
@@ -117,7 +119,7 @@ private Q_SLOTS:
|
||||
void dragEnterEvent( QDragEnterEvent* event );
|
||||
void dropEvent( QDropEvent* event );
|
||||
|
||||
void update();
|
||||
void updateMainWindow();
|
||||
void updateZoomFactorSBox();
|
||||
|
||||
private:
|
||||
|
||||
@@ -69,7 +69,7 @@ void ModuleSubWindow::updateVideoWindowInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
if( module_ptr->getModuleRequirements() & CLP_MODULES_HAS_INFO )
|
||||
if( module_ptr->getModuleRequirements().is_set( ClpModuleFeature::HasInfo ) )
|
||||
{
|
||||
QStringList list = QString::fromStdString( module_ptr->moduleInfo() ).split( '\n' );
|
||||
windowInfoList.append( list );
|
||||
|
||||
+43
-50
@@ -36,7 +36,7 @@
|
||||
#include "modules/CalypModulesFactory.h"
|
||||
|
||||
ModulesHandle::ModulesHandle( QWidget* parent, SubWindowHandle* windowManager, VideoHandle* moduleVideo )
|
||||
: QWidget( parent ), m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
|
||||
: m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
|
||||
{
|
||||
setParent( m_pcParent );
|
||||
}
|
||||
@@ -51,32 +51,32 @@ void ModulesHandle::createActions()
|
||||
connect( m_pcActionMapper, SIGNAL( mapped( int ) ), this, SLOT( processOpt( int ) ) );
|
||||
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while
|
||||
// playing", parent() );
|
||||
// playing", m_pcParent );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module
|
||||
// refreshing while playing" );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
|
||||
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT] = new QAction( "Load external module", parent() );
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT] = new QAction( "Load external module", m_pcParent );
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT]->setStatusTip( "Load an externally build module" );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], SIGNAL( triggered() ), this, SLOT( loadExternalModule() ) );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], &QAction::triggered, this, &ModulesHandle::loadExternalModule );
|
||||
|
||||
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
|
||||
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", m_pcParent );
|
||||
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
|
||||
connect( m_arrayActions[APPLY_ALL_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( m_arrayActions[APPLY_ALL_ACT], APPLY_ALL_ACT );
|
||||
|
||||
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
|
||||
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", m_pcParent );
|
||||
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
|
||||
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_ACT );
|
||||
|
||||
m_arrayActions[DISABLE_ACT] = new QAction( "Disable Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ACT], SIGNAL( triggered() ), this, SLOT( destroyWindowModules() ) );
|
||||
m_arrayActions[DISABLE_ACT] = new QAction( "Disable Modules", m_pcParent );
|
||||
connect( m_arrayActions[DISABLE_ACT], &QAction::triggered, this, &ModulesHandle::destroyWindowModules );
|
||||
|
||||
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
|
||||
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", m_pcParent );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], &QAction::triggered, this, &ModulesHandle::destroyAllModulesIf );
|
||||
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", m_pcParent );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip(
|
||||
"Show module result in a new window. Some modules already force this "
|
||||
"feature" );
|
||||
@@ -85,20 +85,16 @@ void ModulesHandle::createActions()
|
||||
|
||||
QMenu* ModulesHandle::createMenu()
|
||||
{
|
||||
m_pcModulesMenu = new QMenu( "&Modules", this );
|
||||
m_pcModulesMenu = new QMenu( "&Modules", m_pcParent );
|
||||
buildMenu();
|
||||
return m_pcModulesMenu;
|
||||
}
|
||||
|
||||
void ModulesHandle::buildMenu()
|
||||
{
|
||||
QString ModuleIfinternalName;
|
||||
QAction* currAction;
|
||||
QMenu* currSubMenu;
|
||||
|
||||
for( int i = 0; i < m_arrayModulesActions.size(); i++ )
|
||||
for( auto& action : m_arrayModulesActions )
|
||||
{
|
||||
delete m_arrayModulesActions.at( i );
|
||||
delete action;
|
||||
}
|
||||
m_arrayModulesActions.clear();
|
||||
m_pcModulesMenu->clear();
|
||||
@@ -109,9 +105,9 @@ void ModulesHandle::buildMenu()
|
||||
for( ; it != moduleFactoryMap.end(); ++it )
|
||||
{
|
||||
auto pcCurrModuleIf = it->second();
|
||||
ModuleIfinternalName = QString::fromLocal8Bit( it->first );
|
||||
QString ModuleIfinternalName = QString::fromLocal8Bit( it->first );
|
||||
|
||||
currSubMenu = NULL;
|
||||
QMenu* currSubMenu{ nullptr };
|
||||
if( pcCurrModuleIf->m_iModuleAPI <= CLP_MODULE_API_2 )
|
||||
{
|
||||
if( pcCurrModuleIf->m_pchModuleCategory )
|
||||
@@ -132,7 +128,7 @@ void ModulesHandle::buildMenu()
|
||||
}
|
||||
}
|
||||
|
||||
currAction = new QAction( pcCurrModuleIf->getModuleLongName(), parent() );
|
||||
QAction* currAction = new QAction( pcCurrModuleIf->getModuleLongName(), m_pcParent );
|
||||
QString moduleTooltip = pcCurrModuleIf->m_pchModuleTooltip;
|
||||
if( pcCurrModuleIf->m_uiNumberOfFrames > 1 )
|
||||
moduleTooltip += QString( " | Requires %1 frames" ).arg( pcCurrModuleIf->m_uiNumberOfFrames );
|
||||
@@ -140,7 +136,7 @@ void ModulesHandle::buildMenu()
|
||||
currAction->setStatusTip( moduleTooltip );
|
||||
currAction->setData( ModuleIfinternalName );
|
||||
currAction->setCheckable( false );
|
||||
connect( currAction, SIGNAL( triggered() ), this, SLOT( activateModule() ) );
|
||||
connect( currAction, &QAction::triggered, this, &ModulesHandle::activateModule );
|
||||
m_arrayModulesActions.append( currAction );
|
||||
|
||||
if( currSubMenu )
|
||||
@@ -160,20 +156,20 @@ void ModulesHandle::buildMenu()
|
||||
|
||||
void ModulesHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
bool hasSubWindow = pcSubWindow ? true : false;
|
||||
QAction* currModuleAction;
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
|
||||
bool hasSubWindow = pcSubWindow != nullptr ? true : false;
|
||||
|
||||
for( int i = 0; i < m_arrayModulesActions.size(); i++ )
|
||||
{
|
||||
currModuleAction = m_arrayModulesActions.at( i );
|
||||
//currModuleAction->setEnabled( hasSubWindow );
|
||||
auto* currModuleAction = m_arrayModulesActions.at( i );
|
||||
// currModuleAction->setEnabled( hasSubWindow );
|
||||
currModuleAction->setChecked( false );
|
||||
}
|
||||
//for( int i = 0; i < m_pcModulesSubMenuList.size(); i++ )
|
||||
// for( int i = 0; i < m_pcModulesSubMenuList.size(); i++ )
|
||||
//{
|
||||
// m_pcModulesSubMenuList.at( i )->setEnabled( hasSubWindow );
|
||||
//}
|
||||
// }
|
||||
|
||||
for( int i = 0; i < m_arrayActions.size(); i++ )
|
||||
{
|
||||
@@ -213,7 +209,7 @@ void ModulesHandle::writeSettings()
|
||||
|
||||
void ModulesHandle::processOpt( int index )
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcSubWindow )
|
||||
{
|
||||
CalypAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule();
|
||||
@@ -262,7 +258,7 @@ void ModulesHandle::activateModule()
|
||||
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
|
||||
bool bTmpForceNewWindow = false;
|
||||
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( !pcVideoSubWindow )
|
||||
{
|
||||
return;
|
||||
@@ -287,7 +283,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
int minNumFrames = numberOfFrames;
|
||||
int maxNumFrames = numberOfFrames;
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULES_VARIABLE_NUM_FRAMES )
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements.is_set( ClpModuleFeature::VariableNumOfFrames ) )
|
||||
{
|
||||
minNumFrames = numberOfFrames;
|
||||
maxNumFrames = 255;
|
||||
@@ -336,7 +332,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
videoSubWindowList.clear();
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Error! Incompatible frames", CLP_LOG_ERROR );
|
||||
//destroyModuleIf( pcCurrAppModuleIf );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -351,7 +347,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )
|
||||
->printMessage( "Error! There is no windows to apply the module", CLP_LOG_ERROR );
|
||||
//destroyModuleIf( pcCurrAppModuleIf );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,13 +356,13 @@ void ModulesHandle::activateModule()
|
||||
pcCurrAppModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i );
|
||||
}
|
||||
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_OPTIONS )
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements.is_set( ClpModuleFeature::Options ) )
|
||||
{
|
||||
ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrAppModuleIf.get() );
|
||||
if( moduleOptDialog.runConfiguration() == QDialog::Rejected )
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Module canceled by user!", CLP_LOG_WARNINGS );
|
||||
//destroyModuleIf( pcCurrAppModuleIf );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -375,9 +371,9 @@ void ModulesHandle::activateModule()
|
||||
|
||||
QString windowName;
|
||||
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
|
||||
if( bShowModulesNewWindow || pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements.is_set( ClpModuleFeature::NewWindow ) )
|
||||
{
|
||||
auto pcModuleSubWindow = new ModuleSubWindow( pcCurrAppModuleIf.get() );
|
||||
pcModuleSubWindow->resetWindowName();
|
||||
@@ -394,7 +390,7 @@ void ModulesHandle::activateModule()
|
||||
pcCurrAppModuleIf->m_pcSubWindow[0]->setDisplayModule( pcCurrAppModuleIf.get() );
|
||||
}
|
||||
}
|
||||
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
{
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow = NULL;
|
||||
pcCurrAppModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrAppModuleIf.get() );
|
||||
@@ -434,7 +430,7 @@ void ModulesHandle::activateModule()
|
||||
if( !moduleCreated )
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Error! Module cannot be created", CLP_LOG_ERROR );
|
||||
//destroyModuleIf( pcCurrAppModuleIf );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -471,7 +467,7 @@ void ModulesHandle::activateModule()
|
||||
|
||||
void ModulesHandle::destroyWindowModules()
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcVideoSubWindow )
|
||||
{
|
||||
pcVideoSubWindow->disableAllModules();
|
||||
@@ -497,9 +493,6 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
if( !pcCurrModuleIf->m_pcModuleStream )
|
||||
{
|
||||
unsigned int Width = 0, Height = 0, FrameRate = 30;
|
||||
int BitsPixel, InputFormat = -1;
|
||||
|
||||
QString supported = tr( "Supported Files (" );
|
||||
QStringList formatsList;
|
||||
std::vector<CalypStreamFormat> supportedFmts = CalypStream::supportedWriteFormats();
|
||||
@@ -532,15 +525,15 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Width = pcCurrModuleIf->m_pcProcessedFrame->getWidth();
|
||||
Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat();
|
||||
BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel();
|
||||
FrameRate = 30;
|
||||
auto Width = pcCurrModuleIf->m_pcProcessedFrame->getWidth();
|
||||
auto Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
auto InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat();
|
||||
auto BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel();
|
||||
auto FrameRate = 30;
|
||||
|
||||
pcCurrModuleIf->m_pcModuleStream = std::unique_ptr<CalypStream>();
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel,
|
||||
CLP_LITTLE_ENDIAN, FrameRate, false ) )
|
||||
CLP_LITTLE_ENDIAN, FrameRate, CalypStream::Type::Output ) )
|
||||
{
|
||||
pcCurrModuleIf->m_pcModuleStream = nullptr;
|
||||
return;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class SubWindowHandle;
|
||||
class CalypAppModuleIf;
|
||||
class SubWindowHandle;
|
||||
|
||||
class ModulesHandle : public QWidget
|
||||
class ModulesHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "VideoSubWindow.h"
|
||||
|
||||
QualityHandle::QualityHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
: m_pcParent( parent ), m_pcMainWindowManager( windowManager )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void QualityHandle::createActions()
|
||||
|
||||
QMenu* QualityHandle::createMenu()
|
||||
{
|
||||
m_pcMenuQuality = new QMenu( "Quality", this );
|
||||
m_pcMenuQuality = new QMenu( "Quality", m_pcParent );
|
||||
m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" );
|
||||
m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() );
|
||||
m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] );
|
||||
@@ -82,8 +82,8 @@ QMenu* QualityHandle::createMenu()
|
||||
|
||||
QDockWidget* QualityHandle::createDock()
|
||||
{
|
||||
m_pcQualityHandleSideBar = new QualityMeasurementSidebar( m_pcParet, m_pcMainWindowManager );
|
||||
m_pcQualityHandleDock = new QDockWidget( tr( "Quality Measurement" ), this );
|
||||
m_pcQualityHandleSideBar = new QualityMeasurementSidebar( m_pcParent, m_pcMainWindowManager );
|
||||
m_pcQualityHandleDock = new QDockWidget( tr( "Quality Measurement" ), m_pcParent );
|
||||
m_pcQualityHandleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
m_pcQualityHandleDock->setWidget( m_pcQualityHandleSideBar );
|
||||
|
||||
@@ -98,7 +98,7 @@ QDockWidget* QualityHandle::createDock()
|
||||
|
||||
void QualityHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcCurrentVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
bool hasSubWindow = pcCurrentVideoSubWindow ? true : false;
|
||||
bool hasReference = false;
|
||||
bool isReference = false;
|
||||
@@ -179,7 +179,7 @@ void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
}
|
||||
pcReferenceWindow->stop();
|
||||
|
||||
ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames );
|
||||
ProgressBar* pcProgressBar = new ProgressBar( m_pcParent, numberOfFrames );
|
||||
|
||||
QVector<double>* padQualityValues = new QVector<double>[numberOfWindows + 1];
|
||||
double* padAverageQuality = new double[numberOfWindows + 1];
|
||||
@@ -247,7 +247,7 @@ void QualityHandle::slotQualityMetricChanged( int idx )
|
||||
|
||||
void QualityHandle::slotSelectCurrentAsReference()
|
||||
{
|
||||
VideoSubWindow* pcRefSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcRefSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcRefSubWindow )
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow;
|
||||
@@ -267,7 +267,7 @@ void QualityHandle::slotSelectCurrentAsReference()
|
||||
|
||||
void QualityHandle::slotPlotQualitySingle()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcSubWindow )
|
||||
{
|
||||
if( pcSubWindow->getRefSubWindow() )
|
||||
@@ -291,7 +291,7 @@ void QualityHandle::slotPlotQualitySingle()
|
||||
|
||||
void QualityHandle::slotPlotQualitySeveral()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcSubWindow )
|
||||
{
|
||||
QVector<VideoSubWindow*> apcWindowList;
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@
|
||||
class SubWindowHandle;
|
||||
class VideoSubWindow;
|
||||
|
||||
class QualityHandle : public QWidget
|
||||
class QualityHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void update( VideoSubWindow* currSubWindow );
|
||||
|
||||
private:
|
||||
QWidget* m_pcParet;
|
||||
QWidget* m_pcParent;
|
||||
SubWindowHandle* m_pcMainWindowManager;
|
||||
|
||||
enum
|
||||
|
||||
+17
-17
@@ -85,7 +85,7 @@ private:
|
||||
};
|
||||
|
||||
SubWindowHandle::SubWindowHandle( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
: m_pcApp( qobject_cast<MainWindow*>( parent ) )
|
||||
{
|
||||
m_iWindowMode = -1;
|
||||
m_pcWindowManagerLayout = NULL;
|
||||
@@ -94,7 +94,7 @@ SubWindowHandle::SubWindowHandle( QWidget* parent )
|
||||
m_apcSubWindowList.clear();
|
||||
m_apcMdiSubWindowList.clear();
|
||||
|
||||
m_pcApp = qobject_cast<MainWindow*>( parentWidget() );
|
||||
m_pcCentralWidget = new QWidget;
|
||||
// setWindowMode( DETACHEDSUBWINDOWMODE );
|
||||
setWindowMode( MDISUBWINDOWMODE );
|
||||
}
|
||||
@@ -152,8 +152,8 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() );
|
||||
m_apcSubWindowList.at( i )->show();
|
||||
}
|
||||
setVisible( false );
|
||||
parentWidget()->update();
|
||||
m_pcCentralWidget->setVisible( false );
|
||||
m_pcApp->update();
|
||||
m_pcApp->showNormal();
|
||||
qApp->processEvents();
|
||||
QSize screenSize = QGuiApplication::screens()[0]->availableGeometry().size();
|
||||
@@ -164,13 +164,13 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
|
||||
if( iWindowMode == MDISUBWINDOWMODE )
|
||||
{
|
||||
setVisible( true );
|
||||
m_pcCentralWidget->setVisible( true );
|
||||
m_pcMdiArea = new MdiArea;
|
||||
m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
|
||||
connect( m_pcMdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), this, SLOT( updateActiveSubWindow() ) );
|
||||
m_pcWindowManagerLayout = new QHBoxLayout( this );
|
||||
m_pcWindowManagerLayout = new QHBoxLayout( m_pcCentralWidget );
|
||||
m_pcWindowManagerLayout->addWidget( m_pcMdiArea );
|
||||
setLayout( m_pcWindowManagerLayout );
|
||||
m_pcCentralWidget->setLayout( m_pcWindowManagerLayout );
|
||||
for( int i = 0; i < m_apcSubWindowList.size(); i++ )
|
||||
{
|
||||
addMdiSubWindow( m_apcSubWindowList.at( i ) );
|
||||
@@ -320,11 +320,6 @@ void SubWindowHandle::removeActiveSubWindow()
|
||||
removeSubWindow( m_pcActiveWindow );
|
||||
}
|
||||
|
||||
SubWindowAbstract* SubWindowHandle::activeSubWindow() const
|
||||
{
|
||||
return m_pcActiveWindow;
|
||||
}
|
||||
|
||||
QList<SubWindowAbstract*> SubWindowHandle::findSubWindow( const unsigned int uiCategory ) const
|
||||
{
|
||||
QList<SubWindowAbstract*> apcSubWindowList;
|
||||
@@ -491,12 +486,12 @@ void SubWindowHandle::createActions()
|
||||
m_actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true );
|
||||
|
||||
m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( m_pcApp->style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
|
||||
connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) );
|
||||
|
||||
m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( m_pcApp->style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
|
||||
connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) );
|
||||
|
||||
@@ -519,14 +514,14 @@ void SubWindowHandle::createActions()
|
||||
|
||||
m_arrayActions[NEXT_WINDOWS_ACT] = new QAction( tr( "Ne&xt" ), this );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( m_pcApp->style()->standardIcon( QStyle::SP_ArrowRight ) ) );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) );
|
||||
// connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this,
|
||||
// SLOT( activateNextSubWindow() ) );
|
||||
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( m_pcApp->style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) );
|
||||
// connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ),
|
||||
// this, SLOT( activatePreviousSubWindow() ) );
|
||||
@@ -537,12 +532,17 @@ void SubWindowHandle::createActions()
|
||||
|
||||
QMenu* SubWindowHandle::createMenu()
|
||||
{
|
||||
m_pcMenuWindow = new QMenu( "&Window", this );
|
||||
m_pcMenuWindow = new QMenu( "&Window", m_pcApp );
|
||||
updateMenu();
|
||||
connect( m_pcMenuWindow, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
|
||||
return m_pcMenuWindow;
|
||||
}
|
||||
|
||||
auto SubWindowHandle::getWidget() -> QWidget*
|
||||
{
|
||||
return m_pcCentralWidget;
|
||||
}
|
||||
|
||||
void SubWindowHandle::updateMenu()
|
||||
{
|
||||
m_pcMenuWindow->clear();
|
||||
|
||||
+10
-2
@@ -42,7 +42,7 @@ class SubWindowAbstract;
|
||||
class MdiArea;
|
||||
class MdiSubWindow;
|
||||
|
||||
class SubWindowHandle : public QWidget
|
||||
class SubWindowHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,7 +53,12 @@ public:
|
||||
|
||||
void addSubWindow( SubWindowAbstract* widget );
|
||||
|
||||
SubWindowAbstract* activeSubWindow() const;
|
||||
template <class T = SubWindowAbstract>
|
||||
T* activeSubWindow() const
|
||||
{
|
||||
static_assert( std::is_base_of<SubWindowAbstract, T>::value, "T must inherit from SubWindowAbstract" );
|
||||
return qobject_cast<T*>( m_pcActiveWindow );
|
||||
}
|
||||
|
||||
QList<SubWindowAbstract*> findSubWindow( const unsigned int uiCategory = 0 ) const;
|
||||
QList<SubWindowAbstract*> findSubWindow( const QString& aName, const unsigned int uiCategory = 0 ) const;
|
||||
@@ -62,6 +67,8 @@ public:
|
||||
void createActions();
|
||||
QMenu* createMenu();
|
||||
|
||||
auto getWidget() -> QWidget*;
|
||||
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
@@ -76,6 +83,7 @@ private:
|
||||
int m_iWindowMode;
|
||||
QList<SubWindowAbstract*> m_apcSubWindowList;
|
||||
|
||||
QWidget* m_pcCentralWidget;
|
||||
QHBoxLayout* m_pcWindowManagerLayout;
|
||||
MdiArea* m_pcMdiArea;
|
||||
QList<MdiSubWindow*> m_apcMdiSubWindowList;
|
||||
|
||||
+110
-15
@@ -42,9 +42,10 @@
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoStreamSubWindow.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
|
||||
VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
: m_pcParent( parent ), m_pcMainWindowManager( windowManager )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow = NULL;
|
||||
m_bIsPlaying = false;
|
||||
@@ -63,13 +64,13 @@ void VideoHandle::createActions()
|
||||
m_arrayActions.resize( TOTAL_ACT );
|
||||
m_arrayActions[PLAY_ACT] = new QAction( "Play", this );
|
||||
m_arrayActions[PLAY_ACT]->setStatusTip( "Play/Pause" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPlay ) ) );
|
||||
m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space );
|
||||
connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) );
|
||||
|
||||
m_arrayActions[STOP_ACT] = new QAction( "Stop", this );
|
||||
m_arrayActions[STOP_ACT]->setStatusTip( "Stop" );
|
||||
m_arrayActions[STOP_ACT]->setIcon( QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaStop ) ) );
|
||||
m_arrayActions[STOP_ACT]->setIcon( QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaStop ) ) );
|
||||
connect( m_arrayActions[STOP_ACT], SIGNAL( triggered() ), this, SLOT( stop() ) );
|
||||
|
||||
m_mapperVideoSeek = new QSignalMapper( this );
|
||||
@@ -78,7 +79,7 @@ void VideoHandle::createActions()
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon(
|
||||
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
|
||||
QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left );
|
||||
connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, SLOT( map() ) );
|
||||
m_mapperVideoSeek->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 );
|
||||
@@ -86,7 +87,7 @@ void VideoHandle::createActions()
|
||||
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setStatusTip( "Seek forward" );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon(
|
||||
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
|
||||
QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right );
|
||||
connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, SLOT( map() ) );
|
||||
m_mapperVideoSeek->setMapping( m_arrayActions[VIDEO_FORWARD_ACT], 1 );
|
||||
@@ -123,6 +124,24 @@ void VideoHandle::createActions()
|
||||
connect( m_pcFrameSlider, SIGNAL( valueChanged( int ) ), this, SLOT( seekSliderEvent( int ) ) );
|
||||
|
||||
// ------------ Image ------------
|
||||
m_mapperComponent = new QSignalMapper( this );
|
||||
m_actionGroupComponent = new QActionGroup( this );
|
||||
m_actionGroupComponent->setExclusive( true );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "All" ), -1 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Red" ), 0 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Green" ), 1 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Blue" ), 2 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Alpha" ), 3 );
|
||||
for( int i = 0; i < m_actionGroupComponent->actions().size(); i++ )
|
||||
{
|
||||
m_actionGroupComponent->actions().at( i )->setCheckable( true );
|
||||
m_actionGroupComponent->actions().at( i )->setVisible( false );
|
||||
connect( m_actionGroupComponent->actions().at( i ), SIGNAL( triggered() ), m_mapperComponent, SLOT( map() ) );
|
||||
}
|
||||
m_actionGroupComponent->actions().at( 0 )->setChecked( true );
|
||||
m_actionGroupComponent->actions().at( 0 )->setVisible( true );
|
||||
connect( m_mapperComponent, SIGNAL( mapped( int ) ), this, SLOT( setComponent( int ) ) );
|
||||
|
||||
m_actionGroupTools = new QActionGroup( this );
|
||||
m_actionGroupTools->setExclusive( true );
|
||||
|
||||
@@ -158,9 +177,11 @@ void VideoHandle::createActions()
|
||||
m_mapperGrid = new QSignalMapper( this );
|
||||
m_actionGroupGrid = new QActionGroup( this );
|
||||
m_actionGroupGrid->setExclusive( true );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "4x4" ), 4 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "8x8" ), 8 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "16x16" ), 16 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "64x64" ), 64 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "128x128" ), 128 );
|
||||
|
||||
for( int i = 0; i < m_actionGroupGrid->actions().size(); i++ )
|
||||
{
|
||||
@@ -178,7 +199,7 @@ void VideoHandle::createActions()
|
||||
|
||||
QMenu* VideoHandle::createVideoMenu()
|
||||
{
|
||||
m_pcMenuVideo = new QMenu( "Video", m_pcParet );
|
||||
m_pcMenuVideo = new QMenu( "Video", m_pcParent );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[STOP_ACT] );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] );
|
||||
@@ -193,7 +214,9 @@ QMenu* VideoHandle::createVideoMenu()
|
||||
|
||||
QMenu* VideoHandle::createImageMenu()
|
||||
{
|
||||
m_pcMenuImage = new QMenu( "Image", m_pcParet );
|
||||
m_pcMenuImage = new QMenu( "Image", m_pcParent );
|
||||
m_menuComponent = m_pcMenuImage->addMenu( "Component" );
|
||||
m_menuComponent->addActions( m_actionGroupComponent->actions() );
|
||||
m_pcMenuImage->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] );
|
||||
m_pcMenuImage->addAction( m_arrayActions[SELECTION_TOOL_ACT] );
|
||||
m_pcMenuImage->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] );
|
||||
@@ -228,8 +251,8 @@ QToolBar* VideoHandle::createToolBar()
|
||||
|
||||
QDockWidget* VideoHandle::createDock()
|
||||
{
|
||||
m_pcFramePropertiesSideBar = new FramePropertiesDock( m_pcParet, &m_bIsPlaying );
|
||||
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), m_pcParet );
|
||||
m_pcFramePropertiesSideBar = new FramePropertiesDock( m_pcParent, &m_bIsPlaying );
|
||||
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), m_pcParent );
|
||||
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar );
|
||||
connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged( bool ) ), this, SLOT( update() ) );
|
||||
@@ -268,9 +291,65 @@ QWidget* VideoHandle::createStatusBarMessage()
|
||||
return pcStatusBarWidget;
|
||||
}
|
||||
|
||||
void VideoHandle::updateComponentMenu()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcSubWindow == nullptr )
|
||||
{
|
||||
m_menuComponent->setEnabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* frame = pcSubWindow->getCurrFrame();
|
||||
if( frame == nullptr )
|
||||
{
|
||||
m_menuComponent->setEnabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
m_menuComponent->setEnabled( true );
|
||||
for( int i = 1; i < m_actionGroupComponent->actions().size(); i++ )
|
||||
{
|
||||
m_actionGroupComponent->actions()[i]->setChecked( false );
|
||||
m_actionGroupComponent->actions()[i]->setVisible( false );
|
||||
}
|
||||
switch( frame->getColorSpace() )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Gray" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
break;
|
||||
case CLP_COLOR_YUV:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Luminance" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 2 )->setText( QStringLiteral( "Chrominance U (Cb)" ) );
|
||||
m_actionGroupComponent->actions().at( 2 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 3 )->setText( QStringLiteral( "Chrominance V (Cr)" ) );
|
||||
m_actionGroupComponent->actions().at( 3 )->setVisible( true );
|
||||
break;
|
||||
case CLP_COLOR_RGBA:
|
||||
m_actionGroupComponent->actions().at( 4 )->setText( QStringLiteral( "Alpha" ) );
|
||||
m_actionGroupComponent->actions().at( 4 )->setVisible( true );
|
||||
[[fallthrough]];
|
||||
case CLP_COLOR_RGB:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Red" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 2 )->setText( QStringLiteral( "Green" ) );
|
||||
m_actionGroupComponent->actions().at( 2 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 3 )->setText( QStringLiteral( "Blue" ) );
|
||||
m_actionGroupComponent->actions().at( 3 )->setVisible( true );
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
auto component = pcSubWindow->getViewArea()->getFilteredChannel();
|
||||
int idx = component.has_value() ? *component : 0;
|
||||
m_actionGroupComponent->actions().at( idx )->setChecked( true );
|
||||
}
|
||||
|
||||
void VideoHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
bool hasSubWindow = pcSubWindow ? true : false;
|
||||
|
||||
m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow );
|
||||
@@ -296,6 +375,8 @@ void VideoHandle::updateMenus()
|
||||
m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[SHOW_GRID_ACT]->setEnabled( hasSubWindow );
|
||||
|
||||
updateComponentMenu();
|
||||
}
|
||||
|
||||
void VideoHandle::readSettings()
|
||||
@@ -387,12 +468,12 @@ void VideoHandle::update()
|
||||
if( m_pcCurrentVideoSubWindow->isPlaying() )
|
||||
{
|
||||
m_arrayActions[PLAY_ACT]->setText( "Pause" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPause ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPause ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arrayActions[PLAY_ACT]->setText( "Play" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPlay ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -716,7 +797,7 @@ void VideoHandle::playEvent()
|
||||
catch( const char* msg )
|
||||
{
|
||||
QString warningMsg = "Error while playing " + m_pcCurrentVideoSubWindow->getWindowName() + " with the following error: \n" + msg;
|
||||
QMessageBox::warning( m_pcParet, QApplication::applicationName(), warningMsg );
|
||||
QMessageBox::warning( m_pcParent, QApplication::applicationName(), warningMsg );
|
||||
qDebug() << warningMsg;
|
||||
stop();
|
||||
m_pcCurrentVideoSubWindow->close();
|
||||
@@ -757,7 +838,7 @@ void VideoHandle::seekVideo()
|
||||
{
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
SeekStreamDialog* dialogSeekVideo = new SeekStreamDialog( videoStreamSubWindow->getInputStream(), m_pcParet );
|
||||
SeekStreamDialog* dialogSeekVideo = new SeekStreamDialog( videoStreamSubWindow->getInputStream(), m_pcParent );
|
||||
int newFrameNum = dialogSeekVideo->runDialog();
|
||||
if( newFrameNum >= 0 )
|
||||
{
|
||||
@@ -815,7 +896,7 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
}
|
||||
else
|
||||
{
|
||||
SubWindowSelectorDialog dialogWindowsSelection( m_pcParet, m_pcMainWindowManager,
|
||||
SubWindowSelectorDialog dialogWindowsSelection( m_pcParent, m_pcMainWindowManager,
|
||||
SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
QStringList cWindowListNames;
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
@@ -860,6 +941,20 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::setComponent( int component )
|
||||
{
|
||||
if( m_pcCurrentVideoSubWindow == nullptr )
|
||||
return;
|
||||
if( component < 0 )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->getViewArea()->clearFilteredChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->getViewArea()->setFilteredChannel( static_cast<std::size_t>( component ) );
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::setTool( int tool )
|
||||
{
|
||||
m_uiViewTool = tool;
|
||||
|
||||
+8
-1
@@ -72,7 +72,7 @@ public:
|
||||
void addSubWindow( VideoSubWindow* subWindow );
|
||||
|
||||
private:
|
||||
QWidget* m_pcParet;
|
||||
QWidget* m_pcParent;
|
||||
SubWindowHandle* m_pcMainWindowManager;
|
||||
enum
|
||||
{
|
||||
@@ -97,6 +97,11 @@ private:
|
||||
QSlider* m_pcFrameSlider;
|
||||
FrameNumberWidget* m_pcFrameNumInfo;
|
||||
|
||||
// Filter component actions
|
||||
QMenu* m_menuComponent;
|
||||
QActionGroup* m_actionGroupComponent;
|
||||
QSignalMapper* m_mapperComponent;
|
||||
|
||||
// Tools Actions
|
||||
QActionGroup* m_actionGroupTools;
|
||||
QSignalMapper* m_mapperTools;
|
||||
@@ -131,6 +136,7 @@ private:
|
||||
void calculateRealFrameRate();
|
||||
unsigned long getMaxFrameNumber();
|
||||
void setTimerStatus();
|
||||
void updateComponentMenu();
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
@@ -150,6 +156,7 @@ private Q_SLOTS:
|
||||
void seekEvent( int direction );
|
||||
void seekVideo();
|
||||
void videoSelectionButtonEvent();
|
||||
void setComponent( int component );
|
||||
void setTool( int tool );
|
||||
void toggleGrid( bool checked );
|
||||
void setGridSize( int size );
|
||||
|
||||
@@ -49,7 +49,7 @@ QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& array )
|
||||
{
|
||||
d = array.at( i );
|
||||
out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness
|
||||
<< d.m_uiFrameRate << d.m_uiFileSize;
|
||||
<< d.m_uiFrameRate << d.m_uiFileSize << d.m_bForceRaw;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -69,12 +69,13 @@ QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array )
|
||||
in >> d.m_iEndianness;
|
||||
in >> d.m_uiFrameRate;
|
||||
in >> d.m_uiFileSize;
|
||||
in >> d.m_bForceRaw;
|
||||
array.append( d );
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
int findCalypStreamInfo( CalypFileInfoVector array, QString filename )
|
||||
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int
|
||||
{
|
||||
for( int i = 0; i < array.size(); i++ )
|
||||
if( array.at( i ).m_cFilename == filename )
|
||||
@@ -120,7 +121,7 @@ void VideoStreamSubWindow::updateVideoWindowInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_pcDisplayModule->getModuleRequirements() & CLP_MODULES_HAS_INFO )
|
||||
if( m_pcDisplayModule->getModuleRequirements() & ClpModuleFeature::HasInfo )
|
||||
{
|
||||
QStringList list = QString::fromStdString( m_pcDisplayModule->moduleInfo() ).split( '\n' );
|
||||
windowInfoList.append( list );
|
||||
@@ -165,7 +166,7 @@ bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
ConfigureFormatDialog formatDialog( this );
|
||||
unsigned int Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
|
||||
int Endianness = CLP_LITTLE_ENDIAN;
|
||||
int InputFormat = CLP_YUV420P;
|
||||
auto InputFormat = ClpPixelFormats::YUV420p;
|
||||
QSettings appSettings;
|
||||
|
||||
if( m_pCurrStream )
|
||||
@@ -187,7 +188,8 @@ bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
BitsPel = appSettings.value( "VideoStreamSubWindow/LastBitsPerPixel" ).value<unsigned int>();
|
||||
}
|
||||
}
|
||||
bool bRet = false;
|
||||
bool bRet{ false };
|
||||
bool forceRaw{ false };
|
||||
for( int iPass = 0; iPass < 2 && !bRet; iPass++ )
|
||||
{
|
||||
if( iPass || bConfig )
|
||||
@@ -200,23 +202,30 @@ bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
}
|
||||
try
|
||||
{
|
||||
bRet = m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, true );
|
||||
bRet = m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, iPass == 1, CalypStream::Type::Input );
|
||||
forceRaw = iPass > 0;
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
if( iPass == 1 )
|
||||
if( iPass > 0 )
|
||||
throw( e );
|
||||
}
|
||||
}
|
||||
|
||||
if( !bRet )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sStreamInfo.m_cFilename = cFilename;
|
||||
m_sStreamInfo.m_uiWidth = Width;
|
||||
m_sStreamInfo.m_uiHeight = Height;
|
||||
m_sStreamInfo.m_iPelFormat = InputFormat;
|
||||
m_sStreamInfo.m_iPelFormat = static_cast<std::int64_t>( InputFormat );
|
||||
m_sStreamInfo.m_uiBitsPelPixel = BitsPel;
|
||||
m_sStreamInfo.m_iEndianness = Endianness;
|
||||
m_sStreamInfo.m_uiFrameRate = FrameRate;
|
||||
m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size();
|
||||
m_sStreamInfo.m_bForceRaw = forceRaw;
|
||||
|
||||
QVariant var;
|
||||
var.setValue<unsigned int>( Width );
|
||||
@@ -242,21 +251,22 @@ bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::loadFile( CalypFileInfo* streamInfo )
|
||||
bool VideoStreamSubWindow::loadFile( CalypFileInfo streamInfo )
|
||||
{
|
||||
assert( m_pcResourceManager != nullptr );
|
||||
|
||||
m_uiResourceId = m_pcResourceManager->getResource( m_pCurrStream );
|
||||
m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
|
||||
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight,
|
||||
streamInfo->m_iPelFormat, streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
|
||||
streamInfo->m_uiFrameRate, true ) )
|
||||
if( !m_pCurrStream->open( streamInfo.m_cFilename.toStdString(), streamInfo.m_uiWidth, streamInfo.m_uiHeight,
|
||||
static_cast<ClpPixelFormats>( streamInfo.m_iPelFormat ), streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness,
|
||||
streamInfo.m_uiFrameRate, streamInfo.m_bForceRaw, CalypStream::Type::Input ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sStreamInfo = *streamInfo;
|
||||
m_cFilename = streamInfo.m_cFilename;
|
||||
m_sStreamInfo = std::move( streamInfo );
|
||||
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->startResourceWorker( m_uiResourceId );
|
||||
@@ -266,13 +276,12 @@ bool VideoStreamSubWindow::loadFile( CalypFileInfo* streamInfo )
|
||||
|
||||
refreshFrame();
|
||||
|
||||
m_cFilename = streamInfo->m_cFilename;
|
||||
updateVideoWindowInfo();
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel,
|
||||
bool VideoStreamSubWindow::guessFormat( const QString& filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel,
|
||||
int& rEndianness, unsigned int& rFrameRate )
|
||||
{
|
||||
std::vector<CalypStandardResolution> stdResList = CalypStream::stdResolutionSizes();
|
||||
@@ -290,12 +299,12 @@ bool VideoStreamSubWindow::guessFormat( QString filename, unsigned int& rWidth,
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
auto formats_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( std::size_t i = 0; i < formats_list.size(); i++ )
|
||||
const auto& formats_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( const auto& [key, name] : formats_list )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list[i].c_str(), Qt::CaseInsensitive ) )
|
||||
if( FilenameShort.contains( QString::fromStdString( std::string( name ) ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
rInputFormat = i;
|
||||
rInputFormat = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -318,7 +327,7 @@ bool VideoStreamSubWindow::guessFormat( QString filename, unsigned int& rWidth,
|
||||
}
|
||||
|
||||
// Guess resolution - match %dx%d
|
||||
//QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
// QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_[0-9]+x[0-9]+" ).match( FilenameShort );
|
||||
if( resolutionMatch.hasMatch() )
|
||||
{
|
||||
@@ -418,7 +427,7 @@ bool VideoStreamSubWindow::guessFormat( QString filename, unsigned int& rWidth,
|
||||
rEndianness = CLP_LITTLE_ENDIAN;
|
||||
}
|
||||
|
||||
if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 )
|
||||
if( rWidth > 0 && rHeight > 0 && rInputFormat != ClpPixelFormats::Invalid )
|
||||
bGuessed = true && !bGuessedByFilesize;
|
||||
}
|
||||
return !bGuessed;
|
||||
@@ -449,7 +458,7 @@ void VideoStreamSubWindow::refreshFrame()
|
||||
|
||||
if( m_pcDisplayModule )
|
||||
{
|
||||
//bool disableThreads = !m_bIsPlaying && hasAssociatedModule();
|
||||
// bool disableThreads = !m_bIsPlaying && hasAssociatedModule();
|
||||
m_pcDisplayModule->apply( m_bIsPlaying, true );
|
||||
bSetFrame = false;
|
||||
}
|
||||
@@ -509,7 +518,7 @@ bool VideoStreamSubWindow::goToNextFrame( bool bThreaded )
|
||||
return bEndOfSeq;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::saveStream( QString filename )
|
||||
bool VideoStreamSubWindow::saveStream( const QString& filename )
|
||||
{
|
||||
bool iRet = false;
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
@@ -44,22 +44,23 @@ class VideoStreamSubWindow;
|
||||
class ResourceHandle;
|
||||
class CalypAppModuleIf;
|
||||
|
||||
typedef struct
|
||||
struct CalypFileInfo
|
||||
{
|
||||
QString m_cFilename;
|
||||
unsigned int m_uiWidth;
|
||||
unsigned int m_uiHeight;
|
||||
int m_iPelFormat;
|
||||
unsigned int m_uiBitsPelPixel;
|
||||
unsigned int m_iEndianness;
|
||||
int m_iEndianness;
|
||||
unsigned int m_uiFrameRate;
|
||||
unsigned long long int m_uiFileSize;
|
||||
} CalypFileInfo;
|
||||
typedef QVector<CalypFileInfo> CalypFileInfoVector;
|
||||
bool m_bForceRaw{ false };
|
||||
};
|
||||
using CalypFileInfoVector = QVector<CalypFileInfo>;
|
||||
|
||||
QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d );
|
||||
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d );
|
||||
int findCalypStreamInfo( CalypFileInfoVector array, QString filename );
|
||||
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int;
|
||||
|
||||
class VideoStreamSubWindow : public VideoSubWindow
|
||||
{
|
||||
@@ -79,10 +80,12 @@ public:
|
||||
|
||||
void setResourceManaget( ResourceHandle* resourceManager ) { m_pcResourceManager = resourceManager; }
|
||||
|
||||
bool supportsFormatConfiguration() const { return m_pCurrStream->supportsFormatConfiguration(); };
|
||||
|
||||
bool loadFile( QString cFilename, bool bForceDialog = false );
|
||||
bool loadFile( CalypFileInfo* streamInfo );
|
||||
bool loadFile( CalypFileInfo streamInfo );
|
||||
void loadAll();
|
||||
bool saveStream( QString filename );
|
||||
bool saveStream( const QString& filename );
|
||||
|
||||
bool play();
|
||||
void pause();
|
||||
@@ -104,7 +107,7 @@ public:
|
||||
private:
|
||||
bool goToNextFrame( bool bThreaded );
|
||||
|
||||
static bool guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel,
|
||||
static bool guessFormat( const QString& filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel,
|
||||
int& rEndianness, unsigned int& rFrameRate );
|
||||
|
||||
private: // NO_LINT
|
||||
|
||||
+34
-55
@@ -34,13 +34,12 @@
|
||||
#include "SubWindowAbstract.h"
|
||||
|
||||
VideoInformation::VideoInformation( QWidget* parent )
|
||||
: QWidget( parent ), m_bBusyWindow( false )
|
||||
: QWidget( parent ), m_pcRefreshTimer{ new QTimer }, m_bBusyWindow( false )
|
||||
{
|
||||
setPalette( Qt::transparent );
|
||||
setAttribute( Qt::WA_TransparentForMouseEvents );
|
||||
m_cTopLeftTextFont.setPointSize( 8 );
|
||||
m_cCenterTextFont.setPointSize( 12 );
|
||||
m_pcRefreshTimer = new QTimer;
|
||||
m_pcRefreshTimer->setSingleShot( true );
|
||||
}
|
||||
|
||||
@@ -83,18 +82,21 @@ void VideoInformation::paintEvent( QPaintEvent* event )
|
||||
|
||||
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent )
|
||||
: SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category )
|
||||
, m_pcReferenceSubWindow( NULL )
|
||||
, m_pcUpdateTimer( NULL )
|
||||
, m_pcVideoInfo{ new VideoInformation{ this } }
|
||||
, m_pcScrollArea{ new QScrollArea }
|
||||
, m_cViewArea{ new ViewArea }
|
||||
, m_pcReferenceSubWindow{ nullptr }
|
||||
, m_pcUpdateTimer{ new QTimer{ this } }
|
||||
{
|
||||
// Create a new scroll area inside the sub-window
|
||||
m_pcScrollArea = new QScrollArea;
|
||||
|
||||
connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
|
||||
SLOT( updateScrollValues() ) );
|
||||
connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
|
||||
SLOT( updateScrollValues() ) );
|
||||
|
||||
// Create a new interface to show images
|
||||
m_cViewArea = new ViewArea;
|
||||
|
||||
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
|
||||
SLOT( adjustScrollBarByScale( double, QPoint ) ) );
|
||||
|
||||
@@ -102,7 +104,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
SIGNAL( zoomFactorChanged( double, QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
|
||||
//connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved( QPoint ) ) );
|
||||
// connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved( QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
|
||||
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint& ) ), this,
|
||||
@@ -118,12 +120,8 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
|
||||
m_associatedModules.clear();
|
||||
|
||||
m_pcUpdateTimer = new QTimer();
|
||||
m_pcUpdateTimer->setInterval( 800 );
|
||||
connect( m_pcUpdateTimer, SIGNAL( timeout() ), this, SLOT( updateWindowOnTimeout() ) );
|
||||
|
||||
//! Add video information
|
||||
m_pcVideoInfo = new VideoInformation( this );
|
||||
}
|
||||
|
||||
VideoSubWindow::~VideoSubWindow()
|
||||
@@ -158,7 +156,7 @@ void VideoSubWindow::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
if( m_pcDisplayModule )
|
||||
{
|
||||
if( m_pcDisplayModule->getModuleRequirements() & CLP_MODULE_USES_KEYS )
|
||||
if( m_pcDisplayModule->getModuleRequirements().is_set( ClpModuleFeature::KeysShortcuts ) )
|
||||
{
|
||||
bool bRet = false;
|
||||
switch( event->key() )
|
||||
@@ -371,7 +369,7 @@ void VideoSubWindow::refreshFrame()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoSubWindow::save( QString filename )
|
||||
bool VideoSubWindow::save( const QString& filename )
|
||||
{
|
||||
bool iRet = false;
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
@@ -398,7 +396,7 @@ QSize VideoSubWindow::getScrollSize()
|
||||
return QSize( m_pcScrollArea->viewport()->size().width() - 5, m_pcScrollArea->viewport()->size().height() - 5 );
|
||||
}
|
||||
|
||||
void VideoSubWindow::adjustScrollBarToRatio( const double& horRatio, const double& verRatio )
|
||||
void VideoSubWindow::adjustScrollBarToRatio( const double horRatio, const double verRatio )
|
||||
{
|
||||
QScrollBar* scrollBarH = m_pcScrollArea->horizontalScrollBar();
|
||||
QScrollBar* scrollBarV = m_pcScrollArea->verticalScrollBar();
|
||||
@@ -439,15 +437,11 @@ void VideoSubWindow::adjustScrollBarByScale( double scale, QPoint center )
|
||||
}
|
||||
else
|
||||
{
|
||||
int value;
|
||||
|
||||
int x = center.x() - cLastScroll.x();
|
||||
value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) );
|
||||
m_cCurrScroll.setX( value );
|
||||
m_cCurrScroll.setX( int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ) );
|
||||
|
||||
int y = center.y() - cLastScroll.y();
|
||||
value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) );
|
||||
m_cCurrScroll.setY( value );
|
||||
m_cCurrScroll.setY( int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ) );
|
||||
}
|
||||
|
||||
// Update window scroll
|
||||
@@ -464,15 +458,15 @@ void VideoSubWindow::updateScrollValues()
|
||||
double xPos = m_pcScrollArea->horizontalScrollBar()->value();
|
||||
double yPos = m_pcScrollArea->verticalScrollBar()->value();
|
||||
|
||||
m_cCurrScroll.setX( xPos );
|
||||
m_cCurrScroll.setY( yPos );
|
||||
m_cCurrScroll.setX( xPos != 0 );
|
||||
m_cCurrScroll.setY( yPos != 0 );
|
||||
|
||||
m_dHorScroll = m_dVerScroll = 0;
|
||||
|
||||
if( xPos )
|
||||
if( xPos != 0 )
|
||||
m_dHorScroll = xPos / double( m_pcScrollArea->horizontalScrollBar()->maximum() );
|
||||
|
||||
if( yPos )
|
||||
if( yPos != 0 )
|
||||
m_dVerScroll = yPos / double( m_pcScrollArea->verticalScrollBar()->maximum() );
|
||||
}
|
||||
|
||||
@@ -496,25 +490,21 @@ void VideoSubWindow::zoomToFit()
|
||||
|
||||
void VideoSubWindow::zoomToFactor( double factor, QPoint center )
|
||||
{
|
||||
double curFactor;
|
||||
curFactor = getScaleFactor();
|
||||
double curFactor = getScaleFactor();
|
||||
if( factor != curFactor )
|
||||
{
|
||||
double usedScale;
|
||||
usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, QSize() );
|
||||
double usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, QSize() );
|
||||
adjustScrollBarByScale( usedScale, center );
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSubWindow::scaleView( double scale, QPoint center )
|
||||
{
|
||||
Q_ASSERT( !m_cViewArea->image().isNull() );
|
||||
if( scale != 1.0 )
|
||||
{
|
||||
double usedScale;
|
||||
usedScale = m_cViewArea->scaleZoomFactor( scale, center, getScrollSize() );
|
||||
adjustScrollBarByScale( usedScale, center );
|
||||
}
|
||||
if( scale == 1.0 )
|
||||
return;
|
||||
|
||||
double usedScale = m_cViewArea->scaleZoomFactor( scale, center, getScrollSize() );
|
||||
adjustScrollBarByScale( usedScale, center );
|
||||
}
|
||||
|
||||
void VideoSubWindow::scaleView( const QSize& size, QPoint center )
|
||||
@@ -522,29 +512,20 @@ void VideoSubWindow::scaleView( const QSize& size, QPoint center )
|
||||
QSize imgViewSize;
|
||||
if( m_pcCurrFrameAsset )
|
||||
imgViewSize = QSize( m_pcCurrFrameAsset->getWidth(), m_pcCurrFrameAsset->getHeight() );
|
||||
//else
|
||||
// imgViewSize = QSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
// else
|
||||
// imgViewSize = QSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
QSize newSize = imgViewSize;
|
||||
newSize.scale( size, Qt::KeepAspectRatio );
|
||||
|
||||
// Calc the zoom factor
|
||||
double wfactor = 1;
|
||||
double hfactor = 1;
|
||||
double factor;
|
||||
|
||||
wfactor = (double)newSize.width() / imgViewSize.width();
|
||||
hfactor = (double)newSize.height() / imgViewSize.height();
|
||||
|
||||
if( wfactor < hfactor )
|
||||
factor = wfactor;
|
||||
else
|
||||
factor = hfactor;
|
||||
double wfactor = (double)newSize.width() / imgViewSize.width();
|
||||
double hfactor = (double)newSize.height() / imgViewSize.height();
|
||||
auto factor = std::min( wfactor, hfactor );
|
||||
|
||||
double curFactor = getScaleFactor();
|
||||
if( factor != curFactor )
|
||||
{
|
||||
double usedScale;
|
||||
usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, getScrollSize() );
|
||||
double usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center, getScrollSize() );
|
||||
adjustScrollBarByScale( usedScale, center );
|
||||
}
|
||||
}
|
||||
@@ -553,17 +534,15 @@ void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
||||
{
|
||||
if( m_pcCurrFrameAsset )
|
||||
{
|
||||
int iWidth, iHeight;
|
||||
int posX = pos.x();
|
||||
int posY = pos.y();
|
||||
QString strStatus;
|
||||
|
||||
iWidth = m_pcCurrFrameAsset->getWidth();
|
||||
iHeight = m_pcCurrFrameAsset->getHeight();
|
||||
int iWidth = m_pcCurrFrameAsset->getWidth();
|
||||
int iHeight = m_pcCurrFrameAsset->getHeight();
|
||||
|
||||
if( ( posX < iWidth ) && ( posX >= 0 ) && ( posY < iHeight ) && ( posY >= 0 ) )
|
||||
{
|
||||
strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
|
||||
QString strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
|
||||
|
||||
int colorSpace = m_pcCurrFrameAsset->getColorSpace();
|
||||
CalypPixel pixelValue = m_pcCurrFrameAsset->getPixel( pos.x(), pos.y() );
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void setBusyWindow( bool bFlag );
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void paintEvent( QPaintEvent* event ) override;
|
||||
|
||||
private:
|
||||
QTimer* m_pcRefreshTimer;
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
virtual auto getFrameNum() -> std::uint64_t { return 1; };
|
||||
|
||||
QString getVideoInformation() { return m_cStreamInformation; }
|
||||
bool save( QString filename );
|
||||
bool save( const QString& filename );
|
||||
|
||||
void setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame );
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
|
||||
void setFillWindow( bool bFlag );
|
||||
|
||||
void adjustScrollBarToRatio( const double& horRatio, const double& verRatio );
|
||||
void adjustScrollBarToRatio( const double horRatio, const double verRatio );
|
||||
|
||||
private:
|
||||
bool hasRunningModule();
|
||||
@@ -167,18 +167,18 @@ protected:
|
||||
VideoInformation* m_pcVideoInfo;
|
||||
QString m_cStreamInformation;
|
||||
std::shared_ptr<CalypFrame> m_pcCurrFrameAsset;
|
||||
//bool m_bWindowBusy;
|
||||
//bool m_bIsPlaying;
|
||||
// bool m_bWindowBusy;
|
||||
// bool m_bIsPlaying;
|
||||
|
||||
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
|
||||
CalypAppModuleIf* m_pcDisplayModule{ nullptr };
|
||||
//bool m_hasAssociatedModules;
|
||||
// bool m_hasAssociatedModules;
|
||||
|
||||
private:
|
||||
QScrollArea* m_pcScrollArea;
|
||||
QPoint m_cCurrScroll;
|
||||
double m_dHorScroll;
|
||||
double m_dVerScroll;
|
||||
double m_dHorScroll{ 0 };
|
||||
double m_dVerScroll{ 0 };
|
||||
ViewArea* m_cViewArea;
|
||||
QRect m_cSelectedArea;
|
||||
VideoSubWindow* m_pcReferenceSubWindow;
|
||||
|
||||
+94
-53
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ViewArea.h"
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
#include <QColor>
|
||||
@@ -42,9 +43,17 @@
|
||||
|
||||
#include "GridManager.h"
|
||||
|
||||
static const QColor selectionColor = Qt::cyan;
|
||||
static const QColor imageMaskColor = Qt::green;
|
||||
static const QColor eraserColor = Qt::red;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
||||
constexpr auto kSelectionColor = QColorConstants::Cyan;
|
||||
constexpr auto kImageMaskColor = QColorConstants::Green;
|
||||
constexpr auto kEraserColor = QColorConstants::Red;
|
||||
#else
|
||||
static const QColor kSelectionColor = Qt::cyan;
|
||||
static const QColor kImageMaskColor = Qt::green;
|
||||
static const QColor kEraserColor = Qt::red;
|
||||
#endif
|
||||
constexpr double kMaxZoom = 100.0;
|
||||
constexpr double kMinZoom = 0.01;
|
||||
|
||||
ViewArea::ViewArea( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
@@ -53,15 +62,6 @@ ViewArea::ViewArea( QWidget* parent )
|
||||
m_grid = GridManager();
|
||||
m_mask = QBitmap();
|
||||
m_selectedArea = QRect();
|
||||
m_dZoomFactor = 1;
|
||||
m_xOffset = 0;
|
||||
m_yOffset = 0;
|
||||
m_mode = NormalMode;
|
||||
m_eTool = NavigationTool;
|
||||
m_bGridVisible = false;
|
||||
m_snapToGrid = false;
|
||||
m_blockTrackEnable = false;
|
||||
m_visibleZoomRect = true;
|
||||
|
||||
m_zoomWinTimer.setSingleShot( true );
|
||||
m_zoomWinTimer.setInterval( 2000 );
|
||||
@@ -72,7 +72,15 @@ void ViewArea::setImage( std::shared_ptr<CalypFrame> frame )
|
||||
{
|
||||
m_nextFrame = frame;
|
||||
m_uiPixelHalfScale = 1 << ( m_nextFrame->getBitsPel() - 1 );
|
||||
m_nextFrame->fillRGBBuffer();
|
||||
if( m_filterSingleChannel.has_value() )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer();
|
||||
}
|
||||
|
||||
m_image = QImage( m_nextFrame->getRGBBuffer(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
@@ -86,14 +94,47 @@ void ViewArea::setImage( std::shared_ptr<CalypFrame> frame )
|
||||
initZoomWinRect();
|
||||
}
|
||||
|
||||
void ViewArea::clear()
|
||||
// void ViewArea::clear()
|
||||
// {
|
||||
// m_image = QImage();
|
||||
// m_mask = QBitmap();
|
||||
// m_mode = NormalMode;
|
||||
// updateSize();
|
||||
// update();
|
||||
// updateGeometry();
|
||||
// }
|
||||
|
||||
auto ViewArea::getFilteredChannel() -> std::optional<std::size_t>
|
||||
{
|
||||
m_image = QImage();
|
||||
m_mask = QBitmap();
|
||||
m_mode = NormalMode;
|
||||
updateSize();
|
||||
return m_filterSingleChannel;
|
||||
}
|
||||
|
||||
void ViewArea::setFilteredChannel( std::size_t channel )
|
||||
{
|
||||
m_filterSingleChannel = channel;
|
||||
if( m_nextFrame != nullptr )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
m_image = QImage( m_nextFrame->getRGBBuffer(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewArea::clearFilteredChannel()
|
||||
{
|
||||
m_filterSingleChannel = {};
|
||||
if( m_nextFrame != nullptr )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
m_image = QImage( m_nextFrame->getRGBBuffer(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
}
|
||||
update();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void ViewArea::setTool( unsigned int view )
|
||||
@@ -161,14 +202,14 @@ void ViewArea::setZoomFactor( double f )
|
||||
|
||||
double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize )
|
||||
{
|
||||
double maxZoom = 100.0;
|
||||
double minZoom = 0.01; //( 1.0 / m_image.width() );
|
||||
Q_ASSERT( !m_image.isNull() );
|
||||
|
||||
double new_scale = 1.0;
|
||||
|
||||
if( ( m_dZoomFactor == minZoom ) && ( scale < 1 ) )
|
||||
if( ( m_dZoomFactor == kMinZoom ) && ( scale < 1 ) )
|
||||
return new_scale;
|
||||
|
||||
if( ( m_dZoomFactor == maxZoom ) && ( scale > 1 ) )
|
||||
if( ( m_dZoomFactor == kMaxZoom ) && ( scale > 1 ) )
|
||||
return new_scale;
|
||||
|
||||
double newZoomFactor = m_dZoomFactor * scale * 100.0;
|
||||
@@ -209,16 +250,16 @@ double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize
|
||||
|
||||
new_scale = scale;
|
||||
|
||||
if( newZoomFactor < minZoom )
|
||||
if( newZoomFactor < kMinZoom )
|
||||
{
|
||||
newZoomFactor = minZoom;
|
||||
newZoomFactor = kMinZoom;
|
||||
new_scale = newZoomFactor / m_dZoomFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( newZoomFactor > maxZoom )
|
||||
if( newZoomFactor > kMaxZoom )
|
||||
{
|
||||
newZoomFactor = maxZoom;
|
||||
newZoomFactor = kMaxZoom;
|
||||
new_scale = newZoomFactor / m_dZoomFactor;
|
||||
}
|
||||
}
|
||||
@@ -474,12 +515,12 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
|
||||
// Draw a border around the image.
|
||||
/* if( m_xOffset || m_yOffset )
|
||||
{
|
||||
painter.setPen( Qt::black );
|
||||
painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_image.width() *
|
||||
m_dZoomFactor + 1, m_image.height() *
|
||||
m_dZoomFactor + 1 );
|
||||
}*/
|
||||
{
|
||||
painter.setPen( Qt::black );
|
||||
painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_image.width() *
|
||||
m_dZoomFactor + 1, m_image.height() *
|
||||
m_dZoomFactor + 1 );
|
||||
}*/
|
||||
|
||||
int frFormat = m_currFrame->getColorSpace();
|
||||
|
||||
@@ -567,16 +608,16 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
|
||||
QRect vr = windowToView( winRect );
|
||||
QRect cVisibleImg = vr & cImg;
|
||||
//cVisibleImg.moveTopLeft(vr.topLeft());
|
||||
// cVisibleImg.moveTopLeft(vr.topLeft());
|
||||
QRect cVisibleWinRect;
|
||||
cVisibleWinRect.setLeft( floor( (double)cVisibleImg.x() / dRatio ) );
|
||||
cVisibleWinRect.setTop( floor( (double)cVisibleImg.y() / dRatio ) );
|
||||
cVisibleWinRect.setRight( round( (double)cVisibleImg.right() / dRatio ) );
|
||||
cVisibleWinRect.setBottom( round( (double)cVisibleImg.bottom() / dRatio ) );
|
||||
|
||||
//painter.fillRect( cImgWinRect, QBrush( QColor( 128, 128, 128, 128 ) ) );
|
||||
// painter.fillRect( cImgWinRect, QBrush( QColor( 128, 128, 128, 128 ) ) );
|
||||
painter.setPen( QColor( 50, 50, 50, 128 ) );
|
||||
//painter.drawRect( cImgWinRect );
|
||||
// painter.drawRect( cImgWinRect );
|
||||
painter.setOpacity( 0.7 );
|
||||
painter.drawImage( cImgWinRect, m_image );
|
||||
painter.setOpacity( 1 );
|
||||
@@ -599,7 +640,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
painter.setPen( QColor( 255, 255, 255, 128 ) );
|
||||
painter.drawRect( cVisibleWinRect );
|
||||
|
||||
//qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio;
|
||||
// qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio;
|
||||
}
|
||||
|
||||
QRect sr = viewToWindow( m_selectedArea );
|
||||
@@ -610,7 +651,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_newShape || m_blockTrackEnable )
|
||||
{
|
||||
// Set the tool color
|
||||
QColor selectColor = selectionColor;
|
||||
QColor selectColor = kSelectionColor;
|
||||
|
||||
selectColor.setAlpha( 120 );
|
||||
|
||||
@@ -664,7 +705,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_maskColor.isValid() )
|
||||
color = m_maskColor;
|
||||
else
|
||||
color = imageMaskColor;
|
||||
color = kImageMaskColor;
|
||||
|
||||
color.setAlpha( 120 );
|
||||
painter.setPen( color );
|
||||
@@ -684,16 +725,16 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_maskColor.isValid() )
|
||||
color = m_maskColor;
|
||||
else
|
||||
color = imageMaskColor;
|
||||
color = kImageMaskColor;
|
||||
|
||||
break;
|
||||
}
|
||||
case EraserTool: {
|
||||
color = eraserColor;
|
||||
color = kEraserColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
color = selectionColor; // ?Problems!
|
||||
color = kSelectionColor; // ?Problems!
|
||||
}
|
||||
|
||||
color.setAlpha( 120 );
|
||||
@@ -898,18 +939,18 @@ void ViewArea::mouseMoveEvent( QMouseEvent* event )
|
||||
}
|
||||
}
|
||||
/* else // if tool() == BlockSelectionTool || MaskTool || EraserTool
|
||||
{
|
||||
m_blockTrackEnable = false;
|
||||
// If cursor is inside the selected area, we most redraw
|
||||
// the selection rect because it may be smaller.
|
||||
if( m_selectedArea.contains( actualPos ) )
|
||||
{
|
||||
m_selectedArea = m_grid.rectContains( m_lastPos );
|
||||
}
|
||||
{
|
||||
m_blockTrackEnable = false;
|
||||
// If cursor is inside the selected area, we most redraw
|
||||
// the selection rect because it may be smaller.
|
||||
if( m_selectedArea.contains( actualPos ) )
|
||||
{
|
||||
m_selectedArea = m_grid.rectContains( m_lastPos );
|
||||
}
|
||||
|
||||
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
|
||||
}
|
||||
*/
|
||||
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
|
||||
}
|
||||
*/
|
||||
if( tool() == SelectionTool )
|
||||
{
|
||||
// intercept the selected area with the image area to limit the
|
||||
|
||||
+22
-23
@@ -56,17 +56,15 @@ public:
|
||||
|
||||
ViewArea( QWidget* parent = 0 );
|
||||
|
||||
QImage& image() { return m_image; };
|
||||
void setImage( std::shared_ptr<CalypFrame> frame );
|
||||
|
||||
auto getFilteredChannel() -> std::optional<std::size_t>;
|
||||
void setFilteredChannel( std::size_t channel );
|
||||
void clearFilteredChannel();
|
||||
|
||||
void setMode( int mode );
|
||||
void setMaskColor( const QColor& color = QColor() );
|
||||
|
||||
/**
|
||||
* Clears any contents.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Select tool from the menu
|
||||
*/
|
||||
@@ -108,12 +106,12 @@ public Q_SLOTS:
|
||||
// void setSelectedArea( QRect &rect );
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
void mousePressEvent( QMouseEvent* event );
|
||||
void mouseMoveEvent( QMouseEvent* event );
|
||||
void mouseReleaseEvent( QMouseEvent* event );
|
||||
void wheelEvent( QWheelEvent* event );
|
||||
void paintEvent( QPaintEvent* event ) override;
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
void mousePressEvent( QMouseEvent* event ) override;
|
||||
void mouseMoveEvent( QMouseEvent* event ) override;
|
||||
void mouseReleaseEvent( QMouseEvent* event ) override;
|
||||
void wheelEvent( QWheelEvent* event ) override;
|
||||
|
||||
void updateSize();
|
||||
void updateOffset();
|
||||
@@ -149,34 +147,35 @@ private:
|
||||
QRect viewToWindow( const QRect& rc ) const;
|
||||
|
||||
std::shared_ptr<CalypFrame> m_currFrame;
|
||||
QImage m_image;
|
||||
std::shared_ptr<CalypFrame> m_nextFrame;
|
||||
|
||||
std::optional<std::size_t> m_filterSingleChannel;
|
||||
ClpPel m_uiPixelHalfScale;
|
||||
|
||||
Tool m_eTool;
|
||||
bool m_bGridVisible;
|
||||
Tool m_eTool{ NavigationTool };
|
||||
bool m_bGridVisible{ false };
|
||||
|
||||
QTimer m_zoomWinTimer;
|
||||
double m_dZoomWinRatio;
|
||||
double m_dZoomFactor;
|
||||
double m_dZoomFactor{ 1.0 };
|
||||
|
||||
QImage m_image;
|
||||
//QPixmap m_pixmap;
|
||||
// QPixmap m_pixmap;
|
||||
QBitmap m_mask;
|
||||
QRect m_selectedArea;
|
||||
QPoint m_lastPos;
|
||||
QPoint m_lastWindowPos;
|
||||
GridManager m_grid;
|
||||
ViewMode m_mode;
|
||||
ViewMode m_mode{ NormalMode };
|
||||
|
||||
QColor m_maskColor;
|
||||
int m_xOffset;
|
||||
int m_yOffset;
|
||||
bool m_blockTrackEnable;
|
||||
int m_xOffset{ 0 };
|
||||
int m_yOffset{ 0 };
|
||||
bool m_blockTrackEnable{ false };
|
||||
bool m_newShape;
|
||||
bool m_snapToGrid;
|
||||
bool m_snapToGrid{ false };
|
||||
bool m_cursorInGrid;
|
||||
bool m_visibleZoomRect;
|
||||
bool m_visibleZoomRect{ true };
|
||||
};
|
||||
|
||||
#endif // __VIEWAREA_H__
|
||||
@@ -382,8 +382,28 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent )
|
||||
setFixedSize( MainLayout->sizeHint() );
|
||||
}
|
||||
|
||||
auto findPelFormatColorSpace( ClpPixelFormats rInputFormat ) -> std::pair<int, std::int64_t>
|
||||
{
|
||||
if( rInputFormat != ClpPixelFormats::Invalid )
|
||||
{
|
||||
auto pelFmtName = CalypFrame::pixelFormatName( rInputFormat );
|
||||
for( unsigned int j = 0; j < CalypFrame::supportedColorSpacesListNames().size(); j++ )
|
||||
{
|
||||
const auto& formats_list = CalypFrame::supportedPixelFormatListNames( j );
|
||||
for( const auto& [key, name] : formats_list )
|
||||
{
|
||||
if( pelFmtName == name )
|
||||
{
|
||||
return std::make_pair( j, static_cast<int>( key ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::make_pair( 0, 0 );
|
||||
}
|
||||
|
||||
int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight,
|
||||
int& rInputFormat, unsigned int& rBits, int& rEndianess, unsigned int& rFrameRate )
|
||||
ClpPixelFormats& rInputFormat, unsigned int& rBits, int& rEndianess, unsigned int& rFrameRate )
|
||||
{
|
||||
// Set default values
|
||||
// setWindowTitle( "Configure resolution for " + Filename );
|
||||
@@ -391,24 +411,8 @@ int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, un
|
||||
m_spinBoxWidth->setValue( rWidth );
|
||||
m_spinBoxheight->setValue( rHeight );
|
||||
|
||||
int colorSpace = 0;
|
||||
int sampling = 0;
|
||||
if( rInputFormat >= 0 )
|
||||
{
|
||||
std::string pelFmtName = CalypFrame::supportedPixelFormatListNames()[rInputFormat];
|
||||
for( unsigned int j = 0; j < CalypFrame::supportedColorSpacesListNames().size(); j++ )
|
||||
{
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( j ).size(); i++ )
|
||||
{
|
||||
if( pelFmtName == CalypFrame::supportedPixelFormatListNames( j )[i] )
|
||||
{
|
||||
colorSpace = j;
|
||||
sampling = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
auto [colorSpace, sampling] = findPelFormatColorSpace( rInputFormat );
|
||||
|
||||
m_comboBoxColorSpace->setCurrentIndex( colorSpace );
|
||||
m_comboBoxPixelFormat->setCurrentIndex( sampling );
|
||||
m_spinBoxBits->setValue( rBits );
|
||||
@@ -441,16 +445,8 @@ int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, un
|
||||
rWidth = m_spinBoxWidth->value();
|
||||
rHeight = m_spinBoxheight->value();
|
||||
colorSpace = m_comboBoxColorSpace->currentIndex();
|
||||
sampling = m_comboBoxPixelFormat->currentIndex();
|
||||
std::string pelFmtName = CalypFrame::supportedPixelFormatListNames( colorSpace )[sampling];
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
if( pelFmtName == CalypFrame::supportedPixelFormatListNames()[i] )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sampling = m_comboBoxPixelFormat->currentData().toInt();
|
||||
rInputFormat = static_cast<ClpPixelFormats>( sampling );
|
||||
rBits = m_spinBoxBits->value();
|
||||
rEndianess = m_comboBoxEndianness->currentIndex();
|
||||
rFrameRate = m_spinBoxFrameRate->value();
|
||||
@@ -512,9 +508,10 @@ void ConfigureFormatDialog::slotColorSpaceChange( int idx )
|
||||
return;
|
||||
|
||||
m_comboBoxPixelFormat->clear();
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( idx ).size(); i++ )
|
||||
const auto& formats_list = CalypFrame::supportedPixelFormatListNames( idx );
|
||||
for( const auto& [key, name] : formats_list )
|
||||
{
|
||||
m_comboBoxPixelFormat->insertItem( i, CalypFrame::supportedPixelFormatListNames( idx )[i].c_str() );
|
||||
m_comboBoxPixelFormat->addItem( QString::fromStdString( std::string( name ) ), static_cast<int>( key ) );
|
||||
}
|
||||
m_comboBoxPixelFormat->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class QSpinBox;
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
typedef QVector<CalypStandardResolution> CalypStandardResolutionVector;
|
||||
using CalypStandardResolutionVector = QVector<CalypStandardResolution>;
|
||||
QDataStream& operator<<( QDataStream& out, const CalypStandardResolutionVector& array );
|
||||
QDataStream& operator>>( QDataStream& in, CalypStandardResolutionVector& array );
|
||||
|
||||
@@ -51,7 +51,7 @@ class ConfigureFormatDialog : public QDialog
|
||||
|
||||
public:
|
||||
ConfigureFormatDialog( QWidget* parent = 0 );
|
||||
int runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBits,
|
||||
int runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBits,
|
||||
int& rEndianess, unsigned int& rFrameRate );
|
||||
|
||||
void readSettings();
|
||||
|
||||
@@ -36,18 +36,17 @@
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class OpionConfiguration : public QWidget
|
||||
class OptionConfiguration : public QWidget
|
||||
{
|
||||
public:
|
||||
OpionConfiguration( OptionBase* option )
|
||||
OptionConfiguration( CalypOptions::OptionBase* option )
|
||||
: m_cName{ option->opt_string }
|
||||
{
|
||||
m_pcChecked = NULL;
|
||||
m_cName = option->opt_string;
|
||||
m_pcDescription = new QLabel;
|
||||
auto* pcDescription = new QLabel;
|
||||
QString desc = QString::fromStdString( option->opt_desc );
|
||||
m_pcDescription->setText( desc );
|
||||
pcDescription->setText( desc );
|
||||
QHBoxLayout* layout = new QHBoxLayout;
|
||||
layout->addWidget( m_pcDescription, 0, Qt::AlignLeft );
|
||||
layout->addWidget( pcDescription, 0, Qt::AlignLeft );
|
||||
if( !option->isBinary() )
|
||||
{
|
||||
m_pcValue = new QLineEdit;
|
||||
@@ -64,7 +63,7 @@ public:
|
||||
layout->setContentsMargins( 1, 1, 1, 1 );
|
||||
setLayout( layout );
|
||||
}
|
||||
const QString getValue() const
|
||||
auto getValue() const -> QString
|
||||
{
|
||||
if( m_pcChecked )
|
||||
{
|
||||
@@ -72,12 +71,11 @@ public:
|
||||
}
|
||||
return m_pcValue->text();
|
||||
}
|
||||
const std::string& getName() { return m_cName; }
|
||||
auto getName() const -> std::string { return m_cName; }
|
||||
|
||||
private:
|
||||
QLineEdit* m_pcValue;
|
||||
QCheckBox* m_pcChecked;
|
||||
QLabel* m_pcDescription;
|
||||
QLineEdit* m_pcValue{ nullptr };
|
||||
QCheckBox* m_pcChecked{ nullptr };
|
||||
std::string m_cName;
|
||||
};
|
||||
|
||||
@@ -87,13 +85,12 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, CalypAppModuleI
|
||||
resize( 400, 10 );
|
||||
setWindowTitle( "Select module parameters" );
|
||||
|
||||
const CalypOptions::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList();
|
||||
auto& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList();
|
||||
|
||||
QVBoxLayout* optionsLayout = new QVBoxLayout;
|
||||
OpionConfiguration* pcOption;
|
||||
for( CalypOptions::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it )
|
||||
for( auto& option : moduleOptions )
|
||||
{
|
||||
pcOption = new OpionConfiguration( ( *it )->opt );
|
||||
auto pcOption = new OptionConfiguration( option->base_opt.get() );
|
||||
m_apcOptionList.append( pcOption );
|
||||
optionsLayout->addWidget( pcOption );
|
||||
}
|
||||
@@ -125,13 +122,13 @@ int ModulesHandleOptDialog::runConfiguration()
|
||||
std::string optionString;
|
||||
QString valueString( "" );
|
||||
|
||||
for( int i = 0; i < m_apcOptionList.size(); i++ )
|
||||
for( const auto& option : m_apcOptionList )
|
||||
{
|
||||
valueString = m_apcOptionList.at( i )->getValue();
|
||||
valueString = option->getValue();
|
||||
if( !valueString.isEmpty() )
|
||||
{
|
||||
optionString.append( "--" );
|
||||
optionString.append( m_apcOptionList.at( i )->getName() );
|
||||
optionString.append( option->getName() );
|
||||
if( !( valueString == "true" ) )
|
||||
{
|
||||
optionString.append( "=" );
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "CommonDefs.h"
|
||||
#include "config.h"
|
||||
|
||||
class OpionConfiguration;
|
||||
class OptionConfiguration;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
CalypAppModuleIf* m_pcCurrModuleIf;
|
||||
QVector<OpionConfiguration*> m_apcOptionList;
|
||||
QVector<OptionConfiguration*> m_apcOptionList;
|
||||
};
|
||||
|
||||
#endif // __MODULEHANDLEOPTDIALOG_H__
|
||||
@@ -33,15 +33,15 @@ AbsoluteFrameDifferenceExample::AbsoluteFrameDifferenceExample()
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended).
|
||||
// See this example for details on the functions prototype
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence.
|
||||
m_iModuleType = ClpModuleType::FrameProcessing; // Apply module to the frames or to the whole sequence.
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
m_pchModuleName = "AbsoluteDifferenceExample"; // Name
|
||||
m_pchModuleLongName = "Absolute Difference Example"; // Name
|
||||
m_pchModuleTooltip = "Measure the absolute difference " // Description
|
||||
"between two images (Y plane), e. g., abs( Y1 - Y2 )";
|
||||
m_uiNumberOfFrames = 2; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; // Module requirements (check CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_uiNumberOfFrames = 2; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow; // Module requirements (check CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_pcFrameDifference = NULL;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ bool AbsoluteFrameDifferenceExample::create( std::vector<CalypFrame*> apcFrameLi
|
||||
return false;
|
||||
|
||||
m_pcFrameDifference =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ REGISTER_CLASS_MAKER( FrameBinarizationAPIv1 )
|
||||
FrameBinarizationAPIv1::FrameBinarizationAPIv1()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleName = "FrameBinarizationAPIv1";
|
||||
m_pchModuleLongName = "Frame Binarization API v1";
|
||||
m_pchModuleTooltip = "Binarize frame";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" );
|
||||
@@ -47,7 +47,7 @@ FrameBinarizationAPIv1::FrameBinarizationAPIv1()
|
||||
void FrameBinarizationAPIv1::create( CalypFrame* frame )
|
||||
{
|
||||
m_pcBinFrame = NULL;
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), CLP_GRAY, 8 );
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), ClpPixelFormats::Gray, 8 );
|
||||
}
|
||||
|
||||
CalypFrame* FrameBinarizationAPIv1::process( CalypFrame* frame )
|
||||
|
||||
+268
-219
@@ -24,8 +24,11 @@
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
@@ -51,6 +54,7 @@
|
||||
#define xFreeMem( ptr ) free( ptr )
|
||||
#endif
|
||||
|
||||
constexpr auto kNumBitsInByte = 8;
|
||||
constexpr auto kMinBitsPerPixel = 8;
|
||||
constexpr auto kMaxBitsPerPixel = 16;
|
||||
|
||||
@@ -64,47 +68,68 @@ std::vector<std::string> CalypFrame::supportedColorSpacesListNames()
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedPixelFormatListNames()
|
||||
constexpr auto CalypFrame::numberOfFormats() -> std::size_t
|
||||
{
|
||||
std::vector<std::string> formatsList;
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
return kNumberOfPixelFormats;
|
||||
}
|
||||
|
||||
auto CalypFrame::findPixelFormat( const std::string& name ) -> std::optional<ClpPixelFormats>
|
||||
{
|
||||
for( const auto& [key, fmt] : g_CalypPixFmtDescriptorsMap )
|
||||
{
|
||||
formatsList.push_back( g_CalypPixFmtDescriptorsMap.at( i ).name );
|
||||
if( fmt.name.size() == name.size() &&
|
||||
std::equal( fmt.name.begin(), fmt.name.end(), name.begin(),
|
||||
[]( auto a, auto b ) { return std::tolower( a ) == std::tolower( b ); } ) )
|
||||
return key;
|
||||
}
|
||||
return formatsList;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedPixelFormatListNames( int colorSpace )
|
||||
auto CalypFrame::findPixelFormat( const std::string_view name ) -> std::optional<ClpPixelFormats>
|
||||
{
|
||||
std::vector<std::string> formatsList;
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
for( const auto& [key, fmt] : g_CalypPixFmtDescriptorsMap )
|
||||
{
|
||||
if( g_CalypPixFmtDescriptorsMap.at( i ).colorSpace == colorSpace )
|
||||
formatsList.push_back( g_CalypPixFmtDescriptorsMap.at( i ).name );
|
||||
if( fmt.name.size() == name.size() &&
|
||||
std::equal( fmt.name.begin(), fmt.name.end(), name.begin(),
|
||||
[]( auto a, auto b ) { return std::tolower( a ) == std::tolower( b ); } ) )
|
||||
return key;
|
||||
}
|
||||
return formatsList;
|
||||
return {};
|
||||
}
|
||||
|
||||
int CalypFrame::numberOfFormats()
|
||||
{
|
||||
return static_cast<int>( g_CalypPixFmtDescriptorsMap.size() );
|
||||
}
|
||||
|
||||
int CalypFrame::findPixelFormat( const std::string& name )
|
||||
{
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
{
|
||||
if( g_CalypPixFmtDescriptorsMap.at( i ).name == name )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CalypFrame::pelformatColorSpace( const int idx )
|
||||
auto CalypFrame::pelformatColorSpace( ClpPixelFormats idx ) -> int
|
||||
{
|
||||
return g_CalypPixFmtDescriptorsMap.at( idx ).colorSpace;
|
||||
}
|
||||
|
||||
auto CalypFrame::supportedPixelFormatListNames() -> std::map<ClpPixelFormats, std::string_view>
|
||||
{
|
||||
std::map<ClpPixelFormats, std::string_view> formatsList;
|
||||
for( const auto& [key, fmt] : g_CalypPixFmtDescriptorsMap )
|
||||
{
|
||||
formatsList[key] = fmt.name;
|
||||
}
|
||||
return formatsList;
|
||||
}
|
||||
|
||||
auto CalypFrame::supportedPixelFormatListNames( int colorSpace ) -> std::map<ClpPixelFormats, std::string_view>
|
||||
{
|
||||
std::map<ClpPixelFormats, std::string_view> formatsList;
|
||||
for( const auto& [key, fmt] : g_CalypPixFmtDescriptorsMap )
|
||||
{
|
||||
if( fmt.colorSpace == colorSpace )
|
||||
{
|
||||
formatsList[key] = fmt.name;
|
||||
}
|
||||
}
|
||||
return formatsList;
|
||||
}
|
||||
|
||||
auto CalypFrame::pixelFormatName( ClpPixelFormats idx ) -> const std::string_view
|
||||
{
|
||||
return g_CalypPixFmtDescriptorsMap.at( idx ).name;
|
||||
}
|
||||
|
||||
class CalypFrame::CalypFramePrivate
|
||||
{
|
||||
public:
|
||||
@@ -112,14 +137,13 @@ public:
|
||||
|
||||
//! Struct with the pixel format description.
|
||||
const CalypPixelFormatDescriptor* m_pcPelFormat{ nullptr };
|
||||
std::string m_cPelFmtName;
|
||||
|
||||
unsigned int m_uiWidth{ 0 }; //!< Width of the frame
|
||||
unsigned int m_uiHeight{ 0 }; //!< Height of the frame
|
||||
int m_iPixelFormat{ 0 }; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel{ 0 }; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue{ 0 }; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues{ false }; //!< Half of the scale correspond to negative values
|
||||
unsigned int m_uiWidth{ 0 }; //!< Width of the frame
|
||||
unsigned int m_uiHeight{ 0 }; //!< Height of the frame
|
||||
ClpPixelFormats m_iPixelFormat{ ClpPixelFormats::Invalid }; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel{ 0 }; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue{ 0 }; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues{ false }; //!< Half of the scale correspond to negative values
|
||||
|
||||
ClpPel*** m_pppcInputPel{ nullptr };
|
||||
|
||||
@@ -142,26 +166,26 @@ public:
|
||||
CalypFramePrivate& operator=( const CalypFramePrivate& ) = delete;
|
||||
CalypFramePrivate& operator=( CalypFramePrivate&& ) = delete;
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel )
|
||||
void init( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel )
|
||||
{
|
||||
init( width, height, pel_format, bitsPixel, false );
|
||||
init( width, height, pelFormat, bitsPixel, false );
|
||||
}
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel, bool has_negative_values )
|
||||
void init( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel, bool has_negative_values )
|
||||
{
|
||||
m_uiWidth = width;
|
||||
m_uiHeight = height;
|
||||
m_iPixelFormat = pel_format;
|
||||
m_iPixelFormat = pelFormat;
|
||||
m_uiBitsPel = bitsPixel < kMinBitsPerPixel ? kMinBitsPerPixel : bitsPixel;
|
||||
m_uiHalfPelValue = 1 << ( m_uiBitsPel - 1 );
|
||||
m_bHasNegativeValues = has_negative_values;
|
||||
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > kMaxBitsPerPixel )
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == ClpPixelFormats::Invalid || bitsPixel > kMaxBitsPerPixel )
|
||||
{
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a CalypFrame of this type" );
|
||||
}
|
||||
|
||||
m_pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( pel_format ) );
|
||||
m_pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( pelFormat ) );
|
||||
int iNumberChannels = m_pcPelFormat->numberChannels;
|
||||
|
||||
std::size_t mem_size = 0;
|
||||
@@ -177,10 +201,10 @@ public:
|
||||
}
|
||||
mem_size += num_of_ptrs * sizeof( ClpPel* ) + sizeof( ClpPel** ) * iNumberChannels;
|
||||
|
||||
m_pppcInputPel = (ClpPel***)xMalloc( mem_size );
|
||||
m_pppcInputPel = (ClpPel***)xMalloc( mem_size ); // NOLINT
|
||||
|
||||
ClpPel** pelPtrMem = (ClpPel**)( m_pppcInputPel + iNumberChannels );
|
||||
ClpPel* pelMem = (ClpPel*)( pelPtrMem + num_of_ptrs );
|
||||
ClpPel** pelPtrMem = (ClpPel**)( m_pppcInputPel + iNumberChannels ); // NOLINT
|
||||
ClpPel* pelMem = (ClpPel*)( pelPtrMem + num_of_ptrs ); // NOLINT
|
||||
for( int ch = 0; ch < iNumberChannels; ch++ )
|
||||
{
|
||||
int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0;
|
||||
@@ -210,50 +234,44 @@ public:
|
||||
|
||||
m_puiHistogram.resize( m_uiHistoSegments * m_uiHistoChannels );
|
||||
|
||||
m_cPelFmtName = CalypFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str();
|
||||
|
||||
m_bInit = true;
|
||||
}
|
||||
|
||||
int getRealHistogramChannel( int channel )
|
||||
{
|
||||
int realChannel = -1;
|
||||
if( channel == CalypFrame::HIST_ALL_CHANNELS )
|
||||
if( channel < 0 )
|
||||
{
|
||||
realChannel = channel;
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
else if( channel >= 0 && channel < 4 )
|
||||
if( channel < HistogramChannels::HIST_LUMA || channel == HistogramChannels::HIST_ALL_CHANNELS )
|
||||
{
|
||||
realChannel = channel;
|
||||
return channel;
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_GRAY && channel == HistogramChannels::HIST_LUMA )
|
||||
{
|
||||
if( channel >= 10 && channel < 11 )
|
||||
return channel - HistogramChannels::HIST_LUMA;
|
||||
}
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_YUV && channel >= HistogramChannels::HIST_LUMA && channel < HistogramChannels::HIST_CHROMA_V )
|
||||
{
|
||||
return channel - HistogramChannels::HIST_LUMA;
|
||||
}
|
||||
|
||||
if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || m_pcPelFormat->colorSpace == CLP_COLOR_RGBA )
|
||||
{
|
||||
if( channel == HistogramChannels::HIST_LUMA )
|
||||
{
|
||||
realChannel = channel - 10;
|
||||
return static_cast<int>( m_uiHistoChannels ) - 1;
|
||||
}
|
||||
if( channel >= HistogramChannels::HIST_COLOR_R && channel <= HistogramChannels::HIST_COLOR_A )
|
||||
{
|
||||
return channel - CLP_COLOR_R;
|
||||
}
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
if( channel >= 10 && channel < 13 )
|
||||
{
|
||||
realChannel = channel - 10;
|
||||
}
|
||||
}
|
||||
else if( m_pcPelFormat->colorSpace == CLP_COLOR_RGB || m_pcPelFormat->colorSpace == CLP_COLOR_RGBA )
|
||||
{
|
||||
if( channel == CalypFrame::HIST_LUMA )
|
||||
{
|
||||
realChannel = m_uiHistoChannels - 1;
|
||||
}
|
||||
if( channel >= 20 && channel < 24 )
|
||||
{
|
||||
realChannel = channel - 20;
|
||||
}
|
||||
}
|
||||
if( realChannel > (int)m_uiHistoChannels )
|
||||
realChannel = -1;
|
||||
return realChannel;
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
|
||||
~CalypFramePrivate()
|
||||
@@ -263,20 +281,20 @@ public:
|
||||
m_bHasHistogram = false;
|
||||
|
||||
if( m_pppcInputPel )
|
||||
xFreeMem( m_pppcInputPel );
|
||||
xFreeMem( m_pppcInputPel ); // NOLINT
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Constructors
|
||||
*/
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel )
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel );
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values )
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel, bool has_negative_values )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel, has_negative_values );
|
||||
@@ -306,16 +324,6 @@ CalypFrame::CalypFrame( const CalypFrame& other )
|
||||
copyFrom( &other );
|
||||
}
|
||||
|
||||
// CalypFrame::CalypFrame( const CalypFrame* other )
|
||||
// : d{ std::make_unique<CalypFramePrivate>() }
|
||||
// {
|
||||
// if( other )
|
||||
// {
|
||||
// d->init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel(), other->getHasNegativeValues() );
|
||||
// copyFrom( other );
|
||||
// }
|
||||
// }
|
||||
|
||||
CalypFrame& CalypFrame::operator=( const CalypFrame& other )
|
||||
{
|
||||
// Self-assignment detection
|
||||
@@ -413,14 +421,14 @@ bool CalypFrame::haveSameFmt( const CalypFrame* other, unsigned int match ) cons
|
||||
return bRet;
|
||||
}
|
||||
|
||||
int CalypFrame::getPelFormat() const
|
||||
auto CalypFrame::getPelFormat() const -> ClpPixelFormats
|
||||
{
|
||||
return d->m_iPixelFormat;
|
||||
}
|
||||
|
||||
std::string CalypFrame::getPelFmtName()
|
||||
auto CalypFrame::getPelFmtName() const -> std::string
|
||||
{
|
||||
return d->m_pcPelFormat->name;
|
||||
return std::string( d->m_pcPelFormat->name );
|
||||
}
|
||||
|
||||
int CalypFrame::getColorSpace() const
|
||||
@@ -487,32 +495,29 @@ std::uint64_t CalypFrame::getBytesPerFrame() const
|
||||
return getBytesPerFrame( d->m_uiWidth, d->m_uiHeight, d->m_iPixelFormat, d->m_uiBitsPel );
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel )
|
||||
std::uint64_t CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat, unsigned int bitsPixel )
|
||||
{
|
||||
const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( iPixelFormat ) );
|
||||
unsigned int bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
|
||||
const auto& pcPelFormat = g_CalypPixFmtDescriptorsMap.at( pelFormat );
|
||||
unsigned int bytesPerPixel = ( bitsPixel - 1 ) / kNumBitsInByte + 1;
|
||||
std::uint64_t numberBytes = uiWidth * uiHeight;
|
||||
if( pcPelFormat->numberChannels > 1 )
|
||||
if( pcPelFormat.numberChannels > 1 )
|
||||
{
|
||||
std::uint64_t numberBytesChroma =
|
||||
CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
|
||||
numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma;
|
||||
CHROMASHIFT( uiWidth, pcPelFormat.log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat.log2ChromaHeight );
|
||||
numberBytes += ( pcPelFormat.numberChannels - 1 ) * numberBytesChroma;
|
||||
}
|
||||
return numberBytes * bytesPerPixel;
|
||||
}
|
||||
|
||||
void CalypFrame::reset()
|
||||
{
|
||||
ClpPel* pPel;
|
||||
ClpPel pelValue = 1 << ( d->m_uiBitsPel - 1 );
|
||||
int ratioH, ratioW;
|
||||
unsigned int i;
|
||||
for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
const ClpPel pelValue = 1 << ( d->m_uiBitsPel - 1 );
|
||||
for( std::size_t ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
pPel = d->m_pppcInputPel[ch][0];
|
||||
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
ClpPel* pPel = d->m_pppcInputPel[ch][0];
|
||||
for( std::size_t i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
{
|
||||
*pPel++ = pelValue;
|
||||
}
|
||||
@@ -559,6 +564,8 @@ CalypPixel CalypFrame::operator()( unsigned int xPos, unsigned int yPos ) const
|
||||
|
||||
CalypPixel CalypFrame::getPixel( unsigned int xPos, unsigned int yPos ) const
|
||||
{
|
||||
assert( xPos < d->m_uiWidth );
|
||||
assert( yPos < d->m_uiHeight );
|
||||
CalypPixel PixelValue( d->m_pcPelFormat->colorSpace );
|
||||
for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
@@ -664,8 +671,8 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
|
||||
void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndianness )
|
||||
{
|
||||
const ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
std::array<const ClpByte*, CalypPixel::getMaxNumberOfComponents()> ppBuff{ nullptr };
|
||||
int bytesPixel = ( d->m_uiBitsPel - 1 ) / kNumBitsInByte + 1;
|
||||
int startByte = 0;
|
||||
int endByte = bytesPixel;
|
||||
int incByte = 1;
|
||||
@@ -679,7 +686,7 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
}
|
||||
|
||||
ppBuff[0] = Buff.data();
|
||||
for( unsigned i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
for( std::size_t i = 1; i < CalypPixel::getMaxNumberOfComponents(); i++ )
|
||||
{
|
||||
int ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
@@ -688,20 +695,20 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
|
||||
memset( d->m_pppcInputPel[0][0], 0, getTotalNumberOfPixels() * sizeof( ClpPel ) );
|
||||
|
||||
for( unsigned ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
for( std::size_t ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
int step = ( d->m_pcPelFormat->comp[ch].step_minus1 ) * bytesPixel;
|
||||
unsigned step = d->m_pcPelFormat->comp[ch].step_minus1 * bytesPixel;
|
||||
|
||||
ClpPel* pPel = d->m_pppcInputPel[ch][0];
|
||||
const ClpByte* pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * bytesPixel;
|
||||
|
||||
for( unsigned p = 0; p < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); p++ )
|
||||
for( std::size_t p = 0; p < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); p++ )
|
||||
{
|
||||
for( int b = startByte; b != endByte; b += incByte )
|
||||
{
|
||||
pPel[p] += *pTmpBuff << ( b * 8 );
|
||||
pPel[p] += *pTmpBuff << ( b * kNumBitsInByte );
|
||||
pTmpBuff++;
|
||||
}
|
||||
// Check max value and bound it to "maxval" to prevent segfault when
|
||||
@@ -717,16 +724,12 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
|
||||
void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndianness ) const
|
||||
{
|
||||
unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
ClpByte* pTmpBuff;
|
||||
ClpPel* pTmpPel;
|
||||
int ratioH, ratioW, step;
|
||||
unsigned int i, ch;
|
||||
const int bytesPixel = ( d->m_uiBitsPel - 1 ) / kNumBitsInByte + 1;
|
||||
std::array<ClpByte*, CalypPixel::getMaxNumberOfComponents()> ppBuff{ nullptr };
|
||||
|
||||
int startByte = 0;
|
||||
int endByte = bytesPixel;
|
||||
int incByte = 1;
|
||||
int b;
|
||||
|
||||
if( iEndianness == CLP_BIG_ENDIAN )
|
||||
{
|
||||
@@ -736,27 +739,27 @@ void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndian
|
||||
}
|
||||
|
||||
ppBuff[0] = output_buffer.data();
|
||||
for( int i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
for( std::size_t i = 1; i < CalypPixel::getMaxNumberOfComponents(); i++ )
|
||||
{
|
||||
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
int ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
|
||||
}
|
||||
|
||||
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
for( std::size_t ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
step = ( d->m_pcPelFormat->comp[ch].step_minus1 ) * bytesPixel;
|
||||
int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
int step = ( d->m_pcPelFormat->comp[ch].step_minus1 ) * bytesPixel;
|
||||
|
||||
pTmpPel = d->m_pppcInputPel[ch][0];
|
||||
pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * bytesPixel;
|
||||
ClpPel* pTmpPel = d->m_pppcInputPel[ch][0];
|
||||
ClpByte* pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * bytesPixel;
|
||||
|
||||
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
for( std::size_t i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
{
|
||||
for( b = startByte; b != endByte; b += incByte )
|
||||
for( int b = startByte; b != endByte; b += incByte )
|
||||
{
|
||||
*pTmpBuff = *pTmpPel >> ( 8 * b );
|
||||
*pTmpBuff = *pTmpPel >> ( kNumBitsInByte * b );
|
||||
pTmpBuff++;
|
||||
}
|
||||
pTmpPel++;
|
||||
@@ -765,17 +768,36 @@ void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndian
|
||||
}
|
||||
}
|
||||
|
||||
#define PEL_ARGB( a, r, g, b ) ( ( a & 0xff ) << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff )
|
||||
#define PEL_RGB( r, g, b ) PEL_ARGB( 0xffu, r, g, b )
|
||||
#define CLAMP_YUV2RGB( X ) X = X < 0 ? 0 : X > 255 ? 255 : \
|
||||
X;
|
||||
#define YUV2RGB( iY, iU, iV, iR, iG, iB ) \
|
||||
iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ); \
|
||||
iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ); \
|
||||
iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ); \
|
||||
CLAMP_YUV2RGB( iR ) \
|
||||
CLAMP_YUV2RGB( iG ) \
|
||||
CLAMP_YUV2RGB( iB )
|
||||
template <typename T>
|
||||
inline constexpr auto convert_to_pel_argb( const T a, const T r, const T g, const T b ) -> std::uint32_t
|
||||
{
|
||||
return ( ( a & 0xff ) << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff ); // NOLINT
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline constexpr auto convert_to_pel_argb( const T r, const T g, const T b ) -> std::uint32_t
|
||||
{
|
||||
return convert_to_pel_argb<T>( 0xffu, r, g, b ); // NOLINT
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline constexpr void convert_yuv_to_rgb( const T iY, const T iU, const T iV, T& iR, T& iG, T& iB )
|
||||
{
|
||||
auto clamp_pel_value = []( auto X ) {
|
||||
if( X < 0 )
|
||||
return 0;
|
||||
if( X > 255 )
|
||||
return 255;
|
||||
return X;
|
||||
};
|
||||
|
||||
iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 );
|
||||
iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 );
|
||||
iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 );
|
||||
iR = clamp_pel_value( iR );
|
||||
iG = clamp_pel_value( iG );
|
||||
iB = clamp_pel_value( iB );
|
||||
}
|
||||
|
||||
void fillRGBBufferYUV420p( ClpPel*** pppInputPel, uint32_t* pARGB, unsigned uiWidth, unsigned uiHeight, int shiftBits )
|
||||
{
|
||||
@@ -787,45 +809,62 @@ void fillRGBBufferYUV420p( ClpPel*** pppInputPel, uint32_t* pARGB, unsigned uiWi
|
||||
{
|
||||
for( unsigned x = 0; x < uiWidth; x += 2 )
|
||||
{
|
||||
int iY, iU, iV, iR, iG, iB;
|
||||
iY = pY[y * uiWidth + x] >> shiftBits;
|
||||
iU = pU[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
iV = pV[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x] = PEL_RGB( iR, iG, iB );
|
||||
int iR, iG, iB; // NOLINT
|
||||
int iY = pY[y * uiWidth + x] >> shiftBits;
|
||||
int iU = pU[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
int iV = pV[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
convert_yuv_to_rgb( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x] = convert_to_pel_argb( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + x + 1] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x + 1] = PEL_RGB( iR, iG, iB );
|
||||
convert_yuv_to_rgb( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x + 1] = convert_to_pel_argb( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + uiWidth + x] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x] = PEL_RGB( iR, iG, iB );
|
||||
convert_yuv_to_rgb( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x] = convert_to_pel_argb( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + uiWidth + x + 1] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x + 1] = PEL_RGB( iR, iG, iB );
|
||||
convert_yuv_to_rgb( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x + 1] = convert_to_pel_argb( iR, iG, iB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CalypFrame::fillRGBBuffer() const
|
||||
void CalypFrame::fillRGBBuffer( std::optional<std::size_t> channel ) const
|
||||
{
|
||||
if( d->m_bHasRGBPel )
|
||||
return;
|
||||
int shiftBits = d->m_uiBitsPel - 8;
|
||||
auto shiftBits = static_cast<int>( d->m_uiBitsPel ) - 8;
|
||||
|
||||
d->m_bHasRGBPel = true;
|
||||
// 4 bytes for A, R, G and B
|
||||
uint32_t* pARGB = (uint32_t*)d->m_pcARGB32.data();
|
||||
if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY || ( channel.has_value() && *channel == 0 ) )
|
||||
{
|
||||
ClpPel* pY = d->m_pppcInputPel[CLP_LUMA][0];
|
||||
unsigned char finalPel{ 0 };
|
||||
ClpPel* pY = d->m_pppcInputPel[0][0];
|
||||
for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
|
||||
{
|
||||
finalPel = ( *pY++ ) >> shiftBits;
|
||||
*pARGB++ = PEL_RGB( finalPel, finalPel, finalPel );
|
||||
unsigned char finalPel = ( *pY++ ) >> shiftBits;
|
||||
*pARGB++ = convert_to_pel_argb( finalPel, finalPel, finalPel );
|
||||
}
|
||||
}
|
||||
else if( channel.has_value() && *channel > 0 )
|
||||
{
|
||||
ClpPel* pLine = d->m_pppcInputPel[*channel][0];
|
||||
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++ )
|
||||
{
|
||||
ClpPel* pPel = pLine;
|
||||
for( unsigned x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
{
|
||||
unsigned char finalPel = ( *pPel++ ) >> shiftBits;
|
||||
for( int j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
|
||||
{
|
||||
*pARGB++ = convert_to_pel_argb( finalPel, finalPel, finalPel );
|
||||
}
|
||||
}
|
||||
}
|
||||
pLine += CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth );
|
||||
}
|
||||
}
|
||||
else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_RGB )
|
||||
@@ -834,7 +873,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pG = d->m_pppcInputPel[CLP_COLOR_G][0];
|
||||
ClpPel* pB = d->m_pppcInputPel[CLP_COLOR_B][0];
|
||||
for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
|
||||
*pARGB++ = PEL_RGB( ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits );
|
||||
*pARGB++ = convert_to_pel_argb( ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits );
|
||||
}
|
||||
else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_RGBA )
|
||||
{
|
||||
@@ -843,11 +882,11 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pB = d->m_pppcInputPel[CLP_COLOR_B][0];
|
||||
ClpPel* pA = d->m_pppcInputPel[CLP_COLOR_A][0];
|
||||
for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
|
||||
*pARGB++ = PEL_ARGB( ( *pA++ ) >> shiftBits, ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits );
|
||||
*pARGB++ = convert_to_pel_argb( ( *pA++ ) >> shiftBits, ( *pR++ ) >> shiftBits, ( *pG++ ) >> shiftBits, ( *pB++ ) >> shiftBits );
|
||||
}
|
||||
else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
if( d->m_iPixelFormat == CLP_YUV420P )
|
||||
if( d->m_iPixelFormat == ClpPixelFormats::YUV420p )
|
||||
{
|
||||
fillRGBBufferYUV420p( d->m_pppcInputPel, pARGB, d->m_uiWidth, d->m_uiHeight, shiftBits );
|
||||
return;
|
||||
@@ -857,9 +896,8 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pLineV = d->m_pppcInputPel[CLP_CHROMA_V][0];
|
||||
unsigned int uiChromaStride = CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth );
|
||||
|
||||
int iR, iG, iB;
|
||||
int iR, iG, iB; // NOLINT
|
||||
uint32_t* pARGBLine = pARGB;
|
||||
uint32_t* pARGBAux;
|
||||
|
||||
for( unsigned y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
{
|
||||
@@ -868,7 +906,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pY = pLineY;
|
||||
ClpPel* pU = pLineU;
|
||||
ClpPel* pV = pLineV;
|
||||
pARGBAux = pARGBLine;
|
||||
uint32_t* pARGBAux = pARGBLine;
|
||||
for( unsigned x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
{
|
||||
int iU = *pU++;
|
||||
@@ -879,8 +917,8 @@ void CalypFrame::fillRGBBuffer() const
|
||||
{
|
||||
int iY = *pY++;
|
||||
iY >>= shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
*pARGBAux++ = PEL_RGB( iR, iG, iB );
|
||||
convert_yuv_to_rgb( iY, iU, iV, iR, iG, iB );
|
||||
*pARGBAux++ = convert_to_pel_argb( iR, iG, iB );
|
||||
}
|
||||
}
|
||||
pLineY += d->m_uiWidth;
|
||||
@@ -892,6 +930,14 @@ void CalypFrame::fillRGBBuffer() const
|
||||
}
|
||||
}
|
||||
|
||||
void CalypFrame::fillRGBBuffer() const
|
||||
{
|
||||
if( d->m_bHasRGBPel )
|
||||
return;
|
||||
|
||||
fillRGBBuffer( {} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Histogram
|
||||
*/
|
||||
@@ -933,12 +979,12 @@ void CalypFrame::calcHistogram()
|
||||
d->m_bHistogramRunning = false;
|
||||
}
|
||||
|
||||
int CalypFrame::getNumHistogramSegment()
|
||||
int CalypFrame::getNumHistogramSegment() const
|
||||
{
|
||||
return d->m_uiHistoSegments;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getMinimumPelValue( unsigned channel )
|
||||
unsigned int CalypFrame::getMinimumPelValue( unsigned channel ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram )
|
||||
return 0;
|
||||
@@ -970,7 +1016,7 @@ unsigned int CalypFrame::getMinimumPelValue( unsigned channel )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getMaximumPelValue( unsigned channel )
|
||||
unsigned int CalypFrame::getMaximumPelValue( unsigned channel ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram )
|
||||
return 0;
|
||||
@@ -1002,7 +1048,7 @@ unsigned int CalypFrame::getMaximumPelValue( unsigned channel )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getNEBins( unsigned channel )
|
||||
unsigned int CalypFrame::getNEBins( unsigned channel ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram )
|
||||
return 0;
|
||||
@@ -1035,7 +1081,7 @@ unsigned int CalypFrame::getNEBins( unsigned channel )
|
||||
return nEBins;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getMaximum( unsigned channel )
|
||||
unsigned int CalypFrame::getMaximum( unsigned channel ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram )
|
||||
return 0;
|
||||
@@ -1045,8 +1091,8 @@ unsigned int CalypFrame::getMaximum( unsigned channel )
|
||||
return 0;
|
||||
|
||||
unsigned int maxValue = 0;
|
||||
int indexStart;
|
||||
int indexEnd;
|
||||
int indexStart{ 0 };
|
||||
int indexEnd{ 0 };
|
||||
if( channel == HIST_ALL_CHANNELS )
|
||||
{
|
||||
indexStart = 0;
|
||||
@@ -1068,7 +1114,7 @@ unsigned int CalypFrame::getMaximum( unsigned channel )
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end )
|
||||
unsigned int CalypFrame::getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
@@ -1081,7 +1127,7 @@ unsigned int CalypFrame::getNumPixelsRange( unsigned channel, unsigned int start
|
||||
}
|
||||
|
||||
unsigned int count = 0;
|
||||
int indexStart;
|
||||
int indexStart{ 0 };
|
||||
indexStart = channel * d->m_uiHistoSegments;
|
||||
for( unsigned int i = start; i <= end; i++ )
|
||||
{
|
||||
@@ -1090,7 +1136,7 @@ unsigned int CalypFrame::getNumPixelsRange( unsigned channel, unsigned int start
|
||||
return count;
|
||||
}
|
||||
|
||||
double CalypFrame::getMean( unsigned channel, unsigned int start, unsigned int end )
|
||||
double CalypFrame::getMean( unsigned channel, unsigned int start, unsigned int end ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
@@ -1102,15 +1148,14 @@ double CalypFrame::getMean( unsigned channel, unsigned int start, unsigned int e
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double mean = 0.0;
|
||||
double count;
|
||||
double mean{ 0.0 };
|
||||
int indexStart = channel * d->m_uiHistoSegments;
|
||||
for( unsigned int i = start; i <= end; i++ )
|
||||
{
|
||||
mean += i * d->m_puiHistogram[indexStart + i];
|
||||
}
|
||||
|
||||
count = getNumPixelsRange( channel, start, end );
|
||||
auto count = getNumPixelsRange( channel, start, end );
|
||||
|
||||
if( count > 0.0 )
|
||||
{
|
||||
@@ -1120,7 +1165,7 @@ double CalypFrame::getMean( unsigned channel, unsigned int start, unsigned int e
|
||||
return mean;
|
||||
}
|
||||
|
||||
int CalypFrame::getMedian( unsigned channel, unsigned int start, unsigned int end )
|
||||
int CalypFrame::getMedian( unsigned channel, unsigned int start, unsigned int end ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
@@ -1146,7 +1191,7 @@ int CalypFrame::getMedian( unsigned channel, unsigned int start, unsigned int en
|
||||
return 0;
|
||||
}
|
||||
|
||||
double CalypFrame::getStdDev( unsigned channel, unsigned int start, unsigned int end )
|
||||
double CalypFrame::getStdDev( unsigned channel, unsigned int start, unsigned int end ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
|
||||
{
|
||||
@@ -1185,7 +1230,7 @@ double CalypFrame::getStdDev( unsigned channel, unsigned int start, unsigned int
|
||||
return sqrt( ( dev - count * mean * mean ) / ( count - 1 ) );
|
||||
}
|
||||
|
||||
double CalypFrame::getHistogramValue( unsigned channel, unsigned int bin )
|
||||
double CalypFrame::getHistogramValue( unsigned channel, unsigned int bin ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram || bin < 0 || bin > d->m_uiHistoSegments - 1 )
|
||||
return 0.0;
|
||||
@@ -1200,7 +1245,7 @@ double CalypFrame::getHistogramValue( unsigned channel, unsigned int bin )
|
||||
return d->m_puiHistogram[indexStart + bin];
|
||||
}
|
||||
|
||||
double CalypFrame::getEntropy( unsigned channel, unsigned int start, unsigned int end )
|
||||
double CalypFrame::getEntropy( unsigned channel, unsigned int start, unsigned int end ) const
|
||||
{
|
||||
if( !d->m_bHasHistogram )
|
||||
return 0;
|
||||
@@ -1241,27 +1286,28 @@ bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned
|
||||
{
|
||||
return bRet;
|
||||
}
|
||||
unsigned int cvPrecision = getBitsPel() > 8 ? CV_16U : CV_8U;
|
||||
unsigned numBytes = getBitsPel() > 8 ? 2 : 1;
|
||||
unsigned numChannels = getNumberChannels();
|
||||
unsigned scaleFactor = 1 << ( numBytes * 8 - getBitsPel() );
|
||||
if( !scale )
|
||||
auto numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1;
|
||||
auto numChannels = getNumberChannels();
|
||||
double scaleFactor = 1 << ( numBytes * kNumBitsInByte - getBitsPel() );
|
||||
if( scale == 0 )
|
||||
scaleFactor = 1;
|
||||
|
||||
if( convertToGray )
|
||||
{
|
||||
channel = channel >= numChannels ? 0 : channel;
|
||||
numChannels = 1;
|
||||
}
|
||||
|
||||
unsigned imgWidth = getWidth( channel );
|
||||
unsigned imgHeight = getHeight( channel );
|
||||
auto imgWidth = getWidth( channel );
|
||||
auto imgHeight = getHeight( channel );
|
||||
|
||||
const auto cvPrecision = getBitsPel() > 8 ? CV_16U : CV_8U;
|
||||
cvMat.create( imgHeight, imgWidth, CV_MAKETYPE( cvPrecision, numChannels ) );
|
||||
if( numChannels > 1 )
|
||||
{
|
||||
cv::Mat tmpMat( imgHeight, imgWidth, CV_MAKETYPE( cvPrecision, numChannels ) );
|
||||
|
||||
unsigned char* cv_data = tmpMat.data;
|
||||
auto* cv_data = tmpMat.data;
|
||||
for( unsigned y = 0; y < imgHeight; y++ )
|
||||
{
|
||||
for( unsigned x = 0; x < imgWidth; x++ )
|
||||
@@ -1269,22 +1315,25 @@ bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned
|
||||
CalypPixel currPel = getPixel( x, y );
|
||||
currPel *= scaleFactor;
|
||||
for( unsigned int ch = 0; ch < numChannels; ch++ )
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
for( auto b = 0; b < numBytes; b++ )
|
||||
{
|
||||
unsigned char pel = currPel[ch] >> ( 8 * b );
|
||||
unsigned char pel = currPel[ch] >> ( kNumBitsInByte * b );
|
||||
*cv_data++ = pel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( getNumberChannels() >= 1 )
|
||||
// TODO: check for other formats
|
||||
switch( getColorSpace() )
|
||||
{
|
||||
// TODO: check for other formats
|
||||
switch( getColorSpace() )
|
||||
{
|
||||
case CLP_COLOR_YUV:
|
||||
cv::cvtColor( tmpMat, cvMat, cv::COLOR_YCrCb2RGB );
|
||||
break;
|
||||
}
|
||||
case CLP_COLOR_YUV:
|
||||
cv::cvtColor( tmpMat, cvMat, cv::COLOR_YCrCb2RGB );
|
||||
break;
|
||||
case CLP_COLOR_RGB:
|
||||
case CLP_COLOR_RGBA:
|
||||
cvMat = tmpMat;
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1293,9 +1342,9 @@ bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned
|
||||
ClpPel* pel = getPelBufferYUV()[channel][0];
|
||||
for( unsigned y = 0; y < imgHeight * imgWidth; y++ )
|
||||
{
|
||||
ClpPel currPel = ( *pel++ ) * scaleFactor;
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
*cv_data++ = currPel >> ( 8 * b );
|
||||
ClpPel currPel = static_cast<ClpPel>( *pel++ * scaleFactor );
|
||||
for( auto b = 0; b < numBytes; b++ )
|
||||
*cv_data++ = currPel >> ( kNumBitsInByte * b );
|
||||
}
|
||||
}
|
||||
bRet = true;
|
||||
@@ -1307,27 +1356,28 @@ bool CalypFrame::fromMat( cv::Mat& cvMat, int channel )
|
||||
{
|
||||
bool bRet = false;
|
||||
#ifdef USE_OPENCV
|
||||
unsigned numBytes = getBitsPel() > 8 ? 2 : 1;
|
||||
unsigned numBytes = getBitsPel() > kNumBitsInByte ? 2 : 1;
|
||||
unsigned numChannels = getNumberChannels();
|
||||
unsigned int cvPrecision = getBitsPel() > 8 ? CV_16U : CV_8U;
|
||||
unsigned int cvPrecision = getBitsPel() > kNumBitsInByte ? CV_16U : CV_8U;
|
||||
if( !d->m_bInit )
|
||||
{
|
||||
uchar depth = cvMat.type() & CV_MAT_DEPTH_MASK;
|
||||
if( d->m_iPixelFormat == CLP_INVALID_FMT )
|
||||
if( d->m_iPixelFormat == ClpPixelFormats::Invalid )
|
||||
{
|
||||
switch( cvMat.channels() )
|
||||
{
|
||||
case 1:
|
||||
d->m_iPixelFormat = findPixelFormat( "GRAY" );
|
||||
d->m_iPixelFormat = ClpPixelFormats::Gray;
|
||||
break;
|
||||
case 3:
|
||||
d->m_iPixelFormat = findPixelFormat( "BGR24" );
|
||||
d->m_iPixelFormat = ClpPixelFormats::BGR24;
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
d->m_uiBitsPel = depth == CV_8U ? 8 : 16;
|
||||
d->m_uiBitsPel = depth == CV_8U ? kNumBitsInByte : kMinBitsPerPixel * 2;
|
||||
d->init( cvMat.cols, cvMat.rows, d->m_iPixelFormat, d->m_uiBitsPel );
|
||||
}
|
||||
|
||||
@@ -1368,7 +1418,7 @@ bool CalypFrame::fromMat( cv::Mat& cvMat, int channel )
|
||||
currPel[ch] = 0;
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
{
|
||||
currPel[ch] = currPel[ch] + ( *( cv_data + y * cv_step + x * numChannels * numBytes + ch + b ) << ( 8 * b ) );
|
||||
currPel[ch] = currPel[ch] + ( *( cv_data + y * cv_step + x * numChannels * numBytes + ch + b ) << ( kNumBitsInByte * b ) );
|
||||
}
|
||||
}
|
||||
setPixel( x, y, currPel );
|
||||
@@ -1378,13 +1428,12 @@ bool CalypFrame::fromMat( cv::Mat& cvMat, int channel )
|
||||
else
|
||||
{
|
||||
unsigned char* cv_data = cvMat.data;
|
||||
ClpPel curr_pel;
|
||||
ClpPel* pel = getPelBufferYUV()[channel][0];
|
||||
for( unsigned int y = 0; y < imgHeight * imgWidth; y++ )
|
||||
{
|
||||
curr_pel = 0;
|
||||
ClpPel curr_pel{ 0 };
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
curr_pel += ( *cv_data++ ) << ( 8 * b );
|
||||
curr_pel += ( *cv_data++ ) << ( kNumBitsInByte * b );
|
||||
*pel++ = curr_pel;
|
||||
}
|
||||
}
|
||||
|
||||
+189
-179
@@ -26,8 +26,10 @@
|
||||
#ifndef __CALYPFRAME_H__
|
||||
#define __CALYPFRAME_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -56,24 +58,23 @@ enum CalypColorSpace
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum CalypPixelFormats
|
||||
* \enum ClpPixelFormats
|
||||
* \brief List of supported pixel formats
|
||||
* \ingroup CalypLibGrp
|
||||
*/
|
||||
enum CalypPixelFormats
|
||||
enum class ClpPixelFormats : int
|
||||
{
|
||||
CLP_INVALID_FMT = -1, //!< Invalid
|
||||
CLP_YUV420P = 0, //!< YUV 420 progressive
|
||||
CLP_YUV422P, //!< YUV 422 progressive
|
||||
CLP_YUV444P, //!< YUV 444 progressive
|
||||
CLP_YUYV422, //!< YUV 422 interleaved
|
||||
CLP_GRAY, //!< Grayscale
|
||||
CLP_RGB24P, //!< RGB 32 bpp progressive
|
||||
CLP_RGB24, //!< RGB 32 bpp
|
||||
CLP_BGR24, //!< BGR 32 bpp
|
||||
CLP_RGBA32, //!< RGBA 32 bpp
|
||||
CLP_BGRA32, //!< BGRA 32 bpp
|
||||
CLP_MAX_FMT = 255, //!< Account for future formats
|
||||
Invalid = -1, //!< Invalid
|
||||
YUV420p = 0, //!< YUV 420 progressive
|
||||
YUV422p, //!< YUV 422 progressive
|
||||
YUV444p, //!< YUV 444 progressive
|
||||
YUYV422, //!< YUV 422 interleaved
|
||||
Gray, //!< Grayscale
|
||||
RGB24p, //!< RGB 32 bpp progressive
|
||||
RGB24, //!< RGB 32 bpp
|
||||
BGR24, //!< BGR 32 bpp
|
||||
RGBA32, //!< RGBA 32 bpp
|
||||
BGRA32, //!< BGRA 32 bpp
|
||||
};
|
||||
|
||||
enum CLP_YUV_Components
|
||||
@@ -113,7 +114,7 @@ private:
|
||||
std::array<ClpPel, kMaxNumberOfComponents> m_pelComp{ 0, 0, 0, 0 };
|
||||
|
||||
public:
|
||||
static std::size_t getMaxNumberOfComponents() { return kMaxNumberOfComponents; }
|
||||
static constexpr std::size_t getMaxNumberOfComponents() { return kMaxNumberOfComponents; }
|
||||
|
||||
CalypPixel() = default;
|
||||
CalypPixel( const int CalypColorSpace, const ClpPel c0 = 0 );
|
||||
@@ -130,26 +131,32 @@ public:
|
||||
auto components() const -> const std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
auto components() -> std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
|
||||
ClpPel operator[]( const int& channel ) const { return m_pelComp[channel]; }
|
||||
ClpPel& operator[]( const int& channel ) { return m_pelComp[channel]; }
|
||||
ClpPel operator[]( const std::size_t channel ) const { return m_pelComp[channel]; }
|
||||
ClpPel& operator[]( const std::size_t channel ) { return m_pelComp[channel]; }
|
||||
|
||||
CalypPixel& operator+=( const CalypPixel& );
|
||||
CalypPixel& operator-=( const CalypPixel& );
|
||||
CalypPixel& operator*=( const double& );
|
||||
CalypPixel& operator*=( const double );
|
||||
|
||||
CalypPixel operator+( const CalypPixel& ) const;
|
||||
CalypPixel operator-( const CalypPixel& ) const;
|
||||
CalypPixel operator*( const double& ) const;
|
||||
CalypPixel operator*( const double ) const;
|
||||
|
||||
auto operator==( const CalypPixel& other ) const -> bool;
|
||||
|
||||
friend std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
|
||||
/**
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace ) const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
|
||||
/**
|
||||
* \class CalypPlane
|
||||
* \ingroup CalypLibGrp CalypPlaneGrp
|
||||
@@ -201,33 +208,24 @@ class CalypFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedColorSpacesListNames();
|
||||
|
||||
/**
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedPixelFormatListNames();
|
||||
static std::vector<std::string> supportedPixelFormatListNames( int colorSpace );
|
||||
static int numberOfFormats();
|
||||
static int findPixelFormat( const std::string& name );
|
||||
static int pelformatColorSpace( const int idx );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static constexpr auto numberOfFormats() -> std::size_t;
|
||||
static auto findPixelFormat( const std::string& name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto findPixelFormat( const std::string_view name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto pelformatColorSpace( ClpPixelFormats idx ) -> int;
|
||||
static auto supportedPixelFormatListNames() -> std::map<ClpPixelFormats, std::string_view>;
|
||||
static auto supportedPixelFormatListNames( int colorSpace ) -> std::map<ClpPixelFormats, std::string_view>;
|
||||
static auto pixelFormatName( ClpPixelFormats idx ) -> const std::string_view;
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
@@ -238,7 +236,18 @@ public:
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values );
|
||||
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel = 8 );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel, bool has_negative_values );
|
||||
|
||||
/**
|
||||
* Move contructor
|
||||
@@ -255,10 +264,10 @@ public:
|
||||
CalypFrame& operator=( CalypFrame&& other ) noexcept;
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other );
|
||||
|
||||
/**
|
||||
@@ -269,23 +278,23 @@ public:
|
||||
CalypFrame& operator=( const CalypFrame& other );
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
* its contents. This function only copies a specific region from the existing
|
||||
* frame
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
* @param posX position X to crop from
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
* its contents. This function only copies a specific region from the existing
|
||||
* frame
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
* @param posX position X to crop from
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
CalypFrame( const CalypFrame* other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
|
||||
~CalypFrame();
|
||||
|
||||
/** Format match opts
|
||||
*/
|
||||
*/
|
||||
enum FormatMatching
|
||||
{
|
||||
MATCH_COLOR_SPACE = 1,
|
||||
@@ -298,50 +307,50 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @param match matching conditions (use enum FormatMatching)
|
||||
* @return true if format matches
|
||||
*/
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @param match matching conditions (use enum FormatMatching)
|
||||
* @return true if format matches
|
||||
*/
|
||||
bool haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const;
|
||||
bool haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
int getPelFormat() const;
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
ClpPixelFormats getPelFormat() const;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
std::string getPelFmtName();
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
auto getPelFmtName() const -> std::string;
|
||||
|
||||
/**
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
int getColorSpace() const;
|
||||
|
||||
/**
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
unsigned getNumberChannels() const;
|
||||
|
||||
/**
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getWidth( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getHeight( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
@@ -351,10 +360,10 @@ public:
|
||||
bool getHasNegativeValues() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getPixels( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
@@ -364,44 +373,44 @@ public:
|
||||
std::uint64_t getTotalNumberOfPixels() const;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaWidthRatio() const;
|
||||
|
||||
/**
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaHeightRatio() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getChromaLength() const;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
unsigned int getBitsPel() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
std::uint64_t getBytesPerFrame() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static std::uint64_t getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static std::uint64_t getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat, unsigned int bitsPixel );
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
void reset();
|
||||
|
||||
ClpPel*** getPelBufferYUV() const;
|
||||
@@ -411,71 +420,71 @@ public:
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param absolute whether it should return positive/negative values
|
||||
* @return pixel value
|
||||
*/
|
||||
* @return pixel value
|
||||
*/
|
||||
ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel operator()( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const;
|
||||
|
||||
/**
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
void setPixel( unsigned int xPos, unsigned int yPos, CalypPixel pixel );
|
||||
|
||||
/**
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other );
|
||||
void copyFrom( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyFrom( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
/**
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y ) const;
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y ) const;
|
||||
|
||||
@@ -483,11 +492,12 @@ public:
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int );
|
||||
void frameToBuffer( std::vector<ClpByte>&, int ) const;
|
||||
|
||||
void fillRGBBuffer( std::optional<std::size_t> channel ) const;
|
||||
void fillRGBBuffer() const;
|
||||
|
||||
/**
|
||||
* Histogram
|
||||
*/
|
||||
* Histogram
|
||||
*/
|
||||
enum HistogramChannels
|
||||
{
|
||||
HIST_CHAN_ONE = 0,
|
||||
@@ -506,32 +516,32 @@ public:
|
||||
};
|
||||
void calcHistogram();
|
||||
|
||||
unsigned int getMinimumPelValue( unsigned channel );
|
||||
unsigned int getMaximumPelValue( unsigned channel );
|
||||
unsigned int getMinimumPelValue( unsigned channel ) const;
|
||||
unsigned int getMaximumPelValue( unsigned channel ) const;
|
||||
|
||||
unsigned int getMaximum( unsigned channel );
|
||||
unsigned int getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getMean( unsigned channel, unsigned int start, unsigned int end );
|
||||
int getMedian( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getStdDev( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getHistogramValue( unsigned channel, unsigned int bin );
|
||||
unsigned int getNEBins( unsigned channel );
|
||||
int getNumHistogramSegment();
|
||||
double getEntropy( unsigned channel, unsigned int start, unsigned int end );
|
||||
unsigned int getMaximum( unsigned channel ) const;
|
||||
unsigned int getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getMean( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
int getMedian( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getStdDev( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
double getHistogramValue( unsigned channel, unsigned int bin ) const;
|
||||
unsigned int getNEBins( unsigned channel ) const;
|
||||
int getNumHistogramSegment() const;
|
||||
double getEntropy( unsigned channel, unsigned int start, unsigned int end ) const;
|
||||
|
||||
/**
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const;
|
||||
bool fromMat( cv::Mat& cvMat, int iChannel = -1 );
|
||||
|
||||
/**
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
|
||||
enum QualityMetrics
|
||||
{
|
||||
|
||||
+59
-47
@@ -35,6 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <type_safe/flag_set.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
@@ -71,8 +72,9 @@ public: \
|
||||
*/
|
||||
enum Module_API_Version
|
||||
{
|
||||
CLP_MODULE_API_1,
|
||||
CLP_MODULE_API_2,
|
||||
CLP_MODULE_API_INVALID = -1,
|
||||
CLP_MODULE_API_1 = 0,
|
||||
CLP_MODULE_API_2 = 1,
|
||||
CLP_MODULE_API_3,
|
||||
};
|
||||
|
||||
@@ -81,12 +83,11 @@ enum Module_API_Version
|
||||
* Type of module
|
||||
* @see m_iModuleType
|
||||
*/
|
||||
enum Module_Type
|
||||
enum class ClpModuleType : std::uint8_t
|
||||
{
|
||||
CLP_INVALID_MODULE = -1,
|
||||
CLP_FRAME_PROCESSING_MODULE = 0,
|
||||
CLP_FRAME_MEASUREMENT_MODULE = 1,
|
||||
CLP_MODULE_TYPE_MAX = 255,
|
||||
Invalid,
|
||||
FrameProcessing,
|
||||
FrameMeasurement,
|
||||
};
|
||||
|
||||
/** Module_Features Enum
|
||||
@@ -94,18 +95,20 @@ enum Module_Type
|
||||
* Features/Requirements of a module
|
||||
* @see m_uiModuleRequirements
|
||||
*/
|
||||
enum Module_Features
|
||||
enum class ClpModuleFeature
|
||||
{
|
||||
CLP_MODULE_REQUIRES_NOTHING = 0,
|
||||
CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY = 1,
|
||||
CLP_MODULE_REQUIRES_OPTIONS = 2,
|
||||
CLP_MODULE_REQUIRES_NEW_WINDOW = 4,
|
||||
CLP_MODULE_USES_KEYS = 8,
|
||||
CLP_MODULES_VARIABLE_NUM_FRAMES = 16,
|
||||
CLP_MODULES_HAS_INFO = 32,
|
||||
CLP_MODULE_REQURES_MAX = 1024,
|
||||
None,
|
||||
SkipWhilePlaying,
|
||||
Options,
|
||||
NewWindow,
|
||||
KeysShortcuts,
|
||||
VariableNumOfFrames,
|
||||
HasInfo,
|
||||
_flag_set_size
|
||||
};
|
||||
|
||||
using ClpModuleFeatures = type_safe::flag_set<ClpModuleFeature>;
|
||||
|
||||
enum Module_Key_Supported
|
||||
{
|
||||
MODULE_KEY_LEFT,
|
||||
@@ -122,29 +125,14 @@ enum Module_Key_Supported
|
||||
class CalypModuleIf
|
||||
{
|
||||
public:
|
||||
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{ nullptr };
|
||||
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames{ 1 };
|
||||
//! Features/Requirements
|
||||
unsigned int m_uiModuleRequirements{ CLP_MODULE_REQUIRES_NOTHING };
|
||||
|
||||
unsigned int m_iFrameBufferCount{ 0 };
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
|
||||
CalypModuleIf() = default;
|
||||
CalypModuleIf( const CalypModuleIf& other ) noexcept = delete;
|
||||
CalypModuleIf( CalypModuleIf&& other ) noexcept = delete;
|
||||
auto operator=( const CalypModuleIf& other ) -> CalypModuleIf& = delete;
|
||||
auto operator=( CalypModuleIf&& other ) noexcept -> CalypModuleIf& = delete;
|
||||
CalypModuleIf( const CalypModuleIf& buffer ) noexcept = delete;
|
||||
CalypModuleIf( CalypModuleIf&& buffer ) noexcept = delete;
|
||||
auto operator=( const CalypModuleIf& buffer ) -> CalypModuleIf& = delete;
|
||||
auto operator=( CalypModuleIf&& buffer ) noexcept -> CalypModuleIf& = delete;
|
||||
|
||||
virtual ~CalypModuleIf() = default;
|
||||
virtual void destroy() = 0;
|
||||
virtual void destroy(){};
|
||||
|
||||
const char* getModuleLongName()
|
||||
{
|
||||
@@ -175,6 +163,23 @@ public:
|
||||
m_iFrameBufferCount = 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
public:
|
||||
int m_iModuleAPI{ CLP_MODULE_API_1 };
|
||||
ClpModuleType m_iModuleType{ ClpModuleType::Invalid };
|
||||
const char* m_pchModuleCategory{ "" };
|
||||
const char* m_pchModuleName{ "" };
|
||||
const char* m_pchModuleTooltip{ "" };
|
||||
const char* m_pchModuleLongName{ nullptr };
|
||||
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames{ 1 };
|
||||
//! Features/Requirements
|
||||
ClpModuleFeatures m_uiModuleRequirements{ ClpModuleFeature::None };
|
||||
|
||||
unsigned int m_iFrameBufferCount{ 0 };
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
};
|
||||
|
||||
namespace cv
|
||||
@@ -191,16 +196,8 @@ class CalypOpenCVModuleIf : public CalypModuleIf
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
protected:
|
||||
//const char* m_pchPythonFunctionName;
|
||||
std::unique_ptr<CalypFrame> m_pcOutputFrame;
|
||||
bool m_bConvertToGray;
|
||||
|
||||
public:
|
||||
CalypOpenCVModuleIf()
|
||||
{
|
||||
m_bConvertToGray = false;
|
||||
};
|
||||
CalypOpenCVModuleIf() { m_bConvertToGray = false; };
|
||||
virtual ~CalypOpenCVModuleIf() {}
|
||||
|
||||
// Common API
|
||||
@@ -209,11 +206,26 @@ public:
|
||||
void destroy();
|
||||
|
||||
// API using OpenCV
|
||||
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList ) { return nullptr; };
|
||||
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(){};
|
||||
|
||||
protected:
|
||||
// const char* m_pchPythonFunctionName;
|
||||
std::unique_ptr<CalypFrame> m_pcOutputFrame;
|
||||
bool m_bConvertToGray;
|
||||
};
|
||||
|
||||
using CalypModulePtr = std::unique_ptr<CalypModuleIf>;
|
||||
|
||||
template <typename T>
|
||||
class CalypModuleInstace
|
||||
{
|
||||
public:
|
||||
static CalypModulePtr Create() { return std::make_unique<T>(); }
|
||||
};
|
||||
|
||||
#endif // __CALYPMODULESIF_H__
|
||||
@@ -22,11 +22,14 @@
|
||||
* \brief Calyp modules interface for OpenCV
|
||||
*/
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypModuleIf.h"
|
||||
|
||||
// OpenCV
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "PixelFormats.h"
|
||||
|
||||
bool CalypOpenCVModuleIf::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
@@ -39,7 +42,7 @@ bool CalypOpenCVModuleIf::create( std::vector<CalypFrame*> apcFrameList )
|
||||
Mat* outputMat = create_using_opencv( acMatList );
|
||||
if( outputMat )
|
||||
{
|
||||
unsigned pelFormat = m_bConvertToGray ? CalypFrame::findPixelFormat( "GRAY" ) : apcFrameList[0]->getPelFormat();
|
||||
auto pelFormat = m_bConvertToGray ? ClpPixelFormats::Gray : apcFrameList[0]->getPelFormat();
|
||||
m_pcOutputFrame = std::make_unique<CalypFrame>( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
+125
-132
@@ -40,44 +40,44 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include "config.h"
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct ParseFailure : public std::exception
|
||||
{
|
||||
std::string arg;
|
||||
std::string val;
|
||||
ParseFailure( std::string arg0, std::string val0 ) throw()
|
||||
: arg( arg0 ), val( val0 ) {}
|
||||
: arg{ std::move( arg0 ) }, val{ std::move( val0 ) } {}
|
||||
ParseFailure( ParseFailure&& other ) noexcept = delete;
|
||||
ParseFailure& operator=( ParseFailure&& other ) noexcept = delete;
|
||||
ParseFailure( const ParseFailure& other ) = delete;
|
||||
ParseFailure& operator=( const ParseFailure& other ) = delete;
|
||||
~ParseFailure() throw() {}
|
||||
const char* what() const throw() { return "Option Parse Failure"; }
|
||||
const char* what() const throw() override { return "Option Parse Failure"; }
|
||||
};
|
||||
|
||||
/** Type specific option storage */
|
||||
class boolOption : public OptionBase
|
||||
class boolOption : public CalypOptions::OptionBase
|
||||
{
|
||||
public:
|
||||
boolOption( const std::string& name, const std::string& desc )
|
||||
: OptionBase( name, desc, "(1-0)" ) { is_binary = true; }
|
||||
void parse( const std::string& arg ) { arg_count++; }
|
||||
: CalypOptions::OptionBase( name, desc, "(1-0)" ) { is_binary = true; }
|
||||
void parse( const std::string& arg ) override { arg_count++; }
|
||||
};
|
||||
|
||||
/** Type specific option storage */
|
||||
template <typename T>
|
||||
class StandardOption : public OptionBase
|
||||
class StandardOption : public CalypOptions::OptionBase
|
||||
{
|
||||
public:
|
||||
StandardOption( const std::string& name, T& storage, const std::string& desc, const std::string& def )
|
||||
: OptionBase( name, desc, def ), opt_storage( storage )
|
||||
{
|
||||
is_binary = false;
|
||||
}
|
||||
: CalypOptions::OptionBase( name, desc, def ), opt_storage( storage ) {}
|
||||
|
||||
void parse( const std::string& arg );
|
||||
void parse( const std::string& arg ) override;
|
||||
T& opt_storage;
|
||||
std::vector<T> opt_storage_array;
|
||||
};
|
||||
@@ -105,7 +105,7 @@ inline void StandardOption<T>::parse( const std::string& arg )
|
||||
template <>
|
||||
inline void StandardOption<std::vector<unsigned int>>::parse( const std::string& arg )
|
||||
{
|
||||
unsigned int aux_opt_storage;
|
||||
unsigned int aux_opt_storage{ 0 };
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
arg_ss.exceptions( std::ios::failbit );
|
||||
try
|
||||
@@ -123,7 +123,7 @@ inline void StandardOption<std::vector<unsigned int>>::parse( const std::string&
|
||||
template <>
|
||||
inline void StandardOption<std::vector<int>>::parse( const std::string& arg )
|
||||
{
|
||||
int aux_opt_storage;
|
||||
int aux_opt_storage{ 0 };
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
arg_ss.exceptions( std::ios::failbit );
|
||||
try
|
||||
@@ -155,26 +155,26 @@ inline void StandardOption<std::vector<std::string>>::parse( const std::string&
|
||||
}
|
||||
|
||||
/** Option class for argument handling using a user provided function */
|
||||
struct FunctionOption : public OptionBase
|
||||
struct FunctionOption : public CalypOptions::OptionBase
|
||||
{
|
||||
public:
|
||||
typedef void( Func )( CalypOptions&, const std::string& );
|
||||
using OptFunc = std::function<void( CalypOptions&, const std::string& )>;
|
||||
|
||||
FunctionOption( const std::string& name, CalypOptions& parent_, Func* func_, const std::string& desc, const std::string& def )
|
||||
: OptionBase( name, desc, def ), parent( parent_ ), func( func_ )
|
||||
public:
|
||||
FunctionOption( const std::string& name, CalypOptions& parent, OptFunc func, const std::string& desc, const std::string& def )
|
||||
: CalypOptions::OptionBase( name, desc, def ), m_parent( parent ), m_func( func )
|
||||
{
|
||||
is_binary = false;
|
||||
}
|
||||
|
||||
void parse( const std::string& arg )
|
||||
void parse( const std::string& arg ) override
|
||||
{
|
||||
func( parent, arg );
|
||||
m_func( m_parent, arg );
|
||||
arg_count++;
|
||||
}
|
||||
|
||||
private:
|
||||
CalypOptions& parent;
|
||||
void ( *func )( CalypOptions&, const std::string& );
|
||||
CalypOptions& m_parent;
|
||||
OptFunc m_func;
|
||||
};
|
||||
|
||||
/* Helper method to initiate adding options to Options */
|
||||
@@ -187,7 +187,13 @@ private:
|
||||
*/
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, const std::string& desc )
|
||||
{
|
||||
addOption( new boolOption( name, desc ) );
|
||||
addOptionInternal( std::make_unique<boolOption>( name, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, const std::string& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<boolOption>( name, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -199,14 +205,27 @@ CalypOptions& CalypOptions::operator()( const std::string& name, const std::stri
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, T& storage, const std::string& desc )
|
||||
{
|
||||
addOption( new StandardOption<T>( name, storage, desc, std::string( "" ) ) );
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc, std::string( "" ) ) );
|
||||
return *this;
|
||||
}
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, T& storage, const std::string& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc, std::string( "" ) ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, T& storage, const std::string& desc, const std::string& defaults )
|
||||
{
|
||||
addOption( new StandardOption<T>( name, storage, desc ) );
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, T& storage, const std::string& desc, const std::string& defaults )
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -223,53 +242,35 @@ template CalypOptions& CalypOptions::operator()( const std::string& name, std::v
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, std::vector<std::string>& storage,
|
||||
const std::string& desc );
|
||||
|
||||
CalypOptions::Option::Option()
|
||||
: opt( 0 ) {}
|
||||
|
||||
CalypOptions::Option::~Option()
|
||||
CalypOptions::CalypOptions( std::string name )
|
||||
: m_cOptionGroupName{ std::move( name ) }
|
||||
{
|
||||
if( opt )
|
||||
delete opt;
|
||||
}
|
||||
|
||||
CalypOptions::CalypOptions( const std::string& name )
|
||||
{
|
||||
m_cOptionGroupName = name;
|
||||
m_bAllowUnkonw = true;
|
||||
}
|
||||
|
||||
CalypOptions::~CalypOptions()
|
||||
{
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
OptionBase* CalypOptions::operator[]( const std::string& optName )
|
||||
CalypOptions::OptionBase* CalypOptions::operator[]( const std::string& optName )
|
||||
{
|
||||
return getOption( optName );
|
||||
}
|
||||
|
||||
OptionBase* CalypOptions::getOption( const std::string& optName )
|
||||
CalypOptions::OptionBase* CalypOptions::getOption( const std::string& optName )
|
||||
{
|
||||
CalypOptions::OptionMap::iterator opt_it;
|
||||
std::map<std::string, std::list<Option*>>::iterator opt_it;
|
||||
opt_it = opt_short_map.find( optName );
|
||||
if( opt_it != opt_short_map.end() )
|
||||
{
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
auto opt_list = ( *opt_it ).second;
|
||||
for( auto& option : opt_list )
|
||||
{
|
||||
return ( *it )->opt;
|
||||
return option->base_opt.get();
|
||||
}
|
||||
}
|
||||
opt_it = opt_long_map.find( optName );
|
||||
if( opt_it != opt_long_map.end() )
|
||||
{
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
auto opt_list = ( *opt_it ).second;
|
||||
for( auto& option : opt_list )
|
||||
{
|
||||
return ( *it )->opt;
|
||||
return option->base_opt.get();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -281,30 +282,20 @@ bool CalypOptions::hasOpt( const std::string& optName )
|
||||
return opt ? opt->count() > 0 ? true : false : false;
|
||||
}
|
||||
|
||||
void CalypOptions::addDefaultOptions()
|
||||
{
|
||||
addOptions() /**/
|
||||
( "help", "produce help message" ) /**/
|
||||
( "version", "show version and exit" ) /**/
|
||||
( "pel_fmts", "list pixel formats" ) /**/
|
||||
( "quality_metrics", "list supported quality metrics" ) /**/
|
||||
( "module_list", "list supported modules" ) /**/
|
||||
( "module_list_full", "detailed list supported modules" );
|
||||
}
|
||||
|
||||
CalypOptions& CalypOptions::addOptions()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CalypOptions::addOption( OptionBase* opt )
|
||||
void CalypOptions::addOptionInternal( std::unique_ptr<OptionBase> opt )
|
||||
{
|
||||
Option* names = new Option();
|
||||
names->opt = opt;
|
||||
string& opt_string = opt->opt_string;
|
||||
auto names = std::make_unique<Option>();
|
||||
names->base_opt = std::move( opt );
|
||||
opt = nullptr;
|
||||
const std::string& opt_string = names->base_opt->opt_string;
|
||||
|
||||
size_t opt_start = 0;
|
||||
for( size_t opt_end = 0; opt_end != string::npos; )
|
||||
for( size_t opt_end = 0; opt_end != std::string::npos; )
|
||||
{
|
||||
opt_end = opt_string.find_first_of( ',', opt_start );
|
||||
bool force_short = 0;
|
||||
@@ -313,36 +304,37 @@ void CalypOptions::addOption( OptionBase* opt )
|
||||
opt_start++;
|
||||
force_short = 1;
|
||||
}
|
||||
string opt_name = opt_string.substr( opt_start, opt_end - opt_start );
|
||||
std::string opt_name = opt_string.substr( opt_start, opt_end - opt_start );
|
||||
if( force_short || opt_name.size() == 1 )
|
||||
{
|
||||
names->opt_short.push_back( opt_name );
|
||||
opt_short_map[opt_name].push_back( names );
|
||||
opt_short_map[opt_name].push_back( names.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
names->opt_long.push_back( opt_name );
|
||||
opt_long_map[opt_name].push_back( names );
|
||||
opt_long_map[opt_name].push_back( names.get() );
|
||||
}
|
||||
opt_start += opt_end + 1;
|
||||
}
|
||||
opt_list.push_back( names );
|
||||
opt_list.push_back( std::move( names ) );
|
||||
}
|
||||
|
||||
static void setOptions( CalypOptions::OptionsList& opt_list, const string& value )
|
||||
static void setOptions( std::list<CalypOptions::Option*>& opt_list, const std::string& value )
|
||||
{
|
||||
/* multiple options may be registered for the same name:
|
||||
* allow each to parse value */
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
* allow each to parse value
|
||||
*/
|
||||
for( auto& option : opt_list )
|
||||
{
|
||||
( *it )->opt->parse( value );
|
||||
option->base_opt->parse( value );
|
||||
}
|
||||
}
|
||||
|
||||
bool CalypOptions::storePair( bool allow_long, bool allow_short, const string& name, const string& value )
|
||||
bool CalypOptions::storePair( bool allow_long, bool allow_short, const std::string& name, const std::string& value )
|
||||
{
|
||||
bool found = false;
|
||||
CalypOptions::OptionMap::iterator opt_it;
|
||||
std::map<std::string, std::list<Option*>>::iterator opt_it;
|
||||
if( allow_long )
|
||||
{
|
||||
opt_it = opt_long_map.find( name );
|
||||
@@ -367,7 +359,7 @@ bool CalypOptions::storePair( bool allow_long, bool allow_short, const string& n
|
||||
if( !m_bAllowUnkonw )
|
||||
{
|
||||
/* not found */
|
||||
cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << endl;
|
||||
std::cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -376,7 +368,7 @@ bool CalypOptions::storePair( bool allow_long, bool allow_short, const string& n
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalypOptions::storePair( const string& name, const string& value )
|
||||
bool CalypOptions::storePair( const std::string& name, const std::string& value )
|
||||
{
|
||||
return storePair( true, true, name, value );
|
||||
}
|
||||
@@ -384,19 +376,19 @@ bool CalypOptions::storePair( const string& name, const string& value )
|
||||
/**
|
||||
* returns number of extra arguments consumed
|
||||
*/
|
||||
unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] )
|
||||
unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] ) // NOLINT
|
||||
{
|
||||
/* gnu style long options can take the forms:
|
||||
* --option=arg
|
||||
* --option arg
|
||||
*/
|
||||
string arg( argv[0] );
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
std::string arg( argv[0] );
|
||||
std::size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
std::size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
std::string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
|
||||
unsigned int extra_argc_consumed = 0;
|
||||
if( arg_opt_sep == string::npos )
|
||||
if( arg_opt_sep == std::string::npos )
|
||||
{
|
||||
/* no argument found => argument in argv[1] (maybe) */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
@@ -416,7 +408,7 @@ unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] )
|
||||
else
|
||||
{
|
||||
/* argument occurs after option_sep */
|
||||
string val = arg.substr( arg_opt_sep + 1 );
|
||||
std::string val = arg.substr( arg_opt_sep + 1 );
|
||||
storePair( true, false, option, val );
|
||||
}
|
||||
return extra_argc_consumed;
|
||||
@@ -425,7 +417,7 @@ unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] )
|
||||
/**
|
||||
* returns number of extra arguments consumed
|
||||
*/
|
||||
unsigned int CalypOptions::parseLONG( string arg )
|
||||
unsigned int CalypOptions::parseLONG( const std::string& arg )
|
||||
{
|
||||
/* gnu style long options can take the forms:
|
||||
* --option=arg
|
||||
@@ -433,10 +425,10 @@ unsigned int CalypOptions::parseLONG( string arg )
|
||||
*/
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
std::string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
|
||||
unsigned int extra_argc_consumed = 0;
|
||||
if( arg_opt_sep == string::npos )
|
||||
if( arg_opt_sep == std::string::npos )
|
||||
{
|
||||
/* no argument found => argument in argv[1] (maybe) */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
@@ -448,36 +440,36 @@ unsigned int CalypOptions::parseLONG( string arg )
|
||||
else
|
||||
{
|
||||
/* argument occurs after option_sep */
|
||||
string val = arg.substr( arg_opt_sep + 1 );
|
||||
std::string val = arg.substr( arg_opt_sep + 1 );
|
||||
storePair( true, false, option, val );
|
||||
}
|
||||
return extra_argc_consumed;
|
||||
}
|
||||
|
||||
unsigned int CalypOptions::parseSHORT( unsigned int argc, char* argv[] )
|
||||
unsigned int CalypOptions::parseSHORT( unsigned int argc, char* argv[] ) // NOLINT
|
||||
{
|
||||
/* short options can take the forms:
|
||||
* --option arg
|
||||
* -option arg
|
||||
*/
|
||||
string arg( argv[0] );
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
string option = arg.substr( arg_opt_start );
|
||||
std::string arg( argv[0] );
|
||||
std::size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
std::string option = arg.substr( arg_opt_start );
|
||||
/* lookup option */
|
||||
|
||||
/* argument in argv[1] */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
if( argc == 1 )
|
||||
{
|
||||
cerr << "Not processing option without argument `" << option << "'" << endl;
|
||||
std::cerr << "Not processing option without argument `" << option << "'" << std::endl;
|
||||
return 0; /* run out of argv for argument */
|
||||
}
|
||||
storePair( false, true, option, string( argv[1] ) );
|
||||
storePair( false, true, option, std::string( argv[1] ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CalypOptions::parse( unsigned int argc, char* argv[] )
|
||||
int CalypOptions::parse( unsigned int argc, char* argv[] ) // NOLINT
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -499,10 +491,11 @@ int CalypOptions::parse( unsigned int argc, char* argv[] )
|
||||
return 0;
|
||||
}
|
||||
|
||||
list<const char*> CalypOptions::scanArgv( unsigned int argc, char* argv[] )
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
std::list<const char*> CalypOptions::scanArgv( unsigned int argc, char* argv[] )
|
||||
{
|
||||
/* a list for anything that didn't get handled as an option */
|
||||
list<const char*> non_option_arguments;
|
||||
std::list<const char*> non_option_arguments;
|
||||
|
||||
for( unsigned int i = 1; i < argc; i++ )
|
||||
{
|
||||
@@ -560,13 +553,13 @@ static const char spaces[41] = " ";
|
||||
* using the formatting: "-x, --long",
|
||||
* if a short/long option isn't specified, it is not printed
|
||||
*/
|
||||
static void doHelpOpt( ostream& out, const CalypOptions::Option& entry, unsigned int pad_short = 0 )
|
||||
static void doHelpOpt( std::ostream& out, const CalypOptions::Option& entry, unsigned int pad_short = 0 )
|
||||
{
|
||||
pad_short = min( pad_short, 8u );
|
||||
pad_short = std::min( pad_short, 8u );
|
||||
|
||||
if( !entry.opt_short.empty() )
|
||||
{
|
||||
unsigned int pad = max( (int)pad_short - (int)entry.opt_short.front().size(), 0 );
|
||||
unsigned int pad = std::max( (int)pad_short - (int)entry.opt_short.front().size(), 0 );
|
||||
out << "-" << entry.opt_short.front();
|
||||
if( !entry.opt_long.empty() )
|
||||
{
|
||||
@@ -587,19 +580,19 @@ static void doHelpOpt( ostream& out, const CalypOptions::Option& entry, unsigned
|
||||
}
|
||||
|
||||
/* format the help text */
|
||||
void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
{
|
||||
const unsigned int pad_short = 3;
|
||||
/* first pass: work out the longest option name */
|
||||
unsigned int max_width = 0;
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
for( auto& opt : opt_list )
|
||||
{
|
||||
ostringstream line( ios_base::out );
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
max_width = max( max_width, (unsigned int)line.tellp() );
|
||||
std::ostringstream line( std::ios_base::out );
|
||||
doHelpOpt( line, *opt, pad_short );
|
||||
max_width = std::max( max_width, (unsigned int)line.tellp() );
|
||||
}
|
||||
|
||||
unsigned int opt_width = min( max_width + 2, 28u + pad_short ) + 2;
|
||||
unsigned int opt_width = std::min( max_width + 2, 28u + pad_short ) + 2;
|
||||
unsigned int desc_width = columns - opt_width;
|
||||
|
||||
/* second pass: write out formatted option and help text.
|
||||
@@ -607,17 +600,17 @@ void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
* - if the option text is longer than opt_width, place the help
|
||||
* text at opt_width on the next line.
|
||||
*/
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
for( auto& opt : opt_list )
|
||||
{
|
||||
ostringstream line( ios_base::out );
|
||||
std::ostringstream line( std::ios_base::out );
|
||||
line << " ";
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
doHelpOpt( line, *opt, pad_short );
|
||||
|
||||
const string& opt_desc = ( *it )->opt->opt_desc;
|
||||
const std::string& opt_desc = opt->base_opt->opt_desc;
|
||||
if( opt_desc.empty() )
|
||||
{
|
||||
/* no help text: output option, skip further processing */
|
||||
cout << line.str() << endl;
|
||||
std::cout << line.str() << std::endl;
|
||||
continue;
|
||||
}
|
||||
size_t currlength = size_t( line.tellp() );
|
||||
@@ -625,17 +618,17 @@ void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
{
|
||||
/* if option text is too long (and would collide with the
|
||||
* help text, split onto next line */
|
||||
line << endl;
|
||||
line << std::endl;
|
||||
currlength = 0;
|
||||
}
|
||||
/* split up the help text, taking into account new lines,
|
||||
* (add opt_width of padding to each new line) */
|
||||
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 )
|
||||
for( std::size_t newline_pos = 0, cur_pos = 0; cur_pos != std::string::npos; currlength = 0 )
|
||||
{
|
||||
/* print any required padding space for vertical alignment */
|
||||
line << &( spaces[40 - opt_width + currlength] );
|
||||
newline_pos = opt_desc.find_first_of( '\n', newline_pos );
|
||||
if( newline_pos != string::npos )
|
||||
if( newline_pos != std::string::npos )
|
||||
{
|
||||
/* newline found, print substring (newline needn't be stripped) */
|
||||
newline_pos++;
|
||||
@@ -652,14 +645,14 @@ void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
/* find a suitable point to split text (avoid spliting in middle of word)
|
||||
*/
|
||||
size_t split_pos = opt_desc.find_last_of( ' ', cur_pos + desc_width );
|
||||
if( split_pos != string::npos )
|
||||
if( split_pos != std::string::npos )
|
||||
{
|
||||
/* eat up multiple space characters */
|
||||
split_pos = opt_desc.find_last_not_of( ' ', split_pos ) + 1;
|
||||
}
|
||||
|
||||
/* bad split if no suitable space to split at. fall back to width */
|
||||
bool bad_split = split_pos == string::npos || split_pos <= cur_pos;
|
||||
bool bad_split = split_pos == std::string::npos || split_pos <= cur_pos;
|
||||
if( bad_split )
|
||||
{
|
||||
split_pos = cur_pos + desc_width;
|
||||
@@ -677,10 +670,9 @@ void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
{
|
||||
break;
|
||||
}
|
||||
line << endl;
|
||||
line << std::endl;
|
||||
}
|
||||
|
||||
cout << line.str() << endl;
|
||||
std::cout << line.str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,24 +682,25 @@ bool CalypOptions::checkListingOpts()
|
||||
|
||||
if( hasOpt( "version" ) )
|
||||
{
|
||||
std::cout << "Calyp version " << CALYP_VERSION_STRING << "\n";
|
||||
std::cout << "Calyp version" << CALYP_VERSION_STRING << std::endl;
|
||||
bRet |= true;
|
||||
}
|
||||
if( hasOpt( "pel_fmts" ) )
|
||||
{
|
||||
printf( "Calyp supported pixel formats: \n" );
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
std::cout << "Calyp supported pixel formats:" << std::endl;
|
||||
const auto& fmt_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( const auto& [key, name] : fmt_list )
|
||||
{
|
||||
printf( " %s\n", CalypFrame::supportedPixelFormatListNames()[i].c_str() );
|
||||
std::cout << " " << name << std::endl;
|
||||
}
|
||||
bRet |= true;
|
||||
}
|
||||
if( hasOpt( "quality_metrics" ) )
|
||||
{
|
||||
printf( "Calyp supported quality metrics: \n" );
|
||||
std::cout << "Calyp supported quality metrics:" << std::endl;
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ )
|
||||
{
|
||||
printf( " %s\n", CalypFrame::supportedQualityMetricsList()[i].c_str() );
|
||||
std::cout << " " << CalypFrame::supportedQualityMetricsList()[i] << std::endl;
|
||||
}
|
||||
bRet |= true;
|
||||
}
|
||||
|
||||
+51
-46
@@ -46,30 +46,6 @@
|
||||
|
||||
#include "CalypDefs.h"
|
||||
|
||||
/**
|
||||
* \class OptionBase
|
||||
* \ingroup CalypLibGrp
|
||||
* \brief Virtual base class for storing information relating to a
|
||||
* specific option This base class describes common elements.
|
||||
* Type specific information should be stored in a derived class.
|
||||
*/
|
||||
class OptionBase
|
||||
{
|
||||
public:
|
||||
OptionBase( const std::string& name, const std::string& desc, const std::string& def )
|
||||
: arg_count( 0 ), opt_string( name ), opt_desc( desc ), opt_defaults( def ) {}
|
||||
virtual ~OptionBase() {}
|
||||
/* parse argument arg, to obtain a value for the option */
|
||||
virtual void parse( const std::string& arg ) = 0;
|
||||
int count() { return arg_count; }
|
||||
bool isBinary() { return is_binary; }
|
||||
int arg_count;
|
||||
std::string opt_string;
|
||||
std::string opt_desc;
|
||||
std::string opt_defaults;
|
||||
bool is_binary;
|
||||
};
|
||||
|
||||
/**
|
||||
* \class CalypOptions
|
||||
* \ingroup CalypLibGrp
|
||||
@@ -78,34 +54,56 @@ public:
|
||||
class CalypOptions
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Virtual base class for storing information relating to a
|
||||
* specific option This base class describes common elements.
|
||||
* Type specific information should be stored in a derived class.
|
||||
*/
|
||||
class OptionBase
|
||||
{
|
||||
public:
|
||||
OptionBase( std::string name, std::string desc, std::string def )
|
||||
: opt_string{ std::move( name ) }, opt_desc{ std::move( desc ) }, opt_defaults{ std::move( def ) } {}
|
||||
OptionBase( OptionBase&& other ) noexcept = delete;
|
||||
OptionBase& operator=( OptionBase&& other ) noexcept = delete;
|
||||
OptionBase( const OptionBase& other ) = delete;
|
||||
OptionBase& operator=( const OptionBase& other ) = delete;
|
||||
virtual ~OptionBase() = default;
|
||||
/* parse argument arg, to obtain a value for the option */
|
||||
virtual void parse( const std::string& arg ) = 0;
|
||||
auto count() const -> std::size_t { return arg_count; }
|
||||
auto isBinary() const -> bool { return is_binary; }
|
||||
std::string opt_string;
|
||||
std::string opt_desc;
|
||||
std::string opt_defaults;
|
||||
|
||||
protected:
|
||||
std::size_t arg_count{ 0 };
|
||||
bool is_binary{ false };
|
||||
};
|
||||
struct Option
|
||||
{
|
||||
Option();
|
||||
~Option();
|
||||
std::list<std::string> opt_long;
|
||||
std::list<std::string> opt_short;
|
||||
OptionBase* opt;
|
||||
std::unique_ptr<OptionBase> base_opt{ nullptr };
|
||||
};
|
||||
typedef std::list<Option*> OptionsList;
|
||||
|
||||
CalypOptions( const std::string& name = "" );
|
||||
~CalypOptions();
|
||||
CalypOptions() = default;
|
||||
CalypOptions( std::string name );
|
||||
|
||||
int parse( unsigned int argc, char* argv[] );
|
||||
int parse( unsigned int argc, char* argv[] ); // NOLINT
|
||||
void parse( std::vector<std::string> args_array );
|
||||
|
||||
std::list<const char*>& getUnhandledArgs() { return m_aUnhandledArgs; }
|
||||
void doHelp( std::ostream& out, unsigned columns = 80 );
|
||||
|
||||
OptionBase* operator[]( const std::string& optName );
|
||||
OptionBase* getOption( const std::string& optName );
|
||||
CalypOptions::OptionBase* operator[]( const std::string& optName );
|
||||
CalypOptions::OptionBase* getOption( const std::string& optName );
|
||||
|
||||
bool hasOpt( const std::string& optName );
|
||||
|
||||
OptionsList getOptionList() { return opt_list; }
|
||||
void addDefaultOptions();
|
||||
auto getOptionList() -> const std::list<std::unique_ptr<Option>>& { return opt_list; }
|
||||
CalypOptions& addOptions();
|
||||
void addOption( OptionBase* opt );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -114,6 +112,7 @@ public:
|
||||
* with desc as an optional help description
|
||||
*/
|
||||
CalypOptions& operator()( const std::string& name, const std::string& desc );
|
||||
CalypOptions& addOption( const std::string& name, const std::string& desc );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -123,29 +122,35 @@ public:
|
||||
*/
|
||||
template <typename T>
|
||||
CalypOptions& operator()( const std::string& name, T& storage, const std::string& desc );
|
||||
template <typename T>
|
||||
CalypOptions& addOption( const std::string& name, T& storage, const std::string& desc );
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& operator()( const std::string& name, T& storage, const std::string& desc, const std::string& defaults );
|
||||
template <typename T>
|
||||
CalypOptions& addOption( const std::string& name, T& storage, const std::string& desc, const std::string& defaults );
|
||||
|
||||
bool checkListingOpts();
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, OptionsList> OptionMap;
|
||||
OptionMap opt_long_map;
|
||||
OptionMap opt_short_map;
|
||||
void addOptionInternal( std::unique_ptr<OptionBase> opt );
|
||||
|
||||
OptionsList opt_list;
|
||||
private:
|
||||
std::map<std::string, std::list<Option*>> opt_long_map;
|
||||
std::map<std::string, std::list<Option*>> opt_short_map;
|
||||
|
||||
std::string m_cOptionGroupName;
|
||||
bool m_bAllowUnkonw;
|
||||
std::list<std::unique_ptr<Option>> opt_list;
|
||||
|
||||
std::string m_cOptionGroupName{ "" };
|
||||
bool m_bAllowUnkonw{ true };
|
||||
std::list<const char*> m_aUnhandledArgs;
|
||||
|
||||
bool storePair( bool allow_long, bool allow_short, const std::string& name, const std::string& value );
|
||||
bool storePair( const std::string& name, const std::string& value );
|
||||
unsigned int parseLONG( unsigned int argc, char* argv[] );
|
||||
unsigned int parseLONG( std::string arg );
|
||||
unsigned int parseSHORT( unsigned int argc, char* argv[] );
|
||||
std::list<const char*> scanArgv( unsigned int argc, char* argv[] );
|
||||
unsigned int parseLONG( unsigned int argc, char* argv[] ); // NOLINT
|
||||
unsigned int parseLONG( const std::string& arg );
|
||||
unsigned int parseSHORT( unsigned int argc, char* argv[] ); // NOLINT
|
||||
std::list<const char*> scanArgv( unsigned int argc, char* argv[] ); // NOLINT
|
||||
};
|
||||
|
||||
#endif // __CALYPOPTIONS_H__
|
||||
+29
-8
@@ -36,16 +36,16 @@ constexpr auto kMaxPixelValue{ 255 };
|
||||
|
||||
static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB )
|
||||
{
|
||||
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); //NOLINT
|
||||
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); //NOLINT
|
||||
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); //NOLINT
|
||||
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
}
|
||||
|
||||
static inline void rgbToYuv( const int& iR, const int& iG, const int& iB, int& iY, int& iU, int& iV )
|
||||
{
|
||||
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; //NOLINT
|
||||
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; //NOLINT
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; //NOLINT
|
||||
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; // NOLINT
|
||||
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; // NOLINT
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; // NOLINT
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0 )
|
||||
@@ -95,7 +95,7 @@ CalypPixel& CalypPixel::operator-=( const CalypPixel& in )
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypPixel& CalypPixel::operator*=( const double& op )
|
||||
CalypPixel& CalypPixel::operator*=( const double op )
|
||||
{
|
||||
std::transform( m_pelComp.begin(),
|
||||
m_pelComp.end(),
|
||||
@@ -130,7 +130,7 @@ CalypPixel CalypPixel::operator-( const CalypPixel& in ) const
|
||||
return result;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator*( const double& op ) const
|
||||
CalypPixel CalypPixel::operator*( const double op ) const
|
||||
{
|
||||
CalypPixel result{ m_colorSpace };
|
||||
auto& comp = result.components();
|
||||
@@ -141,6 +141,27 @@ CalypPixel CalypPixel::operator*( const double& op ) const
|
||||
return result;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator==( const CalypPixel& other ) const -> bool
|
||||
{
|
||||
return colorSpace() == other.colorSpace() &&
|
||||
std::equal( m_pelComp.begin(), m_pelComp.end(), other.components().begin() );
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p )
|
||||
{
|
||||
#ifdef CLP_DEBUG
|
||||
if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
|
||||
{
|
||||
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
|
||||
}
|
||||
#endif
|
||||
return os;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
|
||||
{
|
||||
if( m_colorSpace == eOutputSpace )
|
||||
|
||||
+163
-145
@@ -30,6 +30,7 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStreamHandlerIf.h"
|
||||
@@ -48,7 +49,7 @@
|
||||
constexpr auto kDefaultBitsPerPixel = 8;
|
||||
constexpr auto kDefaultFrameRate = 30;
|
||||
|
||||
auto find_stream_handler( std::string strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn;
|
||||
auto find_stream_handler( const std::string& strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn;
|
||||
|
||||
std::vector<CalypStreamFormat> CalypStream::supportedReadFormats()
|
||||
{
|
||||
@@ -112,7 +113,7 @@ struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuf
|
||||
std::vector<std::unique_ptr<CalypFrame>> framePool;
|
||||
std::size_t bufferIdx{ 0 };
|
||||
|
||||
CalypStreamFrameBuffer( std::size_t size, unsigned int width, unsigned int height, int pelFormat, unsigned int bitsPixel, bool hasNegative )
|
||||
CalypStreamFrameBuffer( std::size_t size, unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned int bitsPixel, bool hasNegative )
|
||||
{
|
||||
framePool.reserve( size );
|
||||
for( std::size_t i = 0; i < size; i++ )
|
||||
@@ -165,18 +166,14 @@ class CalypStream::CalypStreamPrivate
|
||||
{
|
||||
public:
|
||||
std::recursive_mutex stream_mutex;
|
||||
CalypStream::Type streamType;
|
||||
bool isInit;
|
||||
bool isInput;
|
||||
|
||||
std::unique_ptr<CalypStreamHandlerIf> handler;
|
||||
|
||||
std::shared_ptr<CalypStreamFrameBuffer> frameBuffer;
|
||||
std::deque<std::shared_ptr<CalypFrame>> frameFifo;
|
||||
|
||||
// std::vector<std::unique_ptr<CalypFrame>> framePool;
|
||||
// std::deque<std::shared_ptr<CalypFrame>> frameFifo;
|
||||
// std::size_t bufferIdx{ 0 };
|
||||
|
||||
std::string cFilename;
|
||||
long long int iCurrFrameNum;
|
||||
bool bLoadAll;
|
||||
@@ -188,11 +185,10 @@ public:
|
||||
CalypStreamPrivate()
|
||||
{
|
||||
handler = nullptr;
|
||||
isInput = true;
|
||||
streamType = CalypStream::Type::Input;
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
iCurrFrameNum = -1;
|
||||
cFilename = "";
|
||||
}
|
||||
|
||||
~CalypStreamPrivate()
|
||||
@@ -200,6 +196,110 @@ public:
|
||||
close();
|
||||
}
|
||||
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
|
||||
{
|
||||
if( isInit )
|
||||
{
|
||||
close();
|
||||
}
|
||||
isInit = false;
|
||||
streamType = type;
|
||||
bool isInput = streamType == CalypStream::Type::Input;
|
||||
|
||||
if( forceRaw )
|
||||
{
|
||||
handler = StreamHandlerRaw::Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto createHandlerFct = find_stream_handler( filename, isInput );
|
||||
if( !createHandlerFct )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Invalid handler" );
|
||||
}
|
||||
|
||||
handler = createHandlerFct();
|
||||
}
|
||||
|
||||
if( !handler )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot create handler" );
|
||||
}
|
||||
|
||||
cFilename = std::move( filename );
|
||||
|
||||
handler->m_uiWidth = width;
|
||||
handler->m_uiHeight = height;
|
||||
handler->m_iPixelFormat = input_format;
|
||||
handler->m_uiBitsPerPixel = bitsPel;
|
||||
handler->m_iEndianness = bitsPel > 8 ? endianness : CLP_BIG_ENDIAN;
|
||||
handler->m_dFrameRate = frame_rate;
|
||||
|
||||
if( !handler->openHandler( cFilename, isInput ) )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot create the stream handler" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
if( handler->m_uiWidth <= 0 || handler->m_uiHeight <= 0 || handler->m_iPixelFormat == ClpPixelFormats::Invalid )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
frameFifo.clear();
|
||||
|
||||
// Keep past, current and future frames
|
||||
std::size_t bufferSize = isInput ? 6 : 1;
|
||||
try
|
||||
{
|
||||
frameBuffer = std::make_shared<CalypStreamFrameBuffer>( bufferSize,
|
||||
handler->m_uiWidth,
|
||||
handler->m_uiHeight,
|
||||
handler->m_iPixelFormat,
|
||||
handler->m_uiBitsPerPixel,
|
||||
hasNegative );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
const CalypFrame* refFrame = frameBuffer->ref();
|
||||
|
||||
handler->m_uiNBytesPerFrame = refFrame->getBytesPerFrame();
|
||||
|
||||
// Some handlers need to know how long is a frame to get frame number
|
||||
handler->calculateFrameNumber();
|
||||
|
||||
if( isInput && handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
if( !handler->configureBuffer( *refFrame ) )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated buffers" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
iCurrFrameNum = -1;
|
||||
isInit = true;
|
||||
|
||||
seekInput( 0 );
|
||||
|
||||
isInit = true;
|
||||
return isInit;
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
if( handler )
|
||||
@@ -211,11 +311,35 @@ public:
|
||||
isInit = false;
|
||||
}
|
||||
|
||||
bool seekInput( unsigned long new_frame_num )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || new_frame_num >= handler->m_uiTotalNumberFrames || long( new_frame_num ) == iCurrFrameNum )
|
||||
return false;
|
||||
|
||||
iCurrFrameNum = new_frame_num;
|
||||
|
||||
if( bLoadAll )
|
||||
return true;
|
||||
|
||||
frameFifo.clear();
|
||||
if( !handler->seek( iCurrFrameNum ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot seek file into desired position" );
|
||||
}
|
||||
|
||||
readNextFrame();
|
||||
if( handler->m_uiTotalNumberFrames > 1 )
|
||||
readNextFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readNextFrame( bool fillRgbBuffer = false )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || !isInput || handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
|
||||
if( !isInit || streamType != CalypStream::Type::Input || handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
|
||||
return false;
|
||||
|
||||
if( bLoadAll )
|
||||
@@ -269,11 +393,10 @@ std::string CalypStream::getCodecName() const
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, std::string resolution, std::string input_format_name, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
int input_format = -1;
|
||||
|
||||
if( resolution.size() > 0 )
|
||||
{
|
||||
@@ -283,122 +406,36 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
|
||||
const auto input_format = CalypFrame::findPixelFormat( input_format_name );
|
||||
if( !input_format.has_value() )
|
||||
{
|
||||
if( clpLowercase( CalypFrame::supportedPixelFormatListNames()[i] ) == clpLowercase( input_format_name ) )
|
||||
{
|
||||
input_format = i;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return open( filename, width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, bInput );
|
||||
return d->open( std::move( filename ), width, height, *input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
return open( filename, width, height, input_format, bitsPel, endianness, false, frame_rate, bInput );
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, CalypStream::Type type )
|
||||
{
|
||||
if( d->isInit )
|
||||
{
|
||||
d->close();
|
||||
}
|
||||
d->isInit = false;
|
||||
d->isInput = bInput;
|
||||
|
||||
auto createHandlerFct = find_stream_handler( filename, d->isInput );
|
||||
if( !createHandlerFct )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Invalid handler" );
|
||||
}
|
||||
|
||||
d->handler = createHandlerFct();
|
||||
|
||||
if( !d->handler )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot create handler" );
|
||||
}
|
||||
|
||||
d->cFilename = filename;
|
||||
|
||||
d->handler->m_cFilename = filename;
|
||||
d->handler->m_uiWidth = width;
|
||||
d->handler->m_uiHeight = height;
|
||||
d->handler->m_iPixelFormat = input_format;
|
||||
d->handler->m_uiBitsPerPixel = bitsPel;
|
||||
d->handler->m_iEndianness = endianness;
|
||||
d->handler->m_dFrameRate = frame_rate;
|
||||
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
{
|
||||
d->close();
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 )
|
||||
{
|
||||
d->close();
|
||||
//throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
d->frameFifo.clear();
|
||||
|
||||
// Keep past, current and future frames
|
||||
std::size_t bufferSize = d->isInput ? 6 : 1;
|
||||
try
|
||||
{
|
||||
d->frameBuffer = std::make_shared<CalypStreamFrameBuffer>( bufferSize,
|
||||
d->handler->m_uiWidth,
|
||||
d->handler->m_uiHeight,
|
||||
d->handler->m_iPixelFormat,
|
||||
d->handler->m_uiBitsPerPixel,
|
||||
hasNegative );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
d->close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
const CalypFrame* refFrame = d->frameBuffer->ref();
|
||||
|
||||
d->handler->m_uiNBytesPerFrame = refFrame->getBytesPerFrame();
|
||||
|
||||
// Some handlers need to know how long is a frame to get frame number
|
||||
d->handler->calculateFrameNumber();
|
||||
|
||||
if( d->isInput && d->handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
d->close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( !d->handler->configureBuffer( *refFrame ) )
|
||||
{
|
||||
d->close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated buffers" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
d->iCurrFrameNum = -1;
|
||||
d->isInit = true;
|
||||
|
||||
seekInput( 0 );
|
||||
|
||||
d->isInit = true;
|
||||
return d->isInit;
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormating()
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
|
||||
{
|
||||
if( d->handler != nullptr )
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, forceRaw, type );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormatConfiguration()
|
||||
{
|
||||
if( d->handler == nullptr )
|
||||
return false;
|
||||
return d->handler->m_bSupportsFormat;
|
||||
}
|
||||
@@ -407,7 +444,7 @@ bool CalypStream::reload()
|
||||
{
|
||||
d->frameFifo.clear();
|
||||
d->handler->closeHandler();
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
if( !d->handler->openHandler( d->cFilename, d->streamType == CalypStream::Type::Input ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot open stream " + d->cFilename + " with the " +
|
||||
std::string( d->handler->m_pchHandlerName ) + " handler" );
|
||||
@@ -417,7 +454,7 @@ bool CalypStream::reload()
|
||||
d->handler->calculateFrameNumber();
|
||||
d->handler->configureBuffer( *refFrame );
|
||||
|
||||
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 ||
|
||||
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat == ClpPixelFormats::Invalid ||
|
||||
d->handler->m_uiBitsPerPixel == 0 || d->handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
return false;
|
||||
@@ -472,7 +509,7 @@ long CalypStream::getCurrFrameNum() const
|
||||
return d->iCurrFrameNum;
|
||||
}
|
||||
|
||||
void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate ) const
|
||||
{
|
||||
if( d->isInit )
|
||||
@@ -488,7 +525,7 @@ void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, int& r
|
||||
{
|
||||
rWidth = 0;
|
||||
rHeight = 0;
|
||||
rInputFormat = CLP_YUV420P;
|
||||
rInputFormat = ClpPixelFormats::YUV420p;
|
||||
rBitsPerPel = kDefaultBitsPerPixel;
|
||||
rEndianness = 0;
|
||||
rFrameRate = kDefaultFrameRate;
|
||||
@@ -512,7 +549,7 @@ auto CalypStream::hasWritingSlot() -> bool
|
||||
void CalypStream::loadAll()
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( d->stream_mutex );
|
||||
if( d->bLoadAll || !d->isInput )
|
||||
if( d->bLoadAll || d->streamType != CalypStream::Type::Input )
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -611,7 +648,7 @@ bool CalypStream::saveFrame( const std::string& filename, const CalypFrame& save
|
||||
{
|
||||
CalypStream auxSaveStream;
|
||||
if( !auxSaveStream.open( filename, saveFrame.getWidth(), saveFrame.getHeight(), saveFrame.getPelFormat(),
|
||||
saveFrame.getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ) )
|
||||
saveFrame.getBitsPel(), CLP_LITTLE_ENDIAN, 1, Type::Output ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -624,7 +661,7 @@ bool CalypStream::saveFrame( const std::string& filename, const CalypFrame& save
|
||||
*/
|
||||
bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
{
|
||||
if( !d->isInit || !d->isInput )
|
||||
if( !d->isInit || d->streamType != Type::Input )
|
||||
return false;
|
||||
|
||||
bool bRet = false;
|
||||
@@ -643,29 +680,10 @@ bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
|
||||
bool CalypStream::seekInput( unsigned long new_frame_num )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( d->stream_mutex );
|
||||
|
||||
if( !d->isInit || new_frame_num >= d->handler->m_uiTotalNumberFrames || long( new_frame_num ) == d->iCurrFrameNum )
|
||||
return false;
|
||||
|
||||
d->iCurrFrameNum = new_frame_num;
|
||||
|
||||
if( d->bLoadAll )
|
||||
return true;
|
||||
|
||||
d->frameFifo.clear();
|
||||
if( !d->handler->seek( d->iCurrFrameNum ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot seek file into desired position" );
|
||||
}
|
||||
|
||||
d->readNextFrame();
|
||||
if( d->handler->m_uiTotalNumberFrames > 1 )
|
||||
d->readNextFrame();
|
||||
return true;
|
||||
return d->seekInput( new_frame_num );
|
||||
}
|
||||
|
||||
auto find_stream_handler( std::string strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn
|
||||
auto find_stream_handler( const std::string& strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn
|
||||
{
|
||||
std::string currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
|
||||
currExt = clpLowercase( currExt );
|
||||
|
||||
+36
-9
@@ -29,7 +29,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypFrame.h"
|
||||
|
||||
class CalypStreamHandlerIf;
|
||||
@@ -69,6 +68,12 @@ public:
|
||||
class CalypStream
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Input,
|
||||
Output
|
||||
};
|
||||
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats();
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats();
|
||||
static std::vector<CalypStandardResolution> stdResolutionSizes();
|
||||
@@ -83,14 +88,36 @@ public:
|
||||
std::string getFormatName() const;
|
||||
std::string getCodecName() const;
|
||||
|
||||
bool open( std::string filename, std::string resolution, std::string input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( std::string filename,
|
||||
std::string resolution,
|
||||
std::string input_format,
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
bool hasNegative,
|
||||
unsigned int frame_rate,
|
||||
Type type );
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, CalypStream::Type type );
|
||||
bool open( std::string filename,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
ClpPixelFormats input_format,
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
bool hasNegative,
|
||||
unsigned int frame_rate,
|
||||
Type type );
|
||||
bool open( std::string filename,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
ClpPixelFormats input_format,
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
unsigned int frame_rate,
|
||||
bool forceRaw,
|
||||
Type type );
|
||||
|
||||
bool supportsFormating();
|
||||
bool supportsFormatConfiguration();
|
||||
bool reload();
|
||||
|
||||
bool isNative() const;
|
||||
@@ -102,7 +129,7 @@ public:
|
||||
int getEndianess() const;
|
||||
long getCurrFrameNum() const;
|
||||
double getFrameRate() const;
|
||||
void getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
void getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate ) const;
|
||||
|
||||
auto hasNextFrame() -> bool;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
#define INI_REGIST_CALYP_SUPPORTED_FMT \
|
||||
@@ -102,10 +103,9 @@ protected:
|
||||
std::string m_strCodecName;
|
||||
bool m_bIsInput{ true };
|
||||
bool m_bNative{ true };
|
||||
std::string m_cFilename;
|
||||
unsigned int m_uiWidth{ 0 };
|
||||
unsigned int m_uiHeight{ 0 };
|
||||
int m_iPixelFormat{ -1 };
|
||||
ClpPixelFormats m_iPixelFormat{ ClpPixelFormats::Invalid };
|
||||
unsigned int m_uiBitsPerPixel{ 8 };
|
||||
int m_iEndianness{ CLP_INVALID_ENDIANESS };
|
||||
double m_dFrameRate{ 30 };
|
||||
|
||||
+21
-21
@@ -43,11 +43,11 @@
|
||||
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
|
||||
#endif
|
||||
|
||||
const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
{
|
||||
CLP_YUV420P,
|
||||
ClpPixelFormats::YUV420p,
|
||||
{
|
||||
"YUV420p",
|
||||
"YUV420p"sv,
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -62,9 +62,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_YUV422P,
|
||||
ClpPixelFormats::YUV422p,
|
||||
{
|
||||
"YUV422p",
|
||||
"YUV422p"sv,
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -79,9 +79,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_YUV444P,
|
||||
ClpPixelFormats::YUV444p,
|
||||
{
|
||||
"YUV444p",
|
||||
"YUV444p"sv,
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -96,9 +96,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_YUYV422,
|
||||
ClpPixelFormats::YUYV422,
|
||||
{
|
||||
"YUYV422",
|
||||
"YUYV422"sv,
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
1,
|
||||
@@ -113,9 +113,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_GRAY,
|
||||
ClpPixelFormats::Gray,
|
||||
{
|
||||
"GRAY",
|
||||
"GRAY"sv,
|
||||
CLP_COLOR_GRAY,
|
||||
1,
|
||||
1,
|
||||
@@ -126,9 +126,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_RGB24P,
|
||||
ClpPixelFormats::RGB24p,
|
||||
{
|
||||
"RGBp",
|
||||
"RGBp"sv,
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
3,
|
||||
@@ -143,9 +143,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_RGB24,
|
||||
ClpPixelFormats::RGB24,
|
||||
{
|
||||
"RGB",
|
||||
"RGB"sv,
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
@@ -160,9 +160,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_BGR24,
|
||||
ClpPixelFormats::BGR24,
|
||||
{
|
||||
"BGR",
|
||||
"BGR"sv,
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
@@ -177,9 +177,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_RGBA32,
|
||||
ClpPixelFormats::RGBA32,
|
||||
{
|
||||
"RGBA",
|
||||
"RGBA"sv,
|
||||
CLP_COLOR_RGBA,
|
||||
4,
|
||||
1,
|
||||
@@ -195,9 +195,9 @@ const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
},
|
||||
},
|
||||
{
|
||||
CLP_BGRA32,
|
||||
ClpPixelFormats::BGRA32,
|
||||
{
|
||||
"BGRA",
|
||||
"BGRA"sv,
|
||||
CLP_COLOR_RGBA,
|
||||
4,
|
||||
1,
|
||||
|
||||
+19
-12
@@ -29,11 +29,21 @@
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
#define CHROMA_RESAMPLING( X ) ( ( ( X + 1 ) >> 1 ) << 1 )
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
#define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE )
|
||||
template <typename T>
|
||||
inline constexpr T CHROMA_RESAMPLING( T in )
|
||||
{
|
||||
return ( ( ( in + 1 ) >> 1 ) << 1 );
|
||||
}
|
||||
|
||||
typedef struct CalypComponentDescriptor
|
||||
template <typename T, typename R>
|
||||
inline constexpr T CHROMARATIO( T size, R ratio )
|
||||
{
|
||||
return ( ratio > 1 ? ( ( size + 1 ) / ratio ) : size );
|
||||
}
|
||||
|
||||
struct CalypComponentDescriptor
|
||||
{
|
||||
/**
|
||||
* Which of the 4 planes contains the component.
|
||||
@@ -51,8 +61,7 @@ typedef struct CalypComponentDescriptor
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
unsigned short offset_plus1;
|
||||
|
||||
} CalypComponentDescriptor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Descriptor that unambiguously describes how the bits of a pixel are
|
||||
@@ -63,9 +72,9 @@ typedef struct CalypComponentDescriptor
|
||||
* and all the YUV variants) AVPixFmtDescriptor just stores how values
|
||||
* are stored not what these values represent.
|
||||
*/
|
||||
typedef struct CalypPixelFormatDescriptor
|
||||
struct CalypPixelFormatDescriptor
|
||||
{
|
||||
const char* name;
|
||||
std::string_view name;
|
||||
|
||||
int colorSpace;
|
||||
|
||||
@@ -102,11 +111,9 @@ typedef struct CalypPixelFormatDescriptor
|
||||
* otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
|
||||
*/
|
||||
CalypComponentDescriptor comp[4];
|
||||
};
|
||||
|
||||
} CalypPixelFormatDescriptor;
|
||||
|
||||
#define MAX_NUMBER_PLANES 3
|
||||
|
||||
extern const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap;
|
||||
static constexpr std::size_t kNumberOfPixelFormats{ 10 };
|
||||
extern const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap;
|
||||
|
||||
#endif // __PIXELFORMATS_H__
|
||||
+20
-24
@@ -90,7 +90,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
// }
|
||||
|
||||
// Register all components of FFmpeg
|
||||
//av_register_all();
|
||||
// av_register_all();
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if( avformat_open_input( &m_cFmtCtx, filename, NULL, NULL ) < 0 )
|
||||
@@ -172,8 +172,8 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
m_uiBitsPerPixel = 8;
|
||||
|
||||
/**
|
||||
* Auxiliar conversation to re-use similar pixfmt
|
||||
*/
|
||||
* Auxiliar conversation to re-use similar pixfmt
|
||||
*/
|
||||
int auxPixFmt = m_ffPixFmt;
|
||||
switch( m_ffPixFmt )
|
||||
{
|
||||
@@ -197,20 +197,16 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
auxPixFmt = AV_PIX_FMT_GRAY8;
|
||||
}
|
||||
|
||||
m_iPixelFormat = CLP_INVALID_FMT;
|
||||
for( int i = 0; i < CalypFrame::numberOfFormats(); i++ )
|
||||
m_iPixelFormat = ClpPixelFormats::Invalid;
|
||||
m_bNative = false;
|
||||
auto found_fmt = std::find_if( g_CalypPixFmtDescriptorsMap.begin(), g_CalypPixFmtDescriptorsMap.end(),
|
||||
[auxPixFmt]( const auto& fmt ) {
|
||||
return fmt.second.ffmpegPelFormat == auxPixFmt;
|
||||
} );
|
||||
if( found_fmt != g_CalypPixFmtDescriptorsMap.end() )
|
||||
{
|
||||
if( g_CalypPixFmtDescriptorsMap.at( i ).ffmpegPelFormat == auxPixFmt )
|
||||
{
|
||||
m_iPixelFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( m_iPixelFormat == CLP_INVALID_FMT )
|
||||
{
|
||||
m_bNative = false;
|
||||
//throw CalypFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" );
|
||||
//return false;
|
||||
m_bNative = true;
|
||||
m_iPixelFormat = found_fmt->first;
|
||||
}
|
||||
|
||||
double fr = 30;
|
||||
@@ -249,27 +245,27 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
if( !m_bNative )
|
||||
{
|
||||
int newPelFmt = -1;
|
||||
ClpPixelFormats newPelFmt{ ClpPixelFormats::Invalid };
|
||||
const AVPixFmtDescriptor* ffPelDesc = av_pix_fmt_desc_get( AVPixelFormat( m_ffPixFmt ) );
|
||||
if( ffPelDesc->flags & AV_PIX_FMT_FLAG_PAL )
|
||||
{
|
||||
newPelFmt = CLP_RGB24;
|
||||
newPelFmt = ClpPixelFormats::RGB24;
|
||||
}
|
||||
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_ALPHA )
|
||||
{
|
||||
newPelFmt = CLP_RGBA32;
|
||||
newPelFmt = ClpPixelFormats::RGBA32;
|
||||
}
|
||||
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_RGB )
|
||||
{
|
||||
newPelFmt = CLP_RGB24;
|
||||
newPelFmt = ClpPixelFormats::RGB24;
|
||||
}
|
||||
else if( ffPelDesc->nb_components == 1 )
|
||||
{
|
||||
newPelFmt = CLP_GRAY;
|
||||
newPelFmt = ClpPixelFormats::Gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPelFmt = CLP_YUV444P;
|
||||
newPelFmt = ClpPixelFormats::YUV444p;
|
||||
}
|
||||
m_iPixelFormat = newPelFmt;
|
||||
|
||||
@@ -369,8 +365,8 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
bReadPkt = true;
|
||||
else
|
||||
return false;
|
||||
//if( iRet == AVERROR_EOF )
|
||||
// m_isEOF = true;
|
||||
// if( iRet == AVERROR_EOF )
|
||||
// m_isEOF = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+15
-13
@@ -28,6 +28,8 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#if CV_MAJOR_VERSION >= 3
|
||||
#include <opencv2/videoio.hpp>
|
||||
#endif
|
||||
@@ -60,12 +62,12 @@ std::vector<CalypStreamFormat> StreamHandlerOpenCV::supportedWriteFormats()
|
||||
StreamHandlerOpenCV::StreamHandlerOpenCV()
|
||||
{
|
||||
m_pchHandlerName = "OpenCV";
|
||||
pcVideoCapture = NULL;
|
||||
m_pcVideoCapture = NULL;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
{
|
||||
m_cFilename = strFilename;
|
||||
m_cFilename = std::move( strFilename );
|
||||
if( bInput )
|
||||
{
|
||||
#if( CV_VERSION_MAJOR >= 3 )
|
||||
@@ -82,10 +84,10 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
m_strFormatName = "DEV";
|
||||
m_strCodecName = "Raw Video";
|
||||
pcVideoCapture = new VideoCapture( iDeviceId );
|
||||
m_pcVideoCapture = new VideoCapture( iDeviceId );
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
m_uiWidth = pcVideoCapture->get( cv::CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( cv::CAP_PROP_FRAME_HEIGHT );
|
||||
m_uiWidth = m_pcVideoCapture->get( cv::CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = m_pcVideoCapture->get( cv::CAP_PROP_FRAME_HEIGHT );
|
||||
#else
|
||||
m_uiWidth = pcVideoCapture->get( CV_CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( CV_CAP_PROP_FRAME_HEIGHT );
|
||||
@@ -103,10 +105,10 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
m_dFrameRate = 1;
|
||||
}
|
||||
m_uiBitsPerPixel = 8;
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "BGR" );
|
||||
m_iPixelFormat = ClpPixelFormats::BGR24;
|
||||
|
||||
m_uiTotalNumberFrames = 1;
|
||||
if( pcVideoCapture )
|
||||
if( m_pcVideoCapture )
|
||||
{
|
||||
m_uiTotalNumberFrames = 2;
|
||||
}
|
||||
@@ -117,11 +119,11 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
void StreamHandlerOpenCV::closeHandler()
|
||||
{
|
||||
if( pcVideoCapture )
|
||||
if( m_pcVideoCapture )
|
||||
{
|
||||
pcVideoCapture->release();
|
||||
delete pcVideoCapture;
|
||||
pcVideoCapture = NULL;
|
||||
m_pcVideoCapture->release();
|
||||
delete m_pcVideoCapture;
|
||||
m_pcVideoCapture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +141,10 @@ bool StreamHandlerOpenCV::seek( std::uint64_t iFrameNum )
|
||||
bool StreamHandlerOpenCV::read( CalypFrame& pcFrame )
|
||||
{
|
||||
bool bRet = false;
|
||||
if( pcVideoCapture )
|
||||
if( m_pcVideoCapture )
|
||||
{
|
||||
Mat cvMat;
|
||||
bRet = pcVideoCapture->read( cvMat );
|
||||
bRet = m_pcVideoCapture->read( cvMat );
|
||||
if( bRet )
|
||||
bRet = pcFrame.fromMat( cvMat );
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
bool write( const CalypFrame& pcFrame );
|
||||
|
||||
private:
|
||||
cv::VideoCapture* pcVideoCapture;
|
||||
std::string m_cFilename;
|
||||
cv::VideoCapture* m_pcVideoCapture;
|
||||
};
|
||||
|
||||
#endif // __STREAMHANDLEROPENCV_H__
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerPortableMap::supportedReadFormats()
|
||||
{
|
||||
@@ -79,7 +80,7 @@ bool StreamHandlerPortableMap::openHandler( std::string strFilename, bool bInput
|
||||
}
|
||||
}
|
||||
m_uiBitsPerPixel = log( m_iMaxValue + 1 ) / log( 2 );
|
||||
m_iPixelFormat = m_iMagicNumber == 1 || m_iMagicNumber == 2 || m_iMagicNumber == 5 ? CLP_GRAY : CLP_RGB24;
|
||||
m_iPixelFormat = m_iMagicNumber == 1 || m_iMagicNumber == 2 || m_iMagicNumber == 5 ? ClpPixelFormats::Gray : ClpPixelFormats::RGB24;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -88,17 +89,17 @@ bool StreamHandlerPortableMap::openHandler( std::string strFilename, bool bInput
|
||||
if( m_uiBitsPerPixel == 1 )
|
||||
{
|
||||
m_iMagicNumber = 1;
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "GRAY" );
|
||||
m_iPixelFormat = ClpPixelFormats::Gray;
|
||||
}
|
||||
else if( colorSpace == CLP_COLOR_GRAY )
|
||||
{
|
||||
m_iMagicNumber = 5;
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "GRAY" );
|
||||
m_iPixelFormat = ClpPixelFormats::Gray;
|
||||
}
|
||||
else if( colorSpace == CLP_COLOR_RGB )
|
||||
{
|
||||
m_iMagicNumber = 6;
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "RGB" );
|
||||
m_iPixelFormat = ClpPixelFormats::RGB24;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "StreamHandlerRaw.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
@@ -34,6 +35,7 @@ std::vector<CalypStreamFormat> StreamHandlerRaw::supportedReadFormats()
|
||||
REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw YUV Video", "yuv" );
|
||||
REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Gray Video", "gray" );
|
||||
REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw RGB Video", "rgb" );
|
||||
REGIST_CALYP_SUPPORTED_FMT( &StreamHandlerRaw::Create, "Raw Video", "raw" );
|
||||
END_REGIST_CALYP_SUPPORTED_FMT;
|
||||
}
|
||||
|
||||
@@ -60,7 +62,9 @@ bool StreamHandlerRaw::openHandler( std::string strFilename, bool bInput )
|
||||
return false;
|
||||
}
|
||||
calculateFrameNumber();
|
||||
m_strFormatName = "YUV";
|
||||
std::string fileExtension = std::filesystem::path{ strFilename }.extension().string();
|
||||
fileExtension.erase( fileExtension.begin() );
|
||||
m_strFormatName = clpUppercase( fileExtension );
|
||||
m_strCodecName = "Raw Video";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,16 @@
|
||||
# CMakeLists for Calyp lis tests using catch2
|
||||
#
|
||||
|
||||
# ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
FETCHCONTENT_MAKEAVAILABLE(Catch2)
|
||||
|
||||
SET(Calyp_Lib_Catch2_Tests_SRCS CalypFrameTests.cpp)
|
||||
|
||||
SET(Calyp_Lib_Catch2_Tests_SRCS
|
||||
CalypLibTests.cpp
|
||||
CalypStreamTests.cpp
|
||||
CalypFrameTests.cpp
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS})
|
||||
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* \brief CalypFrame general tests
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
@@ -30,32 +29,32 @@
|
||||
TEST_CASE( "create a 256x128 frame with 8 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 8 );
|
||||
CalypFrame testFrame( 256, 128, ClpPixelFormats::YUV420p, 8 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 8 );
|
||||
CHECK( testFrame.getWidth() == 256 );
|
||||
CHECK( testFrame.getHeight() == 128 );
|
||||
CHECK( testFrame.getPelFormat() == ClpPixelFormats::YUV420p );
|
||||
CHECK( testFrame.getBitsPel() == 8 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 10 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 10 );
|
||||
CalypFrame testFrame( 256, 128, ClpPixelFormats::YUV420p, 10 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 10 );
|
||||
CHECK( testFrame.getWidth() == 256 );
|
||||
CHECK( testFrame.getHeight() == 128 );
|
||||
CHECK( testFrame.getPelFormat() == ClpPixelFormats::YUV420p );
|
||||
CHECK( testFrame.getBitsPel() == 10 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 16 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 16 );
|
||||
CalypFrame testFrame( 256, 128, ClpPixelFormats::YUV420p, 16 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 16 );
|
||||
CHECK( testFrame.getWidth() == 256 );
|
||||
CHECK( testFrame.getHeight() == 128 );
|
||||
CHECK( testFrame.getPelFormat() == ClpPixelFormats::YUV420p );
|
||||
CHECK( testFrame.getBitsPel() == 16 );
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* This file is a part of plaYUVer 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 CalypLibTests.cpp
|
||||
* \brief CalypLib main test file
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
@@ -0,0 +1,279 @@
|
||||
/* This file is a part of plaYUVer 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 CalypStreamTests.cpp
|
||||
* \brief CalypStream general tests
|
||||
*/
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <variant>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
constexpr int kFrameRate{ 30 };
|
||||
constexpr auto kStreamType = CalypStream::Type::Input;
|
||||
|
||||
auto getFileTestFilename( const char* test_sequence ) -> std::string
|
||||
{
|
||||
return std::string( CALYP_TEST_DATA_DIR ) + std::string( "/" ) + std::string( test_sequence );
|
||||
}
|
||||
|
||||
TEST_CASE( "Can open a YUV 420p file", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
|
||||
constexpr int kBitsPel{ 8 };
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
const auto kFilename = getFileTestFilename( "Foreman.yuv" );
|
||||
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
CHECK( test_stream.getWidth() == kWidth );
|
||||
CHECK( test_stream.getHeight() == kHeight );
|
||||
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
|
||||
CHECK( test_stream.getFormatName() == "YUV" );
|
||||
CHECK( test_stream.getCodecName() == "Raw Video" );
|
||||
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );
|
||||
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getPixel( 2, 0 ) == CalypPixel{ CLP_COLOR_YUV, 201, 129, 125 } );
|
||||
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
|
||||
}
|
||||
|
||||
TEST_CASE( "Can open a YUV file", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr int kBitsPel{ 8 };
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
SECTION( "YUV420p" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
|
||||
const auto kFilename = getFileTestFilename( "Foreman.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
|
||||
CHECK( frame->getPelFmtName() == "YUV420p" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
SECTION( "YUV422p" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUV422p };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuv422p.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
|
||||
CHECK( frame->getPelFmtName() == "YUV422p" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
SECTION( "YUV444p" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUV444p };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuv444p.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
|
||||
CHECK( frame->getPelFmtName() == "YUV444p" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
SECTION( "YUYV422" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUYV422 };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_yuyv422.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_YUV );
|
||||
CHECK( frame->getPelFmtName() == "YUYV422" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Can open a RGB file", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr int kBitsPel{ 8 };
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
SECTION( "RGB24" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::RGB24 };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_rgb24.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_RGB );
|
||||
CHECK( frame->getPelFmtName() == "RGB" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
|
||||
std::cout << test_stream.getFormatName();
|
||||
}
|
||||
|
||||
SECTION( "BGR24" )
|
||||
{
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::BGR24 };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_bgr24.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_RGB );
|
||||
CHECK( frame->getPelFmtName() == "BGR" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Can open a GRAY file", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr int kBitsPel{ 8 };
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
auto common_checks = []( auto& stream ) {
|
||||
return stream.getWidth() == kWidth &&
|
||||
stream.getHeight() == kHeight &&
|
||||
stream.getBitsPerPixel() == kBitsPel &&
|
||||
stream.getFormatName() == "YUV" &&
|
||||
stream.getCodecName() == "Raw Video" &&
|
||||
stream.getEndianess() == CLP_BIG_ENDIAN;
|
||||
};
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::Gray };
|
||||
const auto kFilename = getFileTestFilename( "Foreman_352x288_gray.yuv" );
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
|
||||
REQUIRE( result );
|
||||
CHECK( common_checks( test_stream ) );
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
CHECK( frame->getColorSpace() == CLP_COLOR_GRAY );
|
||||
CHECK( frame->getPelFmtName() == "GRAY" );
|
||||
CHECK( frame->getPelFormat() == kInputFormat );
|
||||
}
|
||||
|
||||
TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
|
||||
constexpr int kBitsPel{ 8 };
|
||||
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
|
||||
|
||||
const auto kFilename = getFileTestFilename( "Foreman.batatas" );
|
||||
|
||||
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
|
||||
|
||||
bool force_raw{ false };
|
||||
|
||||
SECTION( "Without forcing raw video" )
|
||||
{
|
||||
CalypStream test_stream;
|
||||
bool result{ false };
|
||||
try
|
||||
{
|
||||
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// NOLINT
|
||||
}
|
||||
|
||||
CHECK( !result );
|
||||
}
|
||||
|
||||
SECTION( "Forcing raw video" )
|
||||
{
|
||||
force_raw = true;
|
||||
|
||||
CalypStream test_stream;
|
||||
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
|
||||
|
||||
REQUIRE( result );
|
||||
|
||||
CHECK( test_stream.getWidth() == kWidth );
|
||||
CHECK( test_stream.getHeight() == kHeight );
|
||||
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
|
||||
CHECK( test_stream.getFormatName() == "BATATAS" );
|
||||
CHECK( test_stream.getCodecName() == "Raw Video" );
|
||||
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );
|
||||
|
||||
const auto* frame = test_stream.getCurrFrame();
|
||||
|
||||
CHECK( frame->getPixel( 2, 0 ) == CalypPixel{ CLP_COLOR_YUV, 201, 129, 125 } );
|
||||
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,13 @@ protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
pcStreamPast = std::make_unique<CalypStream>();
|
||||
pcStreamPast->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcStreamPast->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, ClpPixelFormats::YUV420p, 8,
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
pcFramePast = pcStreamPast->getCurrFrame();
|
||||
|
||||
pcStreamFuture = std::make_unique<CalypStream>();
|
||||
pcStreamFuture->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F15_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcStreamFuture->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F15_832x480_yuv420p.yuv" ), 832, 480, ClpPixelFormats::YUV420p, 8,
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
pcFrameFuture = pcStreamFuture->getCurrFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,19 +29,19 @@ AbsoluteFrameDifference::AbsoluteFrameDifference()
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended).
|
||||
// See this example for details on the functions prototype
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to
|
||||
m_iModuleType = ClpModuleType::FrameProcessing; // Apply module to the frames or to
|
||||
// the whole sequence.
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
m_pchModuleName = "AbsoluteFrameDifference"; // Name (no spaces)
|
||||
m_pchModuleLongName = "Absolute Difference"; // Long Name
|
||||
m_pchModuleTooltip = "Measure the absolute difference " // Description
|
||||
"between two images (Y plane), e. g., abs( Y1 - Y2 )";
|
||||
m_uiNumberOfFrames = 2; // Number of frames required
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; // Module requirements
|
||||
// (check
|
||||
// CalypModulesIf.h).
|
||||
m_uiNumberOfFrames = 2; // Number of frames required
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow; // Module requirements
|
||||
// (check
|
||||
// CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_pcFrameDifference = NULL;
|
||||
m_pcFrameDifference = nullptr;
|
||||
}
|
||||
|
||||
bool AbsoluteFrameDifference::create( std::vector<CalypFrame*> apcFrameList )
|
||||
@@ -52,7 +52,7 @@ bool AbsoluteFrameDifference::create( std::vector<CalypFrame*> apcFrameList )
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE_IGNORE_GRAY | CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_RESOLUTION | CalypFrame::MATCH_BITS ) )
|
||||
return false;
|
||||
|
||||
m_pcFrameDifference = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, apcFrameList[0]->getBitsPel() );
|
||||
m_pcFrameDifference = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray, apcFrameList[0]->getBitsPel() );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,12 +77,5 @@ CalypFrame* AbsoluteFrameDifference::process( std::vector<CalypFrame*> apcFrameL
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_pcFrameDifference;
|
||||
}
|
||||
|
||||
void AbsoluteFrameDifference::destroy()
|
||||
{
|
||||
if( m_pcFrameDifference )
|
||||
delete m_pcFrameDifference;
|
||||
m_pcFrameDifference = NULL;
|
||||
return m_pcFrameDifference.get();
|
||||
}
|
||||
@@ -28,19 +28,16 @@
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
class AbsoluteFrameDifference : public CalypModuleIf
|
||||
class AbsoluteFrameDifference : public CalypModuleIf,
|
||||
public CalypModuleInstace<AbsoluteFrameDifference>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( AbsoluteFrameDifference )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrameDifference;
|
||||
std::unique_ptr<CalypFrame> m_pcFrameDifference;
|
||||
|
||||
public:
|
||||
AbsoluteFrameDifference();
|
||||
virtual ~AbsoluteFrameDifference() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __FRAMEDIFFERENCE_H__
|
||||
+6
-10
@@ -13,7 +13,9 @@ SET(Calyp_Mod_SRCS CalypModulesFactory.cpp)
|
||||
#
|
||||
# Modules List
|
||||
#
|
||||
# SET( MODULE_LOCATION "")
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
ADD_MODULE_USE_OPENCV(DummyOpencvModule "DummyOpencvModule" VERSION 3.1.0 MODULES core)
|
||||
ENDIF()
|
||||
|
||||
ADD_MODULE(FilterComponentLuma "FilterComponent")
|
||||
ADD_MODULE(FilterComponentChromaU "FilterComponent")
|
||||
@@ -34,6 +36,8 @@ ADD_MODULE(WeightedPSNR "WeightedPSNR")
|
||||
ADD_MODULE(HEVCIntraPrediction "HEVCIntraPrediction")
|
||||
ADD_MODULE(OptimiseDisplay "OptimiseDisplay")
|
||||
|
||||
ADD_MODULE_USE_OPENCV(ShapeDetection "ShapeDetection" VERSION 3.1.0 MODULES core)
|
||||
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
MeasureOpticalFlowDualTVL1
|
||||
"MeasureOpticalFlowDualTVL1"
|
||||
@@ -85,15 +89,7 @@ ADD_MODULE_USE_OPENCV(
|
||||
imgproc
|
||||
photo
|
||||
)
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
ThreeSixtyDynamicDownsampling
|
||||
"ThreeSixtyDynamicDownsampling"
|
||||
VERSION
|
||||
3.1.0
|
||||
MODULES
|
||||
core
|
||||
imgproc
|
||||
)
|
||||
# ADD_MODULE_USE_OPENCV( ThreeSixtyDynamicDownsampling "ThreeSixtyDynamicDownsampling" VERSION 3.1.0 MODULES core imgproc )
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
ThreeSixtyNxN
|
||||
"ThreeSixtyNxN"
|
||||
|
||||
@@ -25,18 +25,20 @@
|
||||
|
||||
#include "DisparityStereoBM.h"
|
||||
|
||||
#include "lib/CalypFrame.h"
|
||||
|
||||
DisparityStereoBM::DisparityStereoBM()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Stereo";
|
||||
m_pchModuleName = "Disparity-BM";
|
||||
m_pchModuleLongName = "Block macth based disparity";
|
||||
m_pchModuleTooltip = "Measure the disparity between two images using the "
|
||||
"Stereo BM method (OpenCV)";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "block_size", m_uiBlockSize, "Block Size (positive odd number) [9]" );
|
||||
@@ -49,7 +51,7 @@ bool DisparityStereoBM::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
m_pcDisparityFrame =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
if( ( m_uiBlockSize % 2 ) == 0 )
|
||||
{
|
||||
m_uiBlockSize++;
|
||||
|
||||
@@ -29,14 +29,14 @@ DisparityStereoSGBM::DisparityStereoSGBM()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Stereo";
|
||||
m_pchModuleName = "Disparity-SGBM";
|
||||
m_pchModuleLongName = "SGBM based disparity";
|
||||
m_pchModuleTooltip = "Measure the disparity between two images using the "
|
||||
"Stereo SGBM method (OpenCV)";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "block_size", m_uiBlockSize, "Block Size (positive odd number) [3]" )( "HHAlgorithm", m_bUseHH,
|
||||
@@ -51,7 +51,7 @@ bool DisparityStereoSGBM::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
m_pcDisparityFrame =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
if( ( m_uiBlockSize % 2 ) == 0 )
|
||||
{
|
||||
m_uiBlockSize++;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* 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 DummyOpencvModule.cpp
|
||||
*/
|
||||
|
||||
#include "DummyOpencvModule.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
//#include <opencv2/video/video.hpp>
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Ptr;
|
||||
using namespace cv::saliency;
|
||||
|
||||
DummyOpencvModule::DummyOpencvModule()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Dummy";
|
||||
m_pchModuleName = "DummyOpencvModule";
|
||||
m_pchModuleLongName = "Shape detection";
|
||||
m_pchModuleTooltip = "Detect shapes in images";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
m_bConvertToGray = false;
|
||||
|
||||
m_cModuleOptions.addOptions()( "Convert to Gray", m_bConvertToGray, "Measure a binary saliency map [false]" );
|
||||
}
|
||||
|
||||
cv::Mat* DummyOpencvModule::create_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_resultImage = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
|
||||
return m_resultImage.get();
|
||||
}
|
||||
|
||||
Mat* DummyOpencvModule::process_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
apcMatList[0].copyTo( *m_resultImage );
|
||||
return m_resultImage.get();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/* 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 DummyOpencvModule.h
|
||||
* \brief Modules to detect curves shape
|
||||
*/
|
||||
|
||||
#ifndef __DUMMYOPENCVMODULE_H__
|
||||
#define __DUMMYOPENCVMODULE_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
// OpenCV
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/saliency.hpp>
|
||||
|
||||
class DummyOpencvModule : public CalypOpenCVModuleIf,
|
||||
public CalypModuleInstace<DummyOpencvModule>
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Mat> m_resultImage;
|
||||
|
||||
public:
|
||||
DummyOpencvModule();
|
||||
virtual ~DummyOpencvModule() = default;
|
||||
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
};
|
||||
|
||||
#endif // __DUMMYOPENCVMODULE_H__
|
||||
@@ -28,13 +28,13 @@ EightBitsSampling::EightBitsSampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Conversions";
|
||||
m_pchModuleName = "BitsResampling";
|
||||
m_pchModuleLongName = "Re-sampling frame (bpp)";
|
||||
m_pchModuleTooltip = "Re-sampling frame to a different value of bits per pixel";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "num_bits", m_iNumberOfBits, "Number of bits/pixel (8-16) [8]" );
|
||||
|
||||
@@ -30,19 +30,16 @@ FilterComponentModule::FilterComponentModule()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiModuleRequirements = ClpModuleFeature::None;
|
||||
m_pchModuleCategory = "Filtering";
|
||||
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
bool FilterComponentModule::createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel )
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
m_pcFilteredFrame = new CalypFrame( uiWidth, uiHeight, CLP_GRAY, bitsPixel );
|
||||
return true;
|
||||
m_pcFilteredFrame = std::make_unique<CalypFrame>( uiWidth, uiHeight, ClpPixelFormats::Gray, bitsPixel );
|
||||
return m_pcFilteredFrame != nullptr;
|
||||
}
|
||||
|
||||
CalypFrame* FilterComponentModule::filterComponent( CalypFrame* InputFrame, int Component )
|
||||
@@ -51,14 +48,7 @@ CalypFrame* FilterComponentModule::filterComponent( CalypFrame* InputFrame, int
|
||||
ClpPel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
|
||||
memcpy( pppOutputPelYUV[CLP_LUMA][0], pppInputPelYUV[Component][0],
|
||||
m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof( ClpPel ) );
|
||||
return m_pcFilteredFrame;
|
||||
}
|
||||
|
||||
void FilterComponentModule::destroy()
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = NULL;
|
||||
return m_pcFilteredFrame.get();
|
||||
}
|
||||
|
||||
FilterComponentLuma::FilterComponentLuma()
|
||||
|
||||
@@ -31,22 +31,21 @@
|
||||
class FilterComponentModule : public CalypModuleIf
|
||||
{
|
||||
private:
|
||||
CalypFrame* m_pcFilteredFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcFilteredFrame{ nullptr };
|
||||
|
||||
public:
|
||||
FilterComponentModule();
|
||||
virtual ~FilterComponentModule() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList ) = 0;
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList ) = 0;
|
||||
void destroy();
|
||||
|
||||
bool createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel );
|
||||
CalypFrame* filterComponent( CalypFrame* InputFrame, int Component );
|
||||
};
|
||||
|
||||
class FilterComponentLuma : public FilterComponentModule
|
||||
class FilterComponentLuma : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentLuma>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentLuma )
|
||||
public:
|
||||
FilterComponentLuma();
|
||||
virtual ~FilterComponentLuma() {}
|
||||
@@ -54,9 +53,9 @@ public:
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
};
|
||||
|
||||
class FilterComponentChromaU : public FilterComponentModule
|
||||
class FilterComponentChromaU : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentChromaU>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentChromaU )
|
||||
public:
|
||||
FilterComponentChromaU();
|
||||
virtual ~FilterComponentChromaU() {}
|
||||
@@ -64,9 +63,9 @@ public:
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
};
|
||||
|
||||
class FilterComponentChromaV : public FilterComponentModule
|
||||
class FilterComponentChromaV : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentChromaV>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentChromaV )
|
||||
public:
|
||||
FilterComponentChromaV();
|
||||
virtual ~FilterComponentChromaV() {}
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
FrameBinarization::FrameBinarization()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Binarization";
|
||||
m_pchModuleName = "FrameBinarization";
|
||||
m_pchModuleTooltip = "Binarize frame";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" );
|
||||
@@ -45,7 +45,7 @@ FrameBinarization::FrameBinarization()
|
||||
void FrameBinarization::create( CalypFrame* frame )
|
||||
{
|
||||
m_pcBinFrame = NULL;
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), CLP_GRAY, 8 );
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), ClpPixelFormats::Gray, 8 );
|
||||
}
|
||||
|
||||
CalypFrame* FrameBinarization::process( CalypFrame* frame )
|
||||
|
||||
@@ -28,13 +28,13 @@ FrameConcatenation::FrameConcatenation()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Frame Concatenation";
|
||||
m_pchModuleName = "FrameConc";
|
||||
m_pchModuleTooltip = "Concatenate frames side-by-side";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS | CLP_MODULE_REQUIRES_NEW_WINDOW;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options | ClpModuleFeature::NewWindow;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "ShiftHorizontal", m_iShiftHor, "Amount of pixels to shift in horizontal direction" );
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
FrameCrop::FrameCrop()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Crop";
|
||||
m_pchModuleName = "FrameCrop";
|
||||
m_pchModuleTooltip = "Crop a region of a frame";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "xPosition", m_uiXPosition, "X cordinate of the left-top corner of the crop region [0]" ) /**/
|
||||
|
||||
@@ -28,13 +28,13 @@ FrameDifference::FrameDifference()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Measurements";
|
||||
m_pchModuleName = "FrameDifference";
|
||||
m_pchModuleLongName = "Difference";
|
||||
m_pchModuleTooltip = "Measure the difference between two images (Y plane), "
|
||||
"Y1 - Y2, with max absolute diff of 128";
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
m_uiNumberOfFrames = 2;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
|
||||
@@ -28,13 +28,13 @@ FrameMask::FrameMask()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Apply mask";
|
||||
m_pchModuleName = "FrameMask";
|
||||
m_pchModuleTooltip = "Applies a mask to the selected image (first image)";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS | CLP_MODULE_USES_KEYS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow | ClpModuleFeature::Options | ClpModuleFeature::KeysShortcuts;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "MaskWeigth", m_iWeight, "Influence of the mask [60%]" );
|
||||
@@ -61,22 +61,22 @@ bool FrameMask::create( std::vector<CalypFrame*> apcFrameList )
|
||||
m_iWeight = m_iWeight > 100 || m_iWeight < 0 ? 5 : m_iWeight;
|
||||
m_iWeight = m_iWeight > 10 ? m_iWeight / 10 : m_iWeight;
|
||||
|
||||
int iPelFmt = 0;
|
||||
auto iPelFmt = ClpPixelFormats::Invalid;
|
||||
int iColorSpace = apcFrameList[0]->getColorSpace();
|
||||
if( iColorSpace == CLP_COLOR_GRAY )
|
||||
{
|
||||
iColorSpace = apcFrameList[1]->getPelFormat();
|
||||
iColorSpace = apcFrameList[1]->getColorSpace();
|
||||
}
|
||||
switch( iColorSpace )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
iPelFmt = CLP_GRAY;
|
||||
iPelFmt = ClpPixelFormats::Gray;
|
||||
break;
|
||||
case CLP_COLOR_YUV:
|
||||
iPelFmt = CLP_YUV444P;
|
||||
iPelFmt = ClpPixelFormats::YUV444p;
|
||||
break;
|
||||
case CLP_COLOR_RGB:
|
||||
iPelFmt = CLP_RGB24;
|
||||
iPelFmt = ClpPixelFormats::RGB24;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ FrameResampling::FrameResampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleName = "FrameResampling";
|
||||
m_pchModuleLongName = "Frame Resampling (Spatial)";
|
||||
m_pchModuleTooltip = "Resampling frame to an abritary resolution";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "width", m_iWidth, "Width of the crop region [-1]" ) /**/
|
||||
|
||||
@@ -28,13 +28,13 @@ FrameRotate::FrameRotate()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Rotation";
|
||||
m_pchModuleName = "FrameRotate";
|
||||
m_pchModuleTooltip = "Rotates frame";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Angle", m_iAngle, "Angle to rotate (0, 90, 180, 270)" );
|
||||
|
||||
@@ -30,13 +30,13 @@ FrameShift::FrameShift()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleLongName = "Pixel Shift";
|
||||
m_pchModuleName = "FrameShift";
|
||||
m_pchModuleTooltip = "Shift frame horizontal and vertical";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS | CLP_MODULE_USES_KEYS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options | ClpModuleFeature::KeysShortcuts;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "ShiftHorizontal", m_iShiftHor, "Amount of pixels to shift in horizontal direction" ) /**/
|
||||
|
||||
@@ -30,16 +30,16 @@ HEVCIntraPrediction::HEVCIntraPrediction()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "HEVC";
|
||||
m_pchModuleLongName = "Intra Prediction";
|
||||
m_pchModuleName = "HEVCIntraPrediction";
|
||||
m_pchModuleTooltip = "Apply intra-frame prediction";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW |
|
||||
CLP_MODULE_USES_KEYS |
|
||||
CLP_MODULES_HAS_INFO |
|
||||
CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow |
|
||||
ClpModuleFeature::KeysShortcuts |
|
||||
ClpModuleFeature::HasInfo |
|
||||
ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "mode", m_uiMode, "Intra mode (26-34) [26]" ) /**/
|
||||
@@ -61,7 +61,7 @@ bool HEVCIntraPrediction::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
m_pcPredBlock = NULL;
|
||||
m_pcPredBlock = new CalypFrame( m_iBlockSize * 2 + 1, m_iBlockSize * 2 + 1, CLP_GRAY, apcFrameList[0]->getBitsPel() );
|
||||
m_pcPredBlock = new CalypFrame( m_iBlockSize * 2 + 1, m_iBlockSize * 2 + 1, ClpPixelFormats::Gray, apcFrameList[0]->getBitsPel() );
|
||||
|
||||
m_referenceMem.resize( m_iBlockSize * 4 );
|
||||
|
||||
|
||||
@@ -29,15 +29,15 @@ InterFrameVariance::InterFrameVariance()
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended).
|
||||
// See this example for details on the functions prototype
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to
|
||||
// the whole sequence.
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
m_pchModuleName = "InterFrameVariance"; // Name
|
||||
m_iModuleType = ClpModuleType::FrameProcessing; // Apply module to the frames or to
|
||||
// the whole sequence.
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
m_pchModuleName = "InterFrameVariance"; // Name
|
||||
m_pchModuleLongName = "Variance across frames";
|
||||
m_pchModuleTooltip = "Measure the variance across several frames";
|
||||
m_uiNumberOfFrames = 2; // Number of Frames required (This module
|
||||
// allows a variable number of inputs)
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULES_VARIABLE_NUM_FRAMES;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow | ClpModuleFeature::VariableNumOfFrames;
|
||||
// Several requirements should be "or" between each others.
|
||||
m_pcFrameVariance = NULL;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ bool InterFrameVariance::create( std::vector<CalypFrame*> apcFrameList )
|
||||
return false;
|
||||
|
||||
m_pcFrameVariance =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, 8 );
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray, 8 );
|
||||
|
||||
m_pVariance = CalypPlane<double>{ apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight() };
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
LumaAverage::LumaAverage()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = CLP_FRAME_MEASUREMENT_MODULE; // Apply module to the frames or to
|
||||
m_iModuleType = ClpModuleType::FrameMeasurement; // Apply module to the frames or to
|
||||
// the whole sequence.
|
||||
// Currently only support for frame
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
@@ -37,7 +37,7 @@ LumaAverage::LumaAverage()
|
||||
m_uiNumberOfFrames = 1; // Number of Frames required
|
||||
// (ONE_FRAME, TWO_FRAMES,
|
||||
// THREE_FRAMES)
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; // Module requirements
|
||||
m_uiModuleRequirements = ClpModuleFeature::None; // Module requirements
|
||||
// (check
|
||||
// CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
|
||||
@@ -38,13 +38,13 @@ MeasureOpticalFlowDualTVL1::MeasureOpticalFlowDualTVL1()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Measurements";
|
||||
m_pchModuleName = "MeasureOpticalFlowDualTVL1";
|
||||
m_pchModuleLongName = "Optical flow based on DualTVL1";
|
||||
m_pchModuleTooltip = "Measure optical flow";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Show reconstruction", m_bShowReconstruction, "Show reconstructed frame instead of MVs [false]" );
|
||||
@@ -69,7 +69,7 @@ bool MeasureOpticalFlowDualTVL1::create( std::vector<CalypFrame*> apcFrameList )
|
||||
#else
|
||||
m_cTvl1 = cv::createOptFlow_DualTVL1();
|
||||
#endif
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ OpticalFlowModule::OpticalFlowModule()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "OpticalFlow";
|
||||
m_uiNumberOfFrames = 2;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::NewWindow | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Show reconstruction", m_bShowReconstruction, "Show reconstructed frame instead of MVs [false]" );
|
||||
@@ -62,7 +62,7 @@ bool OpticalFlowModule::commonCreate( std::vector<CalypFrame*> apcFrameList )
|
||||
return false;
|
||||
|
||||
m_iStep = 16;
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,18 +32,18 @@ OptimiseDisplay::OptimiseDisplay()
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended).
|
||||
// See this example for details on the functions prototype
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to
|
||||
m_iModuleType = ClpModuleType::FrameProcessing; // Apply module to the frames or to
|
||||
// the whole sequence.
|
||||
m_pchModuleCategory = "Conversions"; // Category (sub-menu)
|
||||
m_pchModuleName = "OptimiseDisplay"; // Name (no spaces)
|
||||
m_pchModuleLongName = "Optimise Display"; // Long Name
|
||||
m_pchModuleTooltip = "Scales the display of images " // Description
|
||||
"for better visualization of small differences";
|
||||
m_uiNumberOfFrames = 1; // Number of frames required
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING; // Module requirements
|
||||
// (check
|
||||
// CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_uiNumberOfFrames = 1; // Number of frames required
|
||||
m_uiModuleRequirements = ClpModuleFeature::None; // Module requirements
|
||||
// (check
|
||||
// CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_pcOptimisedFrame = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ SaliencyBasedFiltering::SaliencyBasedFiltering()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "SaliencyBasedFiltering";
|
||||
m_pchModuleLongName = "Saliency Based Filtering";
|
||||
m_pchModuleTooltip = "Image filter based on a map";
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiModuleRequirements = ClpModuleFeature::None;
|
||||
m_uiNumberOfFrames = 2;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
@@ -53,10 +53,6 @@ bool SaliencyBasedFiltering::create( std::vector<CalypFrame*> apcFrameList )
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_RESOLUTION ) )
|
||||
return false;
|
||||
}
|
||||
if( apcFrameList[1]->getNumberChannels() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pcProcessedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
|
||||
@@ -36,17 +36,13 @@ SaliencyDetectionModule::SaliencyDetectionModule()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Saliency";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow;
|
||||
m_bConvertToGray = true;
|
||||
}
|
||||
|
||||
void SaliencyDetectionModule::destroy_using_opencv()
|
||||
{
|
||||
}
|
||||
|
||||
SaliencyDetectionSpectral::SaliencyDetectionSpectral()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -54,7 +50,7 @@ SaliencyDetectionSpectral::SaliencyDetectionSpectral()
|
||||
m_pchModuleLongName = "Spectral residual";
|
||||
m_pchModuleTooltip = "Measure saliency using spectral residual method";
|
||||
|
||||
m_uiModuleRequirements = m_uiModuleRequirements | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = m_uiModuleRequirements | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Binary map", m_bBinaryMap, "Measure a binary saliency map [false]" );
|
||||
|
||||
@@ -51,7 +51,6 @@ protected:
|
||||
public:
|
||||
SaliencyDetectionModule();
|
||||
virtual ~SaliencyDetectionModule() {}
|
||||
void destroy_using_opencv();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -66,11 +65,11 @@ public:
|
||||
* approach. In Computer Vision and Pattern Recognition, 2007.
|
||||
* CVPR'07. IEEE Conference on, pages 1–8. IEEE, 2007.
|
||||
*/
|
||||
class SaliencyDetectionSpectral : public SaliencyDetectionModule
|
||||
class SaliencyDetectionSpectral : public SaliencyDetectionModule,
|
||||
public CalypModuleInstace<SaliencyDetectionSpectral>
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionSpectral )
|
||||
private:
|
||||
bool m_bBinaryMap;
|
||||
|
||||
@@ -91,11 +90,11 @@ public:
|
||||
* platform and novel features derived from a visual saliency mechanism.
|
||||
* In Image and Vision Computing, Vol. 28 Issue 3, pages 391–402. Elsevier, 2010.
|
||||
*/
|
||||
class SaliencyDetectionFineGrained : public SaliencyDetectionModule
|
||||
class SaliencyDetectionFineGrained : public SaliencyDetectionModule,
|
||||
public CalypModuleInstace<SaliencyDetectionFineGrained>
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionFineGrained )
|
||||
public:
|
||||
SaliencyDetectionFineGrained();
|
||||
virtual ~SaliencyDetectionFineGrained() {}
|
||||
@@ -110,11 +109,11 @@ public:
|
||||
* Wang and P. Dudek “A Fast Self-tuning Background Subtraction Algorithm”,
|
||||
* in proc of IEEE Workshop on Change Detection, 2014
|
||||
*/
|
||||
class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule
|
||||
class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule,
|
||||
public CalypModuleInstace<SaliencyDetectionBinWangApr2014>
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
REGISTER_CLASS_FACTORY( SaliencyDetectionBinWangApr2014 )
|
||||
public:
|
||||
SaliencyDetectionBinWangApr2014();
|
||||
virtual ~SaliencyDetectionBinWangApr2014() {}
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
SetChromaHalfScale::SetChromaHalfScale()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Conversions";
|
||||
m_pchModuleName = "SetChromaHalfScale";
|
||||
m_pchModuleLongName = "Half scale chroma";
|
||||
m_pchModuleTooltip = "Copy frame only keeping luma component";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiModuleRequirements = ClpModuleFeature::None;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
}
|
||||
|
||||
@@ -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 ShapeDetection.cpp
|
||||
*/
|
||||
|
||||
#include "ShapeDetection.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Ptr;
|
||||
|
||||
ShapeDetection::ShapeDetection()
|
||||
: m_rng( 12345 )
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow;
|
||||
m_bConvertToGray = false;
|
||||
|
||||
/* Module Definition */
|
||||
m_pchModuleName = "ShapeDetection";
|
||||
m_pchModuleLongName = "Shape detection";
|
||||
m_pchModuleTooltip = "Detect shapes in images";
|
||||
}
|
||||
|
||||
cv::Mat* ShapeDetection::create_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
m_resultImage = std::make_unique<Mat>( apcMatList[0].rows, apcMatList[0].cols, CV_8UC1 );
|
||||
return m_resultImage.get();
|
||||
}
|
||||
|
||||
Mat* ShapeDetection::process_using_opencv( const std::vector<Mat>& apcMatList )
|
||||
{
|
||||
Mat canny_output;
|
||||
cv::Canny( apcMatList[0], canny_output, 30, 100 );
|
||||
|
||||
std::vector<std::vector<cv::Point> > contours;
|
||||
findContours( canny_output, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE );
|
||||
|
||||
std::vector<std::vector<cv::Point> > hull( contours.size() );
|
||||
for( size_t i = 0; i < contours.size(); i++ )
|
||||
{
|
||||
cv::convexHull( contours[i], hull[i] );
|
||||
}
|
||||
for( size_t i = 0; i < contours.size(); i++ )
|
||||
{
|
||||
cv::Scalar color = cv::Scalar( m_rng.uniform( 0, 256 ), m_rng.uniform( 0, 256 ), m_rng.uniform( 0, 256 ) );
|
||||
cv::drawContours( *m_resultImage, contours, (int)i, color );
|
||||
cv::drawContours( *m_resultImage, hull, (int)i, color );
|
||||
}
|
||||
|
||||
return m_resultImage.get();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/* 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 ShapeDetection.h
|
||||
* \brief Modules to detect curves shape
|
||||
*/
|
||||
|
||||
#ifndef __SHAPEDETECTION_H__
|
||||
#define __SHAPEDETECTION_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
// OpenCV
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
class ShapeDetection : public CalypOpenCVModuleIf,
|
||||
public CalypModuleInstace<ShapeDetection>
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
private:
|
||||
bool m_bBinaryMap;
|
||||
std::unique_ptr<Mat> m_resultImage;
|
||||
cv::RNG m_rng;
|
||||
|
||||
public:
|
||||
ShapeDetection();
|
||||
virtual ~ShapeDetection() = default;
|
||||
Mat* create_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
Mat* process_using_opencv( const std::vector<Mat>& apcMatList ) override;
|
||||
};
|
||||
|
||||
#endif // __SHAPEDETECTION_H__
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/photo.hpp>
|
||||
|
||||
//using cv::InputArray;
|
||||
//using cv::OutputArray;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
using cv::Size;
|
||||
@@ -39,16 +37,16 @@ ThreeSixtyDownsampling::ThreeSixtyDownsampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleName = "ThreeSixtyDownsampling";
|
||||
m_pchModuleLongName = "Adaptive Latitude Downsampling";
|
||||
m_pchModuleTooltip = "Adaptive Latitude Downsampling";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
|
||||
CLP_MODULE_REQUIRES_OPTIONS |
|
||||
CLP_MODULES_HAS_INFO |
|
||||
CLP_MODULE_USES_KEYS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying |
|
||||
ClpModuleFeature::Options |
|
||||
ClpModuleFeature::HasInfo |
|
||||
ClpModuleFeature::KeysShortcuts;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Downsampling", m_uiDownsampling, "ERP to NxN (0 for up, 1 for down and 2 for recon) [1]" ) /**/
|
||||
@@ -201,8 +199,8 @@ bool ThreeSixtyDownsampling::createDownsamplingMask( CalypFrame* pcInputFrame )
|
||||
if( m_iWidth == -1 || m_iHeight == -1 ) // output dimensions are needed
|
||||
return false;
|
||||
|
||||
//m_pcDownsampled = new CalypFrame( m_iWidth, m_uiHeight, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
m_pcDownsampled = new CalypFrame( m_iWidth, m_iHeight, CalypFrame::findPixelFormat( "GRAY" ), pcInputFrame->getBitsPel() );
|
||||
// m_pcDownsampled = new CalypFrame( m_iWidth, m_uiHeight, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
m_pcDownsampled = new CalypFrame( m_iWidth, m_iHeight, ClpPixelFormats::Gray, pcInputFrame->getBitsPel() );
|
||||
|
||||
m_isOdd = !( m_iHeight % 2 );
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
@@ -422,7 +420,7 @@ bool ThreeSixtyDownsampling::createDownsamplingMask( CalypFrame* pcInputFrame )
|
||||
cv::flip( auxPointMap, auxPointMap, -1 );
|
||||
cv::flip( auxMask, auxMask, -1 );
|
||||
|
||||
//cv::imwrite( "auxMask.png", auxMask );
|
||||
// cv::imwrite( "auxMask.png", auxMask );
|
||||
auxPointMap.copyTo( topTriangleReshape, auxMask );
|
||||
|
||||
long shape_area = std::abs( r34_size.x ) * std::abs( r34_size.y );
|
||||
@@ -493,7 +491,7 @@ bool ThreeSixtyDownsampling::createDownsamplingMask( CalypFrame* pcInputFrame )
|
||||
else if( m_iRearrange == 4 )
|
||||
{
|
||||
intermediateReshapePoints = Mat_<Point>( 10 * p0.y, initialReshapePoints.cols, Point( -1, -1 ) );
|
||||
//unsigned hor_pad = 0;
|
||||
// unsigned hor_pad = 0;
|
||||
unsigned ver_pad = 0;
|
||||
if( m_uiY0 == 40 )
|
||||
{
|
||||
@@ -713,7 +711,7 @@ void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
}
|
||||
}
|
||||
}
|
||||
//m_pcResultedFrame->copyFrom( m_pcDownsampled );
|
||||
// m_pcResultedFrame->copyFrom( m_pcDownsampled );
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
@@ -37,13 +37,13 @@ ThreeSixtyDynamicDownsampling::ThreeSixtyDynamicDownsampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Dynamic Downsampling";
|
||||
m_pchModuleName = "ThreeSixtyDynamicDownsampling";
|
||||
m_pchModuleTooltip = "Dynamic downsampling of 360 videos";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "CodingFaceWidth", m_uiFaceWidth, "Coding Face Width [same as input]" ) /**/
|
||||
|
||||
@@ -37,15 +37,15 @@ ThreeSixtyFaceConcatenation::ThreeSixtyFaceConcatenation()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Face Concatenation";
|
||||
m_pchModuleName = "ThreeSixtyFaceConcatenation";
|
||||
m_pchModuleTooltip = "Concatenate 360 video faces";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
|
||||
CLP_MODULE_REQUIRES_OPTIONS |
|
||||
CLP_MODULES_VARIABLE_NUM_FRAMES;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying |
|
||||
ClpModuleFeature::Options |
|
||||
ClpModuleFeature::VariableNumOfFrames;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "projection", m_uiProjectionType, "Projection [1] \n 1: Cubemap (6 faces)" ) /**/
|
||||
|
||||
@@ -37,13 +37,13 @@ ThreeSixtyFaceExtraction::ThreeSixtyFaceExtraction()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Face Extration";
|
||||
m_pchModuleName = "ThreeSixtyFaceExtration";
|
||||
m_pchModuleTooltip = "Extract a 360 video face";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "faceNum", m_uiFaceNum, "360 proejction face to be outputed [0]" ) /**/
|
||||
|
||||
@@ -37,14 +37,14 @@ ThreeSixtyNxN::ThreeSixtyNxN()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleName = "ThreeSixtyNxN";
|
||||
m_pchModuleLongName = "ERP to NxN";
|
||||
m_pchModuleTooltip = "Downsampling ERP to NxN";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
|
||||
CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying |
|
||||
ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Downsampling", m_uiDownsampling, "ERP to NxN (0 for up, 1 for down and 2 for recon) [1]" ) /**/
|
||||
|
||||
@@ -28,13 +28,13 @@ ThreeSixtySpatialtoTemporal::ThreeSixtySpatialtoTemporal()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_3;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Spatial to Temporal";
|
||||
m_pchModuleName = "ThreeSixtySpatialtoTemporal";
|
||||
m_pchModuleTooltip = "Convert 360 video from Cube Map Projection to temporal frames";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::Options;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "spa2temp", m_uiSpatial2Temporal, "Convert from spatial to temporal [1]" ) /**/
|
||||
|
||||
@@ -30,12 +30,12 @@ WeightedPSNR::WeightedPSNR()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_MEASUREMENT_MODULE;
|
||||
m_iModuleType = ClpModuleType::FrameMeasurement;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "WeightedPSNR";
|
||||
m_pchModuleLongName = "Weighted PSNR";
|
||||
m_pchModuleTooltip = "Measure the weighted PSNR between two images";
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
m_uiNumberOfFrames = 3;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
#
|
||||
# CMakeLists for playuver lib tests component
|
||||
#
|
||||
OPTION(BUILD_MODULES_TESTS "Build unit tests of modules" ON)
|
||||
IF(BUILD_MODULES_TESTS)
|
||||
|
||||
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
|
||||
FETCHCONTENT_MAKEAVAILABLE(googletest Catch2)
|
||||
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
|
||||
|
||||
FOREACH(module ${MODULES_LIST_NAME})
|
||||
ADD_EXECUTABLE(TestModuleCreate_${module} TestModuleCreate.cpp)
|
||||
TARGET_COMPILE_DEFINITIONS(TestModuleCreate_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
|
||||
TARGET_LINK_LIBRARIES(TestModuleCreate_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
|
||||
ADD_TEST(TestModuleCreate_${module} TestModuleCreate_${module})
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
ADD_EXECUTABLE(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames.cpp)
|
||||
TARGET_COMPILE_DEFINITIONS(TestModuleProcessNumberOfFrames_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
|
||||
TARGET_LINK_LIBRARIES(TestModuleProcessNumberOfFrames_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
|
||||
ADD_TEST(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames_${module})
|
||||
FOREACH(module ${MODULES_LIST_NAME})
|
||||
ADD_EXECUTABLE(TestModuleCreate_${module} TestModuleCreate.cpp)
|
||||
TARGET_COMPILE_DEFINITIONS(TestModuleCreate_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
|
||||
TARGET_LINK_LIBRARIES(TestModuleCreate_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
|
||||
ADD_TEST(TestModuleCreate_${module} TestModuleCreate_${module})
|
||||
|
||||
ENDFOREACH(module ${MODULES_LIST_NAME})
|
||||
ADD_EXECUTABLE(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames.cpp)
|
||||
TARGET_COMPILE_DEFINITIONS(TestModuleProcessNumberOfFrames_${module} PUBLIC -DCALYP_TEST_MODULE_NAME=\"${module}\")
|
||||
TARGET_LINK_LIBRARIES(TestModuleProcessNumberOfFrames_${module} ${PROJECT_LIBRARY} CalypModules gtest gtest_main)
|
||||
ADD_TEST(TestModuleProcessNumberOfFrames_${module} TestModuleProcessNumberOfFrames_${module})
|
||||
|
||||
ENDFOREACH(module ${MODULES_LIST_NAME})
|
||||
ENDIF()
|
||||
@@ -39,8 +39,8 @@ protected:
|
||||
std::string moduleName = CALYP_TEST_MODULE_NAME;
|
||||
|
||||
pcStream = std::make_unique<CalypStream>();
|
||||
pcStream->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcStream->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, ClpPixelFormats::YUV420p, 8,
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
}
|
||||
|
||||
// Per-test-case tear-down.
|
||||
@@ -89,7 +89,7 @@ TEST_F( TestModuleCreate, FIND_MODULE )
|
||||
TEST_F( TestModuleCreate, CREATE_OK )
|
||||
{
|
||||
bool moduleRequireOptions = false;
|
||||
if( pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_OPTIONS )
|
||||
if( pcModule->m_uiModuleRequirements & ClpModuleFeature::Options )
|
||||
{
|
||||
moduleRequireOptions = true;
|
||||
}
|
||||
@@ -113,6 +113,7 @@ TEST_F( TestModuleCreate, CREATE_OK )
|
||||
moduleCreated = true;
|
||||
}
|
||||
EXPECT_EQ( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
|
||||
TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE )
|
||||
@@ -129,6 +130,7 @@ TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +146,7 @@ TEST_F( TestModuleCreate, CREATE_FAIL_PLUS_ONE )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,5 +162,6 @@ TEST_F( TestModuleCreate, CREATE_FAIL_NULL_FRAME )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ protected:
|
||||
std::string moduleName = CALYP_TEST_MODULE_NAME;
|
||||
|
||||
pcStream = std::make_unique<CalypStream>();
|
||||
pcStream->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcStream->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, ClpPixelFormats::YUV420p, 8,
|
||||
CLP_BIG_ENDIAN, 1, CalypStream::Type::Input );
|
||||
|
||||
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
|
||||
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
|
||||
|
||||
+14
-14
@@ -68,7 +68,7 @@ int CalypTools::openInputs()
|
||||
std::string resolutionString( "" );
|
||||
std::string fmtString( "yuv420p" );
|
||||
unsigned int uiBitsPerPixel = 8;
|
||||
unsigned int uiEndianness = 0;
|
||||
int uiEndianness = 0;
|
||||
bool hasNegativeValues = false;
|
||||
|
||||
CalypStream* pcStream;
|
||||
@@ -104,7 +104,7 @@ int CalypTools::openInputs()
|
||||
pcStream = new CalypStream;
|
||||
try
|
||||
{
|
||||
if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitsPerPixel, uiEndianness, hasNegativeValues, 1, true ) )
|
||||
if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitsPerPixel, uiEndianness, hasNegativeValues, 1, CalypStream::Type::Input ) )
|
||||
{
|
||||
log( CLP_LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() );
|
||||
return -1;
|
||||
@@ -242,7 +242,7 @@ int CalypTools::Open( int argc, char* argv[] )
|
||||
{
|
||||
pcOutputStream->open( m_pcOutputFileNames[0], pcInputFrame->getWidth(), pcInputFrame->getHeight(),
|
||||
pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel(), m_uiOutEndianness, 1,
|
||||
false );
|
||||
CalypStream::Type::Output );
|
||||
log( CLP_LOG_INFO, "Output stream from rate-reduction!\n" );
|
||||
reportStreamInfo( pcOutputStream, "Output " );
|
||||
}
|
||||
@@ -319,7 +319,7 @@ int CalypTools::Open( int argc, char* argv[] )
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( m_pcCurrModuleIf->m_uiModuleRequirements & CLP_MODULES_VARIABLE_NUM_FRAMES )
|
||||
if( m_pcCurrModuleIf->m_uiModuleRequirements & ClpModuleFeature::VariableNumOfFrames )
|
||||
{
|
||||
m_pcCurrModuleIf->m_uiNumberOfFrames = m_apcInputStreams.size();
|
||||
}
|
||||
@@ -356,7 +356,7 @@ int CalypTools::Open( int argc, char* argv[] )
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
// Check outputs
|
||||
std::vector<std::string> outputFileNames;
|
||||
@@ -383,7 +383,7 @@ int CalypTools::Open( int argc, char* argv[] )
|
||||
try
|
||||
{
|
||||
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(),
|
||||
pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), m_uiOutEndianness, 1, false );
|
||||
pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), m_uiOutEndianness, 1, CalypStream::Type::Output );
|
||||
log( CLP_LOG_INFO, "Output stream from module!\n" );
|
||||
reportStreamInfo( pcModStream, "Module Output " );
|
||||
}
|
||||
@@ -570,11 +570,11 @@ int CalypTools::QualityOperation()
|
||||
return 0;
|
||||
}
|
||||
|
||||
//CalypFrame* CalypTools::applyFrameModule()
|
||||
// CalypFrame* CalypTools::applyFrameModule()
|
||||
//{
|
||||
// CalypFrame* pcProcessedFrame = NULL;
|
||||
// if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
// {
|
||||
// CalypFrame* pcProcessedFrame = NULL;
|
||||
// if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
// {
|
||||
|
||||
// }
|
||||
// return pcProcessedFrame;
|
||||
@@ -621,7 +621,7 @@ int CalypTools::ModuleOperation()
|
||||
{
|
||||
log( CLP_LOG_INFO, " Processing frame %3d\n", frame );
|
||||
bool bReadFrame = true;
|
||||
if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
if( m_pcCurrModuleIf->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
pcProcessedFrame = m_pcCurrModuleIf->process( apcFrameList );
|
||||
@@ -633,7 +633,7 @@ int CalypTools::ModuleOperation()
|
||||
m_apcOutputStreams[0]->writeFrame( *pcProcessedFrame );
|
||||
}
|
||||
}
|
||||
else if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
else if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
{
|
||||
if( m_pcCurrModuleIf->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
dMeasurementResult = m_pcCurrModuleIf->measure( apcFrameList );
|
||||
@@ -660,7 +660,7 @@ int CalypTools::ModuleOperation()
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
{
|
||||
pcProcessedFrame = m_pcCurrModuleIf->process( apcFrameList );
|
||||
if( !pcProcessedFrame )
|
||||
@@ -670,7 +670,7 @@ int CalypTools::ModuleOperation()
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pcCurrModuleIf->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
if( m_pcCurrModuleIf->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
{
|
||||
log( CLP_LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "CalypToolsCmdParser.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
@@ -39,7 +40,14 @@ CalypToolsCmdParser::CalypToolsCmdParser()
|
||||
m_bQuiet = false;
|
||||
m_iFrames = -1;
|
||||
|
||||
m_cOptions.addDefaultOptions();
|
||||
m_cOptions.addOptions() /**/
|
||||
( "help", "produce help message" ) /**/
|
||||
( "version", "show version and exit" ) /**/
|
||||
( "pel_fmts", "list pixel formats" ) /**/
|
||||
( "quality_metrics", "list supported quality metrics" ) /**/
|
||||
( "module_list", "list supported modules" ) /**/
|
||||
( "module_list_full", "detailed list supported modules" );
|
||||
;
|
||||
}
|
||||
|
||||
CalypToolsCmdParser::~CalypToolsCmdParser() {}
|
||||
@@ -166,10 +174,13 @@ void CalypToolsCmdParser::listModules()
|
||||
printf( " %-43s", ModuleNameString.c_str() );
|
||||
switch( pcCurrModuleIf->m_iModuleType )
|
||||
{
|
||||
case CLP_FRAME_PROCESSING_MODULE:
|
||||
case ClpModuleType::Invalid:
|
||||
assert( false );
|
||||
break;
|
||||
case ClpModuleType::FrameProcessing:
|
||||
printf( " Processing " );
|
||||
break;
|
||||
case CLP_FRAME_MEASUREMENT_MODULE:
|
||||
case ClpModuleType::FrameMeasurement:
|
||||
printf( " Measurement " );
|
||||
break;
|
||||
}
|
||||
|
||||
+6
-3
@@ -23,6 +23,8 @@
|
||||
* \brief main file
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "CalypTools.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
@@ -37,19 +39,20 @@ int main( int argc, char* argv[] )
|
||||
}
|
||||
if( iRet < 0 )
|
||||
{
|
||||
printf( "Exiting with error \n" );
|
||||
std::cout << "Exiting with error" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( CalypToolsApp.Process() < 0 )
|
||||
{
|
||||
printf( "Exiting with error \n" );
|
||||
std::cout << "Exiting with error" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( CalypToolsApp.Close() < 0 )
|
||||
{
|
||||
printf( "Exiting with error \n" );
|
||||
std::cout << "Exiting with error" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user