Add support for device opening

This commit is contained in:
2017-03-23 20:26:28 +00:00
parent bc2b3d040c
commit f6f3cf15ab
6 changed files with 25 additions and 26 deletions
+4 -5
View File
@@ -120,11 +120,10 @@ CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, boo
{
return supportedFmts[i].formatFct;
}
// else if( strFilename.find( supportedFmts[i].formatExt ) !=
// String::npos )
// {
// return supportedFmts[i].formatFct;
// }
else if( strFilename.find( supportedFmts[i].formatExt ) != String::npos )
{
return supportedFmts[i].formatFct;
}
}
return &StreamHandlerRaw::Create;
}
+2
View File
@@ -34,6 +34,8 @@ class PlaYUVerFrame;
public: \
static PlaYUVerStreamHandlerIf* Create() { return new X(); } \
void Delete() { delete this; }
/**
* \class PlaYUVerStreamHandlerIf
* \ingroup PlaYUVerLib_Stream
+9 -4
View File
@@ -40,8 +40,7 @@ using cv::VideoCapture;
std::vector<PlaYUVerSupportedFormat> StreamHandlerOpenCV::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
// REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Device",
// "/dev/" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerOpenCV::Create, "Device", "/dev/" );
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
@@ -71,9 +70,15 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput )
*/
if( m_cFilename.find( "/dev/video" ) != String::npos )
{
Int iDeviceId = 0;
if( m_cFilename.find( "/dev/video0" ) != String::npos )
iDeviceId = 0;
else if( m_cFilename.find( "/dev/video1" ) != String::npos )
iDeviceId = 1;
m_strFormatName = "DEV";
m_strCodecName = "Raw Video";
pcVideoCapture = new VideoCapture( 0 );
pcVideoCapture = new VideoCapture( iDeviceId );
m_uiWidth = pcVideoCapture->get( CV_CAP_PROP_FRAME_WIDTH );
m_uiHeight = pcVideoCapture->get( CV_CAP_PROP_FRAME_HEIGHT );
m_dFrameRate = 25;
@@ -88,7 +93,7 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput )
m_dFrameRate = 1;
}
m_uiBitsPerPixel = 8;
m_iPixelFormat = PlaYUVerFrame::findPixelFormat( "BGR24" );
m_iPixelFormat = PlaYUVerFrame::findPixelFormat( "BGR" );
}
return true;