1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form2: TForm2;
Bmp1, Bmp2: TBitmap;
HCam: hwnd;
Num, NbMouvement: Integer;
Debut: Boolean;
MaxSensi: Integer;
image: Integer;
// Formats: Tformats;
enregistrement: Boolean;
Function capCreateCaptureWindowA(lpszWindowName: String; dwStyle: Integer;
X: Integer; Y: Integer; nWidth: Integer; nHeight: Integer; hwndParent: hwnd;
nID: Integer): Integer; stdcall; external 'C:\windows\system32\avicap32.dll';
implementation
{$R *.dfm}
const
WM_CAP_START = 1024;
WM_CAP_DRIVER_CONNECT = 1034; //pour savoir si la webcam est connecté
WM_CAP_GRAB_FRAME =1084; //pour povoir previsualiser la webcam
WM_CAP_EDIT_COPY =1054; //pour copier l//image de la webcam, mais ici ca ne marche pas car on affiche un prwiev de la webcam grace a u copier coller (si vous trouvez autre chose pour le preview ca marche super)
WM_CAP_DRIVER_DISCONNECT = 1035; //pour savoir si la webcam est pas connectée
WM_CAP_SEQUENCE = 1086; //pour la capture AVI
WM_CAP_GET_SEQUENCE_SETUP = 1089; //sais pas
WM_CAP_SET_SEQUENCE_SETUP = 1088; //sais pas
WM_CAP_FILE_SET_CAPTURE_FILE = 1044; //pour changer le chemin de destination du fichier AVI
WM_CAP_DLG_VIDEOSOURCE = 1066; //pour afficher les parametre
WM_CAP_FILE_SAVEAS = 1047; //pour enregistrer dans un fichier specifier
WM_CAP_STOP = 1092; //pour arreter la capture
procedure TForm2.FormCreate(Sender: TObject);
var retour : Integer;
begin
HCam := capCreateCaptureWindowA('', WS_CHILD or WS_VISIBLE, 2, 2, Panel1.Width-4, Panel1.Height-4,Panel1.handle, 0);
retour:=sendmessage(HCam, WM_CAP_DRIVER_CONNECT, 0, 0); //fOK = SendMessage (hWndC, WM_CAP_DRIVER_CONNECT, 0, 0L);
sendmessage(HCam, WM_CAP_START, 0, 0);
end;
end. |
Partager