找传奇、传世资源到传世资源站!

视频采集(摄像头录像)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】视频采集

实现了程序获取摄像头并进行录像保存AVI

【相关图片】

from clipboard

【源码结构】const
  WM_CAP_START = WM_USER;
  WM_CAP_STOP = WM_CAP_START 68;
  WM_CAP_DRIVER_CONNECT = WM_CAP_START 10;
  WM_CAP_DRIVER_DISCONNECT = WM_CAP_START 11;
  WM_CAP_SAVEDIB = WM_CAP_START 25;
  WM_CAP_GRAB_FRAME = WM_CAP_START 60;
  WM_CAP_SEQUENCE = WM_CAP_START 62;
  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';

procedure TForm1.FormCreate(Sender: TObject);
begin
  CapturingAVI := false;
  hWndC := 0;
  SaveDialog1.Options :=
    [ofHideReadOnly, ofNoChangeDir, ofPathMustExist]
end;

procedure TForm1.OpenVideoClick(Sender: TObject);
begin
  hWndC := capCreateCaptureWindowA('My Own Capture Window',
    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.SaveBMPClick(Sender: TObject);
begin
  if hWndC <> 0 then begin
      SaveDialog1.DefaultExt := 'bmp';
      SaveDialog1.Filter := 'Bitmap files (*.bmp)|*.bmp';
      if SaveDialog1.Execute then
        SendMessage(hWndC,
          WM_CAP_SAVEDIB,
          0,
          longint(pchar(SaveDialog1.FileName)));
    end;
end;

procedure TForm1.StartAVIClick(Sender: TObject);
begin
  if hWndC <> 0 then begin
      SaveDialog1.DefaultExt := 'avi';
      SaveDialog1.Filter := 'AVI files (*.avi)|*.avi';
      if SaveDialog1.Execute then begin
          CapturingAVI := true;
          SendMessage(hWndC,
            WM_CAP_FILE_SET_CAPTURE_FILEA,
            0,
            Longint(pchar(SaveDialog1.FileName)));
          SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
        end;
    end;
end;

procedure TForm1.StopAVIClick(Sender: TObject);
begin
  if hWndC <> 0 then begin
      SendMessage(hWndC, WM_CAP_STOP, 0, 0);
      CapturingAVI := false;
    end;
end;

procedure TForm1.GrabFrameClick(Sender: TObject);
begin
  if hWndC <> 0 then
    SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0);
end;

end.
.
├── 视频采集
│   ├── AVICap.dcu
│   ├── AVICap.pas
│   ├── AVICapH.dcu
│   ├── AVICapH.pas
│   ├── D
│   ├── Project1.cfg
│   ├── Project1.dof
│   ├── Project1.dpr
│   ├── Project1.dproj
│   ├── Project1.dproj.local
│   ├── Project1.exe
│   ├── Project1.identcache
│   ├── Project1.res
│   ├── Project1.stat
│   ├── Project1_Icon.ico
│   ├── Unit1.dcu
│   ├── Unit1.ddp
│   ├── Unit1.dfm
│   └── Unit1.pas
└── 5t6t网_视频采集.zip

1 directory, 20 files

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复