| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6037 人关注过本帖
标题:请问如何用VC++和VC#打开摄像头读取数据并保存为图片文件
只看楼主 加入收藏
justcy
Rank: 2
等 级:论坛游民
帖 子:25
专家分:84
注 册:2009-7-25
结帖率:0
收藏
 问题点数:0 回复次数:5 
请问如何用VC++和VC#打开摄像头读取数据并保存为图片文件
请问如何用VC++和VC#打开摄像头读取数据并保存为图片文件  比如可以是每隔5分钟采集一幅图像至内存  然后VC++再调用
搜索更多相关主题的帖子: 保存 文件 数据 摄像头 
2009-09-24 15:40
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:0 
靠,想做偷窥木马啊

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-09-24 17:35
woshiyizhiyu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-9-27
收藏
得分:0 
我也想知道~
2009-09-27 15:51
lixinqing0703
Rank: 2
等 级:论坛游民
威 望:1
帖 子:18
专家分:23
注 册:2008-9-29
收藏
得分:0 
打开摄像头:
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_CAPIMGSAVE:
            MenuOpenDlg(hwnd,"视频采集保存对话框","save");
            capFileSaveDIB(hwndCap,TempName);
            break;
         
2009-10-05 18:49
lixinqing0703
Rank: 2
等 级:论坛游民
威 望:1
帖 子:18
专家分:23
注 册:2008-9-29
收藏
得分:0 
//VideoCapture.cpp
#include <windows.h>
#include <stdio.h>
#include <commdlg.h>
#include <vfw.h>
#include "VideoCapture.h"
#include "resource.h"
 
char     TempName[256];
HWND hwndCap;
HWND hwndSetCapStutas;
 
CAPDRIVERCAPS CapDriver;
CAPSTATUS    CapStat;
 
 
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:
               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;
   char buf[5];
   char Errstr[50]="GetOpenFileName returned Error #";
   char szTemp[] = "BMP文件 (*.bmp;*.BMP)\0*.bmp\0所有文件 (*.*)\0*.*\0";
            
   OpenTemp.lStructSize = sizeof( OPENFILENAME );
   OpenTemp.hwndOwner = hWnd;
   OpenTemp.hInstance = 0;
   OpenTemp.lpstrFilter = (LPSTR)szTemp;
   OpenTemp.lpstrCustomFilter = NULL;
   OpenTemp.nMaxCustFilter = 0;
   OpenTemp.nFilterIndex = 1;
   OpenTemp.lpstrFile = (LPSTR)TempName;
   OpenTemp.nMaxFile = sizeof( TempName );
   OpenTemp.lpstrFileTitle = NULL;
   OpenTemp.nMaxFileTitle = 0;
   OpenTemp.lpstrInitialDir = NULL;
   OpenTemp.lpstrTitle=str1;
   OpenTemp.Flags = OFN_FILEMUSTEXIST |
        OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
   OpenTemp.nFileOffset = 0;
   OpenTemp.nFileExtension = 0;
   OpenTemp.lpstrDefExt = "*";
   OpenTemp.lCustData = 0L;
   OpenTemp.lpfnHook = NULL;
   OpenTemp.lpTemplateName = NULL;
   error=0;
   
 
    if (GetSaveFileName( &OpenTemp ) != TRUE)  
        error=1;
   
 
   if (error==1) {
      Errval=CommDlgExtendedError();
      if (Errval!=0) {
         sprintf(buf,"%ld",Errval);
         strcat(Errstr,buf);
         MessageBox(hWnd,Errstr,"WARNING",MB_OK|MB_ICONSTOP);
      }
   }
   InvalidateRect( hWnd, NULL, TRUE );
}
2009-10-05 19:02
lixinqing0703
Rank: 2
等 级:论坛游民
威 望:1
帖 子:18
专家分:23
注 册:2008-9-29
收藏
得分:0 
//资源文件
// Dialog
//
 
IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 203, 201
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "视频采集"
FONT 10, "System"
BEGIN
    DEFPUSHBUTTON   "打开",IDOK,31,143,39,14
    PUSHBUTTON      "退出",IDCANCEL,140,169,37,15
    PUSHBUTTON      "设置",IDC_BUTTON1,140,142,38,14
    PUSHBUTTON      "帮助",IDC_BUTTON2,84,170,38,14
    PUSHBUTTON      "捕捉图像",IDC_BUTTON3,85,142,38,15
    PUSHBUTTON      "保存图像",IDC_BUTTON4,32,170,37,14
END
// DESIGNINFO
GUIDELINES DESIGNINFO DISCARDABLE  
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 196
        TOPMARGIN, 7
        BOTTOMMARGIN, 194
    END
END
2009-10-05 19:04
快速回复:请问如何用VC++和VC#打开摄像头读取数据并保存为图片文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048895 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved