Compare commits
11
Commits
b7ad00a4c5
...
26f3dc7612
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26f3dc7612 | ||
|
|
6ce220be82 | ||
|
|
cc84c42fd4 | ||
|
|
8d2a9e6100 | ||
|
|
c05aa73e86 | ||
|
|
ddc9f40329 | ||
|
|
e87049dccf | ||
|
|
1c1afa7bfc | ||
|
|
366d69b5c9 | ||
|
|
26a718a06a | ||
|
|
3b31453221 |
No files matched your search
@@ -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.
|
||||
@@ -35,3 +35,29 @@ jobs:
|
||||
# Build your program with the given configuration
|
||||
run: 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
|
||||
lfs: true
|
||||
|
||||
- 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 -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
|
||||
+12
-5
@@ -598,10 +598,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 +618,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 );
|
||||
|
||||
@@ -200,15 +200,20 @@ 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, true, iPass == 1 );
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -79,6 +79,8 @@ 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 );
|
||||
void loadAll();
|
||||
|
||||
@@ -141,6 +141,10 @@ public:
|
||||
CalypPixel operator-( const CalypPixel& ) 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)
|
||||
@@ -150,6 +154,8 @@ public:
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace ) const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
|
||||
|
||||
/**
|
||||
* \class CalypPlane
|
||||
* \ingroup CalypLibGrp CalypPlaneGrp
|
||||
|
||||
@@ -141,6 +141,25 @@ 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 )
|
||||
{
|
||||
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] << ")";
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
|
||||
{
|
||||
if( m_colorSpace == eOutputSpace )
|
||||
|
||||
+141
-118
@@ -48,7 +48,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()
|
||||
{
|
||||
@@ -192,7 +192,6 @@ public:
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
iCurrFrameNum = -1;
|
||||
cFilename = "";
|
||||
}
|
||||
|
||||
~CalypStreamPrivate()
|
||||
@@ -200,6 +199,109 @@ public:
|
||||
close();
|
||||
}
|
||||
|
||||
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 forceRaw )
|
||||
{
|
||||
if( isInit )
|
||||
{
|
||||
close();
|
||||
}
|
||||
isInit = false;
|
||||
isInput = bInput;
|
||||
|
||||
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 < 0 )
|
||||
{
|
||||
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,6 +313,30 @@ 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 );
|
||||
@@ -291,114 +417,30 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
|
||||
break;
|
||||
}
|
||||
}
|
||||
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, bInput, false );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
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, bInput, false );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
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, bInput, false );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormating()
|
||||
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 forceRaw )
|
||||
{
|
||||
if( d->handler != nullptr )
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, bInput, forceRaw );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormatConfiguration()
|
||||
{
|
||||
if( d->handler == nullptr )
|
||||
return false;
|
||||
return d->handler->m_bSupportsFormat;
|
||||
}
|
||||
@@ -643,29 +685,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 );
|
||||
|
||||
+32
-5
@@ -29,7 +29,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypFrame.h"
|
||||
|
||||
class CalypStreamHandlerIf;
|
||||
@@ -83,14 +82,42 @@ 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 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 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 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,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
int input_format,
|
||||
unsigned int bitsPel,
|
||||
int endianness,
|
||||
unsigned int frame_rate,
|
||||
bool bInput,
|
||||
bool forceRaw );
|
||||
|
||||
bool supportsFormating();
|
||||
bool supportsFormatConfiguration();
|
||||
bool reload();
|
||||
|
||||
bool isNative() const;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
#define INI_REGIST_CALYP_SUPPORTED_FMT \
|
||||
@@ -102,7 +103,6 @@ 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 };
|
||||
|
||||
+12
-12
@@ -60,12 +60,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 +82,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 );
|
||||
@@ -106,7 +106,7 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "BGR" );
|
||||
|
||||
m_uiTotalNumberFrames = 1;
|
||||
if( pcVideoCapture )
|
||||
if( m_pcVideoCapture )
|
||||
{
|
||||
m_uiTotalNumberFrames = 2;
|
||||
}
|
||||
@@ -117,11 +117,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 +139,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__
|
||||
@@ -34,6 +34,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
# CMakeLists for Calyp lis tests using catch2
|
||||
#
|
||||
|
||||
# ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
SET(Calyp_Lib_Catch2_Tests_SRCS
|
||||
CalypLibTests.cpp
|
||||
CalypStreamTests.cpp
|
||||
CalypFrameTests.cpp
|
||||
)
|
||||
|
||||
SET(Calyp_Lib_Catch2_Tests_SRCS 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"
|
||||
@@ -32,10 +31,10 @@ 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 );
|
||||
|
||||
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() == CLP_YUV420P );
|
||||
CHECK( testFrame.getBitsPel() == 8 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 10 bits in YUV420 format", "CalypFrame" )
|
||||
@@ -43,10 +42,10 @@ 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 );
|
||||
|
||||
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() == CLP_YUV420P );
|
||||
CHECK( testFrame.getBitsPel() == 10 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 16 bits in YUV420 format", "CalypFrame" )
|
||||
@@ -54,8 +53,8 @@ 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 );
|
||||
|
||||
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() == CLP_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,121 @@
|
||||
/* 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 <variant>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
constexpr int kFrameRate{ 30 };
|
||||
constexpr bool kIsInput{ true };
|
||||
|
||||
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{ CalypPixelFormats::CLP_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, true );
|
||||
|
||||
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 .batatas file as RAW video", "CalypStream" )
|
||||
{
|
||||
constexpr int kWidth{ 352 };
|
||||
constexpr int kHeight{ 288 };
|
||||
constexpr auto kInputFormat{ CalypPixelFormats::CLP_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, kIsInput, force_raw );
|
||||
}
|
||||
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, kIsInput, force_raw );
|
||||
|
||||
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 } );
|
||||
}
|
||||
}
|
||||
@@ -85,15 +85,15 @@ 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"
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in new issue
Block a user