Change interface with other libs in PlaYUVerFrame
This commit is contained in:
@@ -362,34 +362,8 @@ Void PlaYUVerFrame::FrametoRGB8Pixfc()
|
||||
#endif
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::copyFrom( struct AVFrame *ffAvFrame, Int iPixelFormat )
|
||||
{
|
||||
#ifdef USE_FFMPEG
|
||||
if( m_iPixelFormat != iPixelFormat )
|
||||
return;
|
||||
m_bHasRGBPel = false;
|
||||
for( UInt ch = 0; ch < m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
Pel *pPel = m_pppcInputPel[ch][0];
|
||||
uint8_t *ffPel = ffAvFrame->data[ch];
|
||||
if( !ffPel ) continue;
|
||||
Int ratioH = ch > 0 ? m_pcPelFormat->ratioChromaHeight : 1;
|
||||
Int ratioW = ch > 0 ? m_pcPelFormat->ratioChromaWidth : 1;
|
||||
for( UInt y = 0; y < m_uiHeight / ratioH; y++ )
|
||||
{
|
||||
for( UInt x = 0; x < m_uiWidth / ratioW; x++ )
|
||||
{
|
||||
*pPel++ = ffPel[x];
|
||||
}
|
||||
ffPel += ffAvFrame->linesize[ch];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
cv::Mat PlaYUVerFrame::getCvMat()
|
||||
Void PlaYUVerFrame::getCvMat( cv::Mat** ppCvFrame )
|
||||
{
|
||||
Int cvType = CV_8UC3;
|
||||
switch( m_iPixelFormat )
|
||||
@@ -409,17 +383,17 @@ cv::Mat PlaYUVerFrame::getCvMat()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cv::Mat opencvFrame( m_uiHeight, m_uiWidth, cvType );
|
||||
cv::Mat *pcCvFrame = *ppCvFrame = new cv::Mat( m_uiHeight, m_uiWidth, cvType );
|
||||
|
||||
if( m_iPixelFormat != GRAY )
|
||||
{
|
||||
fillRGBBuffer();
|
||||
memcpy( opencvFrame.data, m_pcRGB32, m_uiWidth * m_uiHeight * 4 * sizeof(UChar) );
|
||||
memcpy( pcCvFrame->data, m_pcRGB32, m_uiWidth * m_uiHeight * 4 * sizeof(UChar) );
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( opencvFrame.data, &( m_pppcInputPel[LUMA][0][0] ), m_uiWidth * m_uiHeight * sizeof(Pel) );
|
||||
memcpy( pcCvFrame->data, &( m_pppcInputPel[LUMA][0][0] ), m_uiWidth * m_uiHeight * sizeof(Pel) );
|
||||
}
|
||||
return opencvFrame;
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
|
||||
|
||||
@@ -168,10 +168,8 @@ public:
|
||||
/**
|
||||
* Interface to other libs
|
||||
*/
|
||||
Void copyFrom( struct AVFrame *, Int iPixelFormat );
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
cv::Mat getCvMat();
|
||||
Void getCvMat( cv::Mat** );
|
||||
Void copyFrom( cv::Mat* );
|
||||
#endif
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ PlaYUVerStream::PlaYUVerStream()
|
||||
m_ppcFrameBuffer = NULL;
|
||||
m_uiFrameBufferSize = 2;
|
||||
m_uiFrameBufferIndex = 0;
|
||||
m_uiAveragePlayInterval = 0;
|
||||
#ifdef USE_FFMPEG
|
||||
m_cLibAvContext = new LibAvContextHandle;
|
||||
#endif
|
||||
@@ -259,9 +258,6 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
|
||||
|
||||
seekInput( 0 );
|
||||
|
||||
m_cTimer.start();
|
||||
m_uiAveragePlayInterval = 0;
|
||||
|
||||
m_bInit = true;
|
||||
return m_bInit;
|
||||
}
|
||||
@@ -313,10 +309,6 @@ Void PlaYUVerStream::close()
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D<Pel>( m_pStreamBuffer );
|
||||
|
||||
qDebug( ) << "Frame read time: "
|
||||
<< QString::number( 1000 / ( m_uiAveragePlayInterval + 1 ) )
|
||||
<< " fps";
|
||||
|
||||
m_bLoadAll = false;
|
||||
m_bInit = false;
|
||||
}
|
||||
@@ -550,8 +542,6 @@ Void PlaYUVerStream::readFrame()
|
||||
}
|
||||
m_pcNextFrame->frameFromBuffer( m_pStreamBuffer, bytes_read );
|
||||
}
|
||||
//Int time = m_cTimer.elapsed();
|
||||
//m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time) / 2;
|
||||
m_pcNextFrame->fillRGBBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,9 +70,6 @@ private:
|
||||
QString m_cCodedName;
|
||||
QString m_cStreamInformationString;
|
||||
|
||||
QTime m_cTimer;
|
||||
UInt m_uiAveragePlayInterval;
|
||||
|
||||
FILE* m_pFile; /**< The input file pointer >*/
|
||||
Int m_iFileFormat;
|
||||
Int m_iPixelFormat;
|
||||
|
||||
@@ -67,11 +67,13 @@ Void DisparityStereoVar::create( PlaYUVerFrame* InputFrame )
|
||||
|
||||
PlaYUVerFrame* DisparityStereoVar::process( PlaYUVerFrame* InputLeft, PlaYUVerFrame* InputRight )
|
||||
{
|
||||
cv::Mat leftImage = InputLeft->getCvMat();
|
||||
cv::Mat rightImage = InputRight->getCvMat();
|
||||
cv::Mat* leftImage;
|
||||
InputLeft->getCvMat( &leftImage );
|
||||
cv::Mat* rightImage;
|
||||
InputRight->getCvMat( &rightImage );
|
||||
cv::Mat disparityImage, disparityImage8;
|
||||
|
||||
m_cStereoVar(leftImage,rightImage,disparityImage);
|
||||
m_cStereoVar(*leftImage,*rightImage,disparityImage);
|
||||
disparityImage.convertTo(disparityImage8,CV_8U);
|
||||
|
||||
m_pcDisparityFrame->copyFrom(&disparityImage8);
|
||||
|
||||
Reference in New Issue
Block a user