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
+1 -1
View File
@@ -449,7 +449,7 @@ Void ModulesHandle::activateModule()
if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_2 )
{
std::vector<PlaYUVerFrame*> apcFrameList;
for( UInt i = 0; i < videoSubWindowList.size(); i++ )
for( Int i = 0; i < videoSubWindowList.size(); i++ )
{
apcFrameList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrFrame() );
}
+8 -13
View File
@@ -189,11 +189,6 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
printMessage( "File " + fileName + " do not exist!", LOG_ERROR );
return;
}
load( fileName, pStreamInfo );
}
Void PlaYUVerApp::load( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
{
VideoSubWindow* videoSubWindow =
PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
if( videoSubWindow )
@@ -293,10 +288,10 @@ Void PlaYUVerApp::open()
}
}
Void PlaYUVerApp::openDevice()
{
load( "/dev/video0", NULL );
}
// Void PlaYUVerApp::openDevice()
//{
// loadFile( "/dev/video0", NULL );
//}
Void PlaYUVerApp::openRecent()
{
@@ -620,9 +615,9 @@ Void PlaYUVerApp::createActions()
m_arrayActions[OPEN_ACT]->setStatusTip( tr( "Open stream" ) );
connect( m_arrayActions[OPEN_ACT], SIGNAL( triggered() ), this, SLOT( open() ) );
m_arrayActions[OPEN_DEVICE_ACT] = new QAction( tr( "&Open Capture Device" ), this );
m_arrayActions[OPEN_DEVICE_ACT]->setStatusTip( tr( "Open capture device (webcam)" ) );
connect( m_arrayActions[OPEN_DEVICE_ACT], SIGNAL( triggered() ), this, SLOT( openDevice() ) );
// m_arrayActions[OPEN_DEVICE_ACT] = new QAction( tr( "&Open Capture Device" ), this );
// m_arrayActions[OPEN_DEVICE_ACT]->setStatusTip( tr( "Open capture device (webcam)" ) );
// connect( m_arrayActions[OPEN_DEVICE_ACT], SIGNAL( triggered() ), this, SLOT( openDevice() ) );
m_arrayRecentFilesActions.resize( MAX_RECENT_FILES );
for( Int i = 0; i < MAX_RECENT_FILES; i++ )
@@ -747,7 +742,7 @@ Void PlaYUVerApp::createMenus()
m_arrayMenu[FILE_MENU] = menuBar()->addMenu( tr( "&File" ) );
m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[OPEN_ACT] );
m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[OPEN_DEVICE_ACT] );
// m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[OPEN_DEVICE_ACT] );
m_arrayMenu[RECENT_MENU] = m_arrayMenu[FILE_MENU]->addMenu( tr( "Open Recent" ) );
for( Int i = 0; i < MAX_RECENT_FILES; ++i )
{
+1 -3
View File
@@ -89,7 +89,7 @@ class PlaYUVerApp : public QMainWindow
* File functions slots
*/
void open();
void openDevice();
// void openDevice();
void openRecent();
void save();
void format();
@@ -129,8 +129,6 @@ class PlaYUVerApp : public QMainWindow
static VideoSubWindow* findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager,
const QString& fileName );
Void load( QString fileName, PlaYUVerStreamInfo* pStreamInfo );
Void updateMenus();
Void createActions();
+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;