Implement Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )

This commit is contained in:
jfmcarreira committed 2014-05-17 14:41:20 +01:00
1 parent 92e758009d
commit cb3a120a0b
2 files changed
+47 -1

No files matched your search

+46 -1
View File
@@ -520,10 +520,55 @@ cv::Mat PlaYUVerFrame::getCvMat()
}
else
{
memcpy( opencvFrame.data, &(m_pppcInputPel[LUMA][0][0]), getBytesPerFrame() * sizeof(Pel) );
memcpy( opencvFrame.data, &( m_pppcInputPel[LUMA][0][0] ), getBytesPerFrame() * sizeof(Pel) );
}
return opencvFrame;
}
Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
{
if( m_iPixelFormat == NO_FMT )
{
switch( opencvFrame->channels() )
{
case 1:
m_iPixelFormat = GRAY;
break;
case 3:
m_iPixelFormat = RGB8;
break;
default:
return;
}
}
if( !isValid() )
{
init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat );
}
m_bHasRGBPel = false;
if( m_iPixelFormat != GRAY )
{
Pel* pInputPelY = m_pppcInputPel[LUMA][0];
Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0];
Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0];
Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced;
memcpy( pcRGBPelInterlaced, opencvFrame->data, getBytesPerFrame() * sizeof(Pel) );
for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
{
*pInputPelY++ = *pcRGBPelInterlaced++;
*pInputPelU++ = *pcRGBPelInterlaced++;
*pInputPelV++ = *pcRGBPelInterlaced++;
}
m_bHasRGBPel = true;
}
else
{
memcpy( m_pppcInputPel[LUMA][0], opencvFrame->data, getBytesPerFrame() * sizeof(Pel) );
}
}
#endif
}
// NAMESPACE
+1
View File
@@ -145,6 +145,7 @@ public:
#ifdef USE_OPENCV
cv::Mat getCvMat();
Void copyFrom( cv::Mat* input_frame );
#endif
UInt getWidth() const