• 大小: 17.37MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-13
  • 语言: C/C++
  • 标签: mfc  opencv  directshow  

资源简介

opencv+directshow+mfc同步打开4个摄像头

资源截图

代码片段和文件信息

//////////////////////////////////////////////////////////////////////
// Video Capture using DirectShow
// Author: Shiqi Yu (shiqi.yu@gmail.com)
// Thanks to:
// HardyAI@OpenCV China
// flymanbox@OpenCV China (for his contribution to function CameraName and frame width/height setting)
// Last modification: April 9 2009
//////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////
// 使用说明:
//   1. 将CameraDS.h CameraDS.cpp以及目录DirectShow复制到你的项目中
//   2. 菜单 Project->Settings->Settings for:(All configurations)->C/C++->Category(Preprocessor)->Additional include directories
//      设置为 DirectShow/Include
//   3. 菜单 Project->Settings->Settings for:(All configurations)->link->Category(Input)->Additional library directories
//      设置为 DirectShow/Lib
//////////////////////////////////////////////////////////////////////

// CameraDS.cpp: implementation of the CCameraDS class.
//
//////////////////////////////////////////////////////////////////////
#include“stdafx.h“
#include “CameraDS.h“

#pragma comment(lib“Strmiids.lib“) 
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCameraDS::CCameraDS()
{
m_bConnected = m_bLock = m_bChanged = false;
m_nWidth = m_nHeight = 0;
m_nBufferSize = 0;

m_pframe = NULL;

m_pNullFilter = NULL;
m_pMediaEvent = NULL;
m_pSampleGrabberFilter = NULL;
m_pGraph = NULL;

CoInitialize(NULL);
}

CCameraDS::~CCameraDS()
{
CloseCamera();
CoUninitialize();
}

void CCameraDS::CloseCamera()
{
if(m_bConnected)
{
m_pMediaControl->Stop();
}

m_pGraph = NULL;
m_pDeviceFilter = NULL;
m_pMediaControl = NULL;
m_pSampleGrabberFilter = NULL;
m_pSampleGrabber = NULL;
m_pGrabberInput = NULL;
m_pGrabberOutput = NULL;
m_pCameraOutput = NULL;
m_pMediaEvent = NULL;
m_pNullFilter = NULL;
m_pNullInputPin = NULL;

if (m_pframe)
{
cvReleaseImage(&m_pframe);
}

m_bConnected = m_bLock = m_bChanged = false;
m_nWidth = m_nHeight = 0;
m_nBufferSize = 0;
}

bool CCameraDS::OpenCamera(int nCamID bool bDisplayProperties int nWidth int nHeight)
{
HRESULT hr = S_OK;

CoInitialize(NULL);
// Create the Filter Graph Manager.
hr = CoCreateInstance(CLSID_FilterGraph NULL CLSCTX_INPROC IID_IGraphBuilder (void **)&m_pGraph);

hr = CoCreateInstance(CLSID_SampleGrabber NULL CLSCTX_INPROC_SERVER IID_IbaseFilter (LPVOID *)&m_pSampleGrabberFilter);

hr = m_pGraph->QueryInterface(IID_IMediaControl (void **) &m_pMediaControl);
hr = m_pGraph->QueryInterface(IID_IMediaEvent (void **) &m_pMediaEvent);

hr = CoCreateInstance(CLSID_NullRenderer NULL CLSCTX_INPROC_SERVER IID_IbaseFilter (LPVOID*) &m_pNullFilter);

hr = m_pGraph->AddFilter(m_pNullFilter L“NullRenderer“);

hr = m_pSampleGrabberFilter->QueryInterface(IID_ISam

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    2457600  2016-12-31 11:06  Directshow_4Camera\combase.pdb\A9819D7C64B44CA687E15F11AFE004F41\download.error

     文件     268800  2016-12-31 11:16  Directshow_4Camera\Debug\Directshow_4Camera.exe

     文件    1904984  2016-12-31 11:16  Directshow_4Camera\Debug\Directshow_4Camera.ilk

     文件    9129984  2016-12-31 11:16  Directshow_4Camera\Debug\Directshow_4Camera.pdb

     文件      11416  2016-12-30 22:18  Directshow_4Camera\Directshow_4Camera\CameraDS.cpp

     文件       3097  2010-11-16 17:20  Directshow_4Camera\Directshow_4Camera\CameraDS.h

     文件       6960  2012-03-14 16:52  Directshow_4Camera\Directshow_4Camera\CvvImage.cpp

     文件       1957  2016-11-26 17:01  Directshow_4Camera\Directshow_4Camera\CvvImage.h

     文件     332161  2016-12-31 10:49  Directshow_4Camera\Directshow_4Camera\Debug\CameraDS.obj

     文件     252225  2016-12-31 10:49  Directshow_4Camera\Directshow_4Camera\Debug\CvvImage.obj

     文件       4106  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\cl.command.1.tlog

     文件      94678  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\CL.read.1.tlog

     文件       4912  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\CL.write.1.tlog

     文件        175  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\Directshow_4Camera.lastbuildstate

     文件       2854  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\link.command.1.tlog

     文件       8162  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\link.read.1.tlog

     文件       1460  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\link.write.1.tlog

     文件        716  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\rc.command.1.tlog

     文件       3006  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\rc.read.1.tlog

     文件        354  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directsh.36A50D19.tlog\rc.write.1.tlog

     文件       2139  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directshow_4Camera.log

     文件      41502  2016-12-31 11:08  Directshow_4Camera\Directshow_4Camera\Debug\Directshow_4Camera.obj

     文件   43253760  2016-12-31 10:49  Directshow_4Camera\Directshow_4Camera\Debug\Directshow_4Camera.pch

     文件      70424  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directshow_4Camera.res

     文件     344320  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\Directshow_4CameraDlg.obj

     文件     905058  2016-12-31 10:49  Directshow_4Camera\Directshow_4Camera\Debug\stdafx.obj

     文件    3058688  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\vc120.idb

     文件    8474624  2016-12-31 11:16  Directshow_4Camera\Directshow_4Camera\Debug\vc120.pdb

     文件     196608  2006-02-28 18:04  Directshow_4Camera\Directshow_4Camera\DirectShow\bin\libguide40.dll

     文件      11687  2010-05-31 09:25  Directshow_4Camera\Directshow_4Camera\DirectShow\CameraDS.cpp

............此处省略191个文件信息

评论

共有 条评论