Bonjour
J'ai un PC muni d'une webcam intégrée et d'une autre connectée sur un port Usb. Je voulais développer une application où je récupère une image de ces caméras.
J'ai utilisé ce code mais le seul résultat que j'ai est un ecran noir si quelqu'un aurait une idée je lui saurai gré de me donner un coup de pouce
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
private
{ Private declarations }
hWndC : THandle;
CapturingAVI : bool;
Public
*** { Public declarations }
end;
 
var
 Form1: TForm1;
implementation

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{$R *.DFM}
 
const 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';
 
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.GrabFrameClick(Sender: TObject);
begin
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0);
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;
 
end