-
大小: 146KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-05-08
- 語言: 其他
- 標(biāo)簽: Labwindows??攝像頭??
資源簡介
程序是用Labwindows使用USB攝像頭的方法,可一實(shí)時預(yù)覽,并且能捕獲和抓拍。

代碼片段和文件信息
#include?“windows.h“
#include?“CapturePicture.h“
#include?
#include???
#include?
#include?“video.h“
//設(shè)置所需要攝像頭的常量
#define?WM_CAP_START?????????WM_USER????//開始
#define?WM_CAP_STOP?????????WM_CAP_START?+?68??//停止
#define?WM_CAP_DRIVER_CONNECT??????WM_CAP_START?+?10???//連接
#define?WM_CAP_DRIVER_DISCONNECT??????WM_CAP_START?+?11???//斷開
#define?WM_CAP_SAVEDIB????????WM_CAP_START?+?25
#define?WM_CAP_GRAB_frame???????WM_CAP_START?+?60
#define?WM_CAP_SEQUENCE????????WM_CAP_START?+?62
#define?WM_CAP_FILE_SET_CAPTURE_FILEA????WM_CAP_START?+?20?//保存至文件
#define?WM_CAP_SEQUENCE_NOFILE?????WM_CAP_START?+?63
#define?WM_CAP_SET_OVERLAY??????WM_CAP_START?+?51
#define?WM_CAP_SET_PREVIEW??????WM_CAP_START?+?50
#define?WM_CAP_SET_CALLBACK_VIDEOSTREAM????WM_CAP_START?+6
#define?WM_CAP_SET_CALLBACK_ERROR?????WM_CAP_START?+2
#define?WM_CAP_SET_CALLBACK_STATUSA????WM_CAP_START?+3
#define?WM_CAP_SET_CALLBACK_frame?????WM_CAP_START?+5
#define?WM_CAP_SET_SCALE??????WM_CAP_START+??53
#define?WM_CAP_SET_PREVIEWRATE?????WM_CAP_START+??52
#define?WM_CAP_COPYDIB??????WM_CAP_START?+?30??//復(fù)制圖片
//定義面板句柄
static?int?handle;
//定義攝像頭句柄
static?int?result;
static?int?panelHandle;
int?main?(int?argc?char?*argv[])
{
?if?(InitCVIRTE?(0?argv?0)?==?0)
??return?-1;?/*?out?of?memory?*/
?if?((panelHandle?=?LoadPanel?(0?“cam.uir“?PANEL))?0)
??return?-1;
?DisplayPanel?(panelHandle);
?RunUserInterface?();
?DiscardPanel?(panelHandle);
?return?0;
}
//退出按鈕
int?CVICALLBACK?QuitCallback?(int?panel?int?control?int?event
??void?*callbackData?int?eventData1?int?eventData2)
{
?switch?(event)
?{
??case?EVENT_COMMIT:
???QuitUserInterface?(0);
???break;
?}
?return?0;
}
//開始按鈕
int?CVICALLBACK?startCB?(int?panel?int?control?int?event
??void?*callbackData?int?eventData1?int?eventData2)
{
?int?width;
?int?height;
?int?top;
?int?left;
switch?(event)
?{
??case?EVENT_COMMIT:
???
???//獲得面板句柄
???GetPanelAttribute?(panelHandle?ATTR_SYSTEM_WINDOW_HANDLE?handle);
???
???//獲得屏幕中圖像要顯示的位置
???GetCtrlAttribute?(panelHandle?PANEL_CANVAS_TV?ATTR_LEFT?left);
???GetCtrlAttribute?(panelHandle?PANEL_CANVAS_TV?ATTR_TOP?top);
???GetCtrlAttribute?(panelHandle?PANEL_CANVAS_TV?ATTR_HEIGHT?height);
???GetCtrlAttribute?(panelHandle?PANEL_CANVAS_TV?ATTR_WIDTH?width);
???
???//打開攝像頭
???result?=?capCreateCaptureWindowA(““WS_CHILD?|?WS_VISIBLE?lefttopwidthheighthandle0);
???
???//設(shè)置攝像頭函數(shù)
???SendMessage((HWND)result?WM_CAP_SET_CALLBACK_VIDEOSTREAM?0?0);
??????SendMessage((HWND)result?WM_CAP_SET_CALLBACK_ERROR?0?0);
??????SendMessage((HWND)result?WM_CAP_SET_CALLBACK_STATUSA?0?0);
?????SendMessage((HWND)result?WM_CAP_DRIVER_CONNECT?0?0);
??????SendMessage((HWND)result?WM_CAP_SET_SCALE?1?0);
??????SendMessage((HWND)result?WM_CAP_SET_PREVIEWRATE?66?0);
??????SendMessage((HWND)result?WM_CAP_SET_OVERLAY?1?0);
??????SendMessage((HWND)result?WM_CAP_SET_PREVIEW?1?0);
???br
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????135168??2005-09-14?14:43??video\CapturePicture.dll
?????文件????????520??2010-01-13?22:53??video\CapturePicture.h
?????文件?????266992??2004-08-12?17:20??video\CapturePicture.lib
?????文件???????7948??2010-01-13?22:46??video\video.c
?????文件???????3198??2010-01-21?11:44??video\video.cws
?????文件????????907??2010-01-11?17:33??video\video.h
?????文件???????4609??2010-01-13?22:46??video\video.prj
?????文件????????992??2010-01-11?17:33??video\video.uir
?????目錄??????????0??2010-01-21?11:44??video
-----------?---------??----------?-----??----
???????????????420334????????????????????9
評論
共有 條評論