摄像头驱动小软件
来源:互联网 发布:黑莓q10软件下载 编辑:程序博客网 时间:2024/05/02 00:16
利用MFC建立一个对话框。拉一个组框作为图像显示窗口。
在对话框头文件中添加包含库代码
#include "vfw.h"
#pragma comment(lib,"vfw32.lib")
#include <afxmt.h>
在公共成员变量中添加窗口句柄变量,和事件变量
HWND m_hVideoWnd; //窗口句柄
CEvent m_Event; //事件
再添加自定义线程函数的声明,注意是静态STATIC类型
static UINT ThreadFun( LPVOID lpParam ); //线程函数声明
在C++文件中添加线程函数
//定义线程函数
UINT CCaptureDlg::ThreadFun( LPVOID lpParam )
{
CCaptureDlg* pTempDlg = (CCaptureDlg*)lpParam;
if (pTempDlg!= NULL)
{
HWND hwnd= capCreateCaptureWindow(NULL,WS_POPUP,0,0,300,300,pTempDlg->m_hWnd,0);
//指定位置创建窗口
pTempDlg->m_hVideoWnd = hwnd;
pTempDlg->m_Event.SetEvent();
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
return 0;
}
然后在OnInitDialog()函数中开始一个线程添加代码如下
AfxBeginThread(ThreadFun,(void*)this); //开始一个线程
::WaitForSingleObject(m_Event,INFINITE); //等待线程函数的执行
if (capDriverConnect(m_hVideoWnd,0)) //连接驱动程序
{
::SetParent(m_hVideoWnd,*this); //设置父窗口
::SetWindowLong(m_hVideoWnd,GWL_STYLE,WS_CHILD);
::SetWindowPos(m_hVideoWnd,NULL,17,27,
300,300,SWP_NOZORDER);
::ShowWindow(m_hVideoWnd,SW_SHOW);
capPreviewRate(m_hVideoWnd,30); //设置预览速率
capPreview(m_hVideoWnd,true); //开始预览
}
即可显示图像。
- 摄像头驱动小软件
- 摄像头驱动
- 使用DirectShow驱动摄像头
- 使用DirectShow驱动摄像头
- 使用DirectShow驱动摄像头
- 使用DirectShow驱动摄像头
- 使用DirectShow驱动摄像头
- Ubuntu 摄像头驱动安装
- Linux下摄像头驱动
- 使用DirectShow驱动摄像头
- 驱动摄像头的类
- 使用DirectShow驱动摄像头
- 使用DirectShow驱动摄像头
- DirectShow驱动摄像头
- wince摄像头驱动
- 不知品牌摄像头驱动
- 使用DirectShow驱动摄像头
- 求WIN7摄像头驱动
- 从字符串中截取掉指定的子字符串.
- Python CheatSheet
- mysql 的capi预处理
- C++ 程序员应聘常见笔试题(2)
- 努力,祝福!
- 摄像头驱动小软件
- 《51单片机开发入门与典型实例》目录
- 对于数据的显示在 StringGrid 的 OnDrawCell 事件中写程序
- TAdvStringGrid
- xlsreadwriteII2的一个unicode的bug
- ORACLE汉字排序
- Android软件TOP10排行榜
- 网络技巧:八大方法巧妙排除网络连接故障
- 007推荐好书之传记类:《解读傅雷一家》与《解密钱学森》