diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index b00287d..b502506 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -387,15 +387,6 @@ PlaYUVerFrame* InputStream::getCurrFrame() return m_pcCurrFrame; } -#ifdef USE_OPENCV -cv::Mat InputStream::getFrameCvMat() -{ - cv::Mat cvMat( m_uiHeight, m_uiWidth, CV_8UC3 ); - - return cvMat; -} -#endif - Void InputStream::seekInput( UInt64 new_frame_num ) { if( !m_pFile ) diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index b039950..917e7c2 100755 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -37,8 +37,8 @@ PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format ) PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other ) { - init( other->getWidth(), other->getHeight(), other->getPelFormat() ); - copyFrom(other); + init( other->getWidth(), other->getHeight(), other->getPelFormat() ); + copyFrom( other ); } PlaYUVerFrame::~PlaYUVerFrame() @@ -494,8 +494,36 @@ Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, Int color_space ) #ifdef USE_OPENCV cv::Mat PlaYUVerFrame::getCvMat() { - return cv::Mat(); + Int cvType = CV_8UC3; + switch( m_iPixelFormat ) + { + case YUV420p: + case YUV444p: + case YUV422p: + case YUYV422: + cvType = CV_8UC3; + break; + case GRAY: + cvType = CV_8UC1; + break; + case RGB8: + cvType = CV_8UC3; + break; + default: + break; + } + cv::Mat opencvFrame( m_uiHeight, m_uiWidth, cvType ); + if( m_iPixelFormat != GRAY ) + { + FrametoRGB8(); + memcpy( opencvFrame.data, m_pcRGBPelInterlaced, getBytesPerFrame() * sizeof(Pel) ); + } + else + { + memcpy( opencvFrame.data, &(m_pppcInputPel[LUMA][0][0]), getBytesPerFrame() * sizeof(Pel) ); + } + return opencvFrame; } #endif } - // NAMESPACE +// NAMESPACE diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 0c3866f..1bc2fe5 100755 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -31,6 +31,9 @@ #include #include #include +#ifdef USE_OPENCV +#include +#endif #ifdef USE_PIXFC #include "pixfc-sse.h" #endif