资源简介
此代码基于OpenCV技术,通过眼睛、嘴巴等器管可直接检测是否处于疲劳状态
代码片段和文件信息
//////////////////////////////////////////////////////////////////////
// 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 “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“NullRenderer“);
hr = m_pSa
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 209452 2010-10-30 22:14 4\ALARM.WAV
文件 649481 2010-10-30 22:14 4\Average of Synthetic Exact Filters.pdf
文件 11586 2010-10-30 22:14 4\CameraDS.cpp
文件 4733 2010-10-30 22:14 4\camerads.dsp
文件 541 2010-10-30 22:14 4\camerads.dsw
文件 3302 2010-10-30 22:14 4\CameraDS.h
文件 156672 2010-11-05 10:26 4\camerads.ncb
文件 54784 2010-11-05 10:25 4\camerads.opt
文件 1000 2010-11-05 10:24 4\camerads.plg
文件 843824 2010-10-30 22:14 4\cv100.dll
文件 1265722 2010-10-30 22:14 4\cv100d_i7.dll
文件 598067 2010-10-30 22:14 4\cvaux100.dll
文件 49152 2010-10-30 22:14 4\cvcam100.dll
文件 1011764 2010-10-30 22:14 4\cxcore100.dll
文件 1581118 2010-10-30 22:14 4\cxcore100d_i7.dll
文件 131133 2010-10-30 22:14 4\cxts001.dll
文件 536687 2010-11-05 10:24 4\Debug\camerads.exe
文件 701444 2010-11-05 10:24 4\Debug\camerads.ilk
文件 114753 2010-11-03 21:18 4\Debug\CameraDS.obj
文件 43520 2010-10-30 22:16 4\Debug\camerads.opt
文件 7814688 2010-11-04 23:20 4\Debug\camerads.pch
文件 885760 2010-11-05 10:24 4\Debug\camerads.pdb
文件 226808 2010-11-05 10:24 4\Debug\main.obj
文件 336896 2010-11-05 10:24 4\Debug\vc60.idb
文件 413696 2010-11-05 10:24 4\Debug\vc60.pdb
文件 631 2010-10-30 22:14 4\DirectShow\Include\activecf.h
文件 1826 2010-10-30 22:14 4\DirectShow\Include\amaudio.h
文件 1065 2010-10-30 22:14 4\DirectShow\Include\amparse.h
文件 73261 2010-10-30 22:14 4\DirectShow\Include\amstream.h
文件 3974 2010-10-30 22:14 4\DirectShow\Include\amva.h
............此处省略171个文件信息
- 上一篇:SpaceClaim 联机帮助和支持
- 下一篇:serialplot win64
评论
共有 条评论