能够播放出来的就行了的摄像头控件,我们急用!

解决方案 »

  1.   

    如果只要显示,不需要控件,主要是使用windows自己带的AviCap32.DLL,以下是例子,在Panel1上显示摄像头数据unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        OpenVideo: TButton;
        CloseVideo: TButton;
        GrabFrame: TButton;
        procedure FormCreate(Sender: TObject);
        procedure OpenVideoClick(Sender: TObject);
        procedure CloseVideoClick(Sender: TObject);
        procedure GrabFrameClick(Sender: TObject);
      private
        { Private declarations }
       hWndC : THandle;
       CapturingAVI : bool;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationconst WM_CAP_START                  = WM_USER;
    const WM_CAP_STOP                  = WM_CAP_START + 68;
    const WM_CAP_DRIVER_CONNECT        = WM_CAP_START + 10;
    const WM_CAP_DRIVER_DISCONNECT      = WM_CAP_START + 11;
    const WM_CAP_SAVEDIB                = WM_CAP_START + 25;
    const WM_CAP_GRAB_FRAME            = WM_CAP_START + 60;
    const WM_CAP_SEQUENCE              = WM_CAP_START + 62;
    const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START +  20;function capCreateCaptureWindowA(lpszWindowName : PCHAR;
                                     dwStyle : longint;
                                     x : integer;
                                     y : integer;
                                     nWidth : integer;
                                     nHeight : integer;
                                     ParentWin  : HWND;
                                     nId : integer): HWND;
                                     STDCALL EXTERNAL 'AVICAP32.DLL';{$R *.dfm}
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      hWndC := 0;
    end;procedure TForm1.OpenVideoClick(Sender: TObject);
    // 打开视频窗口
    begin
      hWndC := capCreateCaptureWindowA('自己的显示窗口',
                                       WS_CHILD or WS_VISIBLE ,
                                       Panel1.Left,
                                       Panel1.Top,
                                       Panel1.Width,
                                       Panel1.Height,
                                       Form1.Handle,
                                       0);
      if hWndC <> 0 then
       SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
    end;procedure TForm1.CloseVideoClick(Sender: TObject);
    // 关闭视频窗口
    begin
      if hWndC <> 0 then begin
       SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
       hWndC := 0;
       end;
    end;procedure TForm1.GrabFrameClick(Sender: TObject);
    // 拍照(一张)
    begin
      if hWndC <> 0 then
       SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0);
    end;end.
      

  2.   

    huangxw:你好!
       今天我试了下你提供的代码,其中开始事件,不能播放阿.请给予进一步指教,不胜感激!
    能否提供一下capCreateCaptureWindowA函数中各个参数的解释吗?
    谢谢!