摄像头图像采集程序与分析

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

打开摄像头:

case IDM_OPENCAMERA:

if(capDriverConnect(hwndCap, 0)==TRUE)

{

capDriverGetCaps(hwndCap , &CapDriver ,sizeof (CAPDRIVERCAPS) );

if (CapDriver.fHasOverlay)

capOverlay(hwndCap ,TRUE);

else

{

capPreviewRate(hwndCap ,66) ;

capPreview(hwndCap, TRUE) ;

}

}

else {

MessageBox(hwndCap,"打开摄像头错误!\n 确定摄像头是否已连接","错误

",MB_OK);

}break;

//采集,捕捉摄像头单帧图像

case IDM_CAPTUREIMG:

capGrabFrame( hwndCap);

break;

//保存摄像头采集的图片

case IDM_CAPIMGSA VE:

MenuOpenDlg(hwnd,"视频采集保存对话框","save");

capFileSaveDIB(hwndCap,TempName);

break;

//VideoCapture.cpp

#include

#include

#include

#include

#include "VideoCapture.h"

#include "resource.h"

char TempName[256];

HWND hwndCap;

HWND hwndSetCapStutas;

CAPDRIVERCAPS CapDriver;

CAPSTATUS CapStat;

2 / 17

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)

{

if(DialogBox(hInstance,(LPCSTR)IDD_DIALOG1,NULL,DlgProc)==-1) MessageBox(NULL,"对话框建立错误!","错误",MB_OK);

return 0;

}

BOOL CALLBACK DlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM

lParam)

{

RECT rect;

switch(message)

{

case WM_INITDIALOG:

GetWindowRect(hdlg,&rect);

hwndCap =capCreateCaptureWindow(" 人脸录入" ,WS_CHILD|

WS_VISIBLE,30,20,320,240,hdlg ,0);

return FALSE;

case WM_COMMAND :

switch (LOWORD (wParam))

{

case IDOK :

if(capDriverConnect(hwndCap, 0)==TRUE)

{

capDriverGetCaps(hwndCap , &CapDriver ,sizeof (CAPDRIVERCAPS) );

if (CapDriver.fHasOverlay)

capOverlay(hwndCap ,TRUE);

else

{

capPreviewRate (hwndCap ,66) ;

capPreview(hwndCap, TRUE) ;

}

}

else

MessageBox(hdlg,"采集图像错误","提示",MB_OK);

return 0;

break;

case IDC_BUTTON1: 3 / 17

if(CapDriver.fHasDlgVideoSource)

capDlgVideoSource(hwndCap);

break;

case IDC_BUTTON2:

MessageBox(hdlg,"作者:Steward\n地址:云南大学信息学院","关于作者",MB_OK);

break;

case IDC_BUTTON3:

capGrabFrame( hwndCap);

break;

case IDC_BUTTON4:

MenuOpenDlg(hdlg,"视频采集保存对话框");

capFileSaveDIB(hwndCap,TempName);

break;

case IDCANCEL :

capCaptureStop(hwndCap);

capDriverDisconnect (hwndCap);

EndDialog (hdlg, 0) ;

return TRUE ;

}

break ;

}

return FALSE ;

}

void MenuOpenDlg(HWND hWnd,char *str1)

{

OPENFILENAME OpenTemp;

DWORD Errval,error;

相关文档
最新文档