Fix save image with opencv problems
This commit is contained in:
1 parent
51f9585263
commit
2bd2e2ce95
1 file changed
+12
-2
@@ -125,7 +125,7 @@ Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename )
|
|||||||
switch( pcFrame->getNumberChannels() )
|
switch( pcFrame->getNumberChannels() )
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
cvType = CV_8UC4;
|
cvType = CV_8UC3;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
cvType = CV_8UC1;
|
cvType = CV_8UC1;
|
||||||
@@ -134,10 +134,20 @@ Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename )
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Mat pcCvFrame( pcFrame->getHeight(), pcFrame->getWidth(), cvType );
|
cv::Mat pcCvFrame( pcFrame->getHeight(), pcFrame->getWidth(), cvType );
|
||||||
|
|
||||||
if( pcFrame->getColorSpace() != PlaYUVerFrame::COLOR_GRAY )
|
if( pcFrame->getColorSpace() != PlaYUVerFrame::COLOR_GRAY )
|
||||||
{
|
{
|
||||||
memcpy( pcCvFrame.data, pcFrame->getRGBBuffer(), pcFrame->getHeight() * pcFrame->getWidth() * 4 * sizeof(UChar) );
|
UChar* pCvPel = pcCvFrame.data;
|
||||||
|
UChar* pARGB = pcFrame->getRGBBuffer();
|
||||||
|
for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ )
|
||||||
|
{
|
||||||
|
*pCvPel++ = *pARGB++;
|
||||||
|
*pCvPel++ = *pARGB++;
|
||||||
|
*pCvPel++ = *pARGB++;
|
||||||
|
pARGB++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user