利用Delphi编辑控制摄像头(二)

利用Delphi编辑控制摄像头(二),第1张

   完整的程序代码如下

    unit Unit     interface    uses    Windows Messages SysUtils Variants Classes Graphics Controls Forms     Dialogs StdCtrls ExtCtrls    type    TForm = class(TForm)    Panel : TPanel    Button : TButton    Button : TButton    Button : TButton    Button : TButton    Button : TButton    procedure Button Click(Sender: TObject)    procedure Button Click(Sender: TObject)    procedure Button Click(Sender: TObject)    procedure Button Click(Sender: TObject)    procedure Button Click(Sender: TObject)    procedure FormClose(Sender: TObjectvar Action: TCloseAction)    private    hWndC : THandle    public    { Public declarations }    end    var    Form : TForm     const WM_CAP_START = WM_USER    const WM_CAP_STOP = WM_CAP_START +     const WM_CAP_DRIVER_CONNECT = WM_CAP_START +     const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START +     const WM_CAP_SAVEDIB = WM_CAP_START +     const WM_CAP_GRAB_FRAME = WM_CAP_START +     const WM_CAP_SEQUENCE = WM_CAP_START +     const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START +     const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+     const WM_CAP_SET_OVERLAY =WM_CAP_START+     const WM_CAP_SET_PREVIEW =WM_CAP_START+     const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +     const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +     const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +     const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +     const WM_CAP_SET_SCALE=WM_CAP_START+     const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+     function capCreateCaptureWindowA(lpszWindowName : PCHAR    dwStyle : longintx : integery : integernWidth : integer    nHeight : integerParentWin : HWNDnId : integer): HWND    STDCALL EXTERNAL AVICAP DLL     implementation    {$R * dfm}    procedure TForm Button Click(Sender: TObject)    begin    hWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle )    hWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle )    if hWndC <>then    begin    SendMessage(hWndC WM_CAP_SET_CALLBACK_VIDEOSTREAM )    SendMessage(hWndC WM_CAP_SET_CALLBACK_ERROR )    SendMessage(hWndC WM_CAP_SET_CALLBACK_STATUSA )    SendMessage(hWndC WM_CAP_DRIVER_CONNECT )    SendMessage(hWndC WM_CAP_SET_SCALE )    SendMessage(hWndC WM_CAP_SET_PREVIEWRATE )    SendMessage(hWndC WM_CAP_SET_OVERLAY )    SendMessage(hWndC WM_CAP_SET_PREVIEW )    end    end    procedure TForm Button Click(Sender: TObject)    begin    if hWndC <>then begin    SendMessage(hWndC WM_CAP_DRIVER_DISCONNECT )    hWndC :=     end    end    procedure TForm Button Click(Sender: TObject)    begin    if hWndC <>then begin    SendMessage(hWndC WM_CAP_SAVEDIB longint(pchar( c:\test bmp )))    end    end    procedure TForm Button Click(Sender: TObject)    begin    if hWndC <>then    begin    SendMessage(hWndC WM_CAP_FILE_SET_CAPTURE_FILEA Longint(pchar( c:\test avi )))    SendMessage(hWndC WM_CAP_SEQUENCE )    end    end    procedure TForm Button Click(Sender: TObject)    begin    if hWndC <>then begin    SendMessage(hWndC WM_CAP_STOP )    end    end    procedure TForm FormClose(Sender: TObjectvar Action: TCloseAction)    begin    if hWndC <>then begin    SendMessage(hWndC WM_CAP_DRIVER_DISCONNECT )    end    end    end

    如果电脑没有摄像头 但又想看看程序的效果 可以么?

    当然可以 找个虚拟摄像头不就搞定 大家可以试试SoftCam这个软件 它是一个名副其实的软件摄像机 能模拟成为 真实的 摄像机 提醒一下各位 大家可不要用这个东东用在QQ MSN等聊天软件上欺骗MM或GG啊

    关于摄像头编程 大家也可以看看这组VCL组件 DSPack DSPack是一套使用微软Direct Show和DirectX技术的类和组件 设计工作于DirectX 支持系统Win X ME 和Windows XP

lishixinzhi/Article/program/Delphi/201311/24709

这些都是当前单元文件使用的其它单元文件名称,编译运行时,编译器在默认的路径中,找不到这些文件才出错。你大概打开的是别人的源码吧,多半是别人给你的系列单元文件中,不包含这些文件。现在唯一的办法是1,在本机上用系统搜索来搜一下,看看是不放在别的文件夹中了;2、在你下载这源码的网站找一下;3,丢了他们,没有用的。


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/44795.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-02-23
下一篇2023-02-23

发表评论

登录后才能评论

评论列表(0条)

    保存