资源简介
MFC+OPENCV开发摄像机标定程序,可控制摄像机的打开关闭,截取符合标定要求的靶标图像,并将标定结果显示在edit box中,包含内外参数,畸变参数。
代码片段和文件信息
//////////////////////////////////////////////////////////////////////
// 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 = false;
m_nWidth = 0;
m_nHeight = 0;
m_bLock = false;
m_bChanged = false;
m_pframe = NULL;
m_nBufferSize = 0;
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 = false;
m_nWidth = 0;
m_nHeight = 0;
m_bLock = false;
m_bChanged = false;
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“NullRendere
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 327 2014-03-30 10:16 ImageShow\calibdata.txt
文件 0 2014-03-30 13:29 ImageShow\caliberation_result.txt
文件 11605 2011-04-30 16:26 ImageShow\CameraDS.cpp
文件 3302 2011-04-30 16:26 ImageShow\CameraDS.h
文件 277 2007-05-29 14:05 ImageShow\cvut\cvut.h
文件 5172 2007-05-29 13:28 ImageShow\cvut\cvutImage.h
文件 16548 2014-03-12 10:19 ImageShow\cvut\cvutMatrix.h
文件 6166 2014-03-12 10:21 ImageShow\cvut\cvutSeq.h
文件 6442 2007-05-29 14:34 ImageShow\cvut\cvutUtil.h
文件 277 2007-05-29 14:05 ImageShow\cvut.h
文件 5172 2007-05-29 13:28 ImageShow\cvutImage.h
文件 16537 2014-03-12 10:17 ImageShow\cvutMatrix.h
文件 6162 2007-05-29 14:08 ImageShow\cvutSeq.h
文件 6442 2007-05-29 14:34 ImageShow\cvutUtil.h
文件 99531 2014-03-27 10:02 ImageShow\Debug\CameraDS.obj
文件 4056064 2014-03-12 09:17 ImageShow\Debug\ImageShow.bsc
文件 167985 2014-03-30 13:36 ImageShow\Debug\ImageShow.exe
文件 613784 2014-03-30 13:36 ImageShow\Debug\ImageShow.ilk
文件 16076 2014-03-27 10:02 ImageShow\Debug\ImageShow.obj
文件 5916124 2014-03-27 10:02 ImageShow\Debug\ImageShow.pch
文件 730112 2014-03-30 13:36 ImageShow\Debug\ImageShow.pdb
文件 2996 2014-03-30 09:10 ImageShow\Debug\ImageShow.res
文件 0 2014-03-12 09:16 ImageShow\Debug\ImageShow.sbr
文件 0 2014-03-12 09:17 ImageShow\Debug\ImageShowDlg.sbr
文件 106191 2014-03-27 10:02 ImageShow\Debug\StdAfx.obj
文件 1366381 2014-03-12 09:16 ImageShow\Debug\StdAfx.sbr
文件 623616 2014-04-08 22:31 ImageShow\Debug\vc60.idb
文件 790528 2014-04-08 22:31 ImageShow\Debug\vc60.pdb
文件 631 2011-04-30 16:26 ImageShow\DirectShow\Include\activecf.h
文件 1826 2011-04-30 16:26 ImageShow\DirectShow\Include\amaudio.h
............此处省略199个文件信息
- 上一篇:百度地图二次开发汇总
- 下一篇:C++MFC日程管理系统
评论
共有 条评论