《xp下采用directshow采集摄像头》由会员分享,可在线阅读,更多相关《xp下采用directshow采集摄像头(20页珍藏版)》请在金锄头文库上搜索。
1、XP下采用DirectShow采集摄像头 分类: TCPMP/DDShow/音视频编解码技术2012-05-24 16:426602人阅读评论(14)收藏举报xpnullgraphfilterinterfacefunction目录(?)+1. 一初始化工作1. DirctShow环境初始化2. 搜索Video源2. 二选择某个摄像设备1. 先停止原有的Media2. 删除Graph3. 根据选择的设备的moniker来创建Graph3. 四开始播放4. 五 pin 特征的查看5. 六 查询包含的 filter信息转载请标明是引用于 http:/ 摄像头能正常工作、摄像头有创建directsho
2、w filter即 大家可以对比我的另一篇文章学习: wince系统下DirectShow采集摄像头一、初始化工作1、DirctShow环境初始化cppview plaincopyprint?1. bool2. uEye_DirectShow_Demo_Dlg:DirectShow_Init()3. 4. /initializetheCOMlibraryonthecurrentthread 5. HRESULTerr=CoInitialize(NULL);6. 7. if(FAILED(err)8. 9. MessageBoxEx(NULL,InitializingCOMlibraryfail
3、ed!,_FUNCTION_,MB_ICONERROR,0);10. 11. 12. returnerr=S_OK;13. booluEye_DirectShow_Demo_Dlg:DirectShow_Init() / initialize the COM library on the current thread HRESULT err= CoInitialize(NULL); if( FAILED(err) MessageBoxEx( NULL, Initializing COM library failed!, _FUNCTION_, MB_ICONERROR, 0); return
4、err = S_OK;2、搜索Video源如果没有设备接入,那么CreateClassEnumerator会返回失败cppview plaincopyprint?1. bool2. uEye_DirectShow_Demo_Dlg:VideoSourcesList_Fill()3. 4. HRESULTstatus=S_OK;5. 6. /createSystemDeviceEnumerator 7. ICreateDevEnum*pSystemDeviceEnumerator=NULL;8. status=CoCreateInstance(CLSID_SystemDeviceEnum,9.
5、NULL,10. CLSCTX_INPROC,11. IID_ICreateDevEnum,12. (void*)&pSystemDeviceEnumerator);13. if(FAILED(status)14. 15. MessageBoxEx(NULL,CreatingSystemDeviceEnumeratorfailed!,_FUNCTION_,MB_ICONERROR,0);16. returnfalse;17. 18. 19. /createClassEnumeratorthatlistsallsvideoinputdevicesamongthesystemdevices 20.
6、 IEnumMoniker*pVideoInputDeviceEnumerator=NULL;21. status=pSystemDeviceEnumerator-CreateClassEnumerator(CLSID_VideoInputDeviceCategory,22. &pVideoInputDeviceEnumerator,23. 0);24. 25. /releasetheSystemDeviceEnumeratorwhichisnotneededanymore 26. pSystemDeviceEnumerator-Release();27. pSystemDeviceEnume
7、rator=NULL;28. 29. if(status!=S_OK)30. 31. MessageBoxEx(NULL,CreatingClassEnumeratorfailed!,_FUNCTION_,MB_ICONERROR,0);32. returnfalse;33. 34. 35. /addentrynodeviceselectedtolist 36. m_comboVideoSources.AddString(nodeviceselected);37. m_comboVideoSources.SetItemDataPtr(0,NULL);38. 39. /foreachenumer
8、atedvideoinputdevice:addittothelist 40. IMoniker*pMoniker=NULL;41. while(pVideoInputDeviceEnumerator-Next(1,&pMoniker,NULL)=S_OK)42. 43. VARIANTvar;44. VariantInit(&var);45. 46. /makefilterspropertiesaccessible 47. IPropertyBag*pPropBag=NULL;48. status=pMoniker-BindToStorage(0,0,IID_IPropertyBag,(vo
9、id*)&pPropBag);49. if(FAILED(status)50. 51. pPropBag=NULL;52. MessageBoxEx(NULL,Accessingfilterpropertiesfailed!,_FUNCTION_,MB_ICONERROR,0);53. /continuewiththenextfilter 54. 55. else56. 57. /addareferencetothestorageobject 58. pPropBag-AddRef();59. 60. /getthenameofthisfilter 61. status=pPropBag-Re
10、ad(LFriendlyName,&var,0);62. if(FAILED(status)63. 64. MessageBoxEx(NULL,Readingfilternamefailed!,_FUNCTION_,MB_ICONERROR,0);65. /continuewiththenextfilter 66. 67. else68. 69. /ifuEyeCaptureDevice: 70. /addfilternametothelistandlinkthemonikerpointertothelistentry 71. CStringsTemp(var.bstrVal);72. #if(0)/*jma04/08/2010adddevicesnamedUI.too*/ 73. if(sTemp.Find(uEyeCaptureDevice,0)!=-1)74. #endif 75.