Autor |
Beitrag |
Phil511
      
Beiträge: 27
|
Verfasst: Do 15.05.08 22:05
Hi,
Ich suche einen weg das Ich Bilder von meiner Webcam auslese und wenn ich einen Button drücke das Bild abspeichere.
Nun nach Suche im Forum hab einen Quelltext gefunden mit dem Ich das Bild meiner Webcam in einen Panel anzeigen kann.
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:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; const WM_CAP_DRIVER_CONNECT = WM_USER + 10; WM_CAP_EDIT_COPY = WM_USER + 30; WM_CAP_SET_PREVIEW = WM_USER + 50; WM_CAP_SET_OVERLAY = WM_USER + 51; WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function capCreateCaptureWindow(lpszWindowName: LPCSTR; dwStyle: DWORD; x, y, nWidth, nHeight: integer; hwndParent: HWND; nID: integer): HWND; stdcall; external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';
procedure TForm1.Button1Click(Sender: TObject); var handle:THandle; begin handle := capCreateCaptureWindow('Video',ws_child+ws_visible, 0, 0, 320, 240, Panel1.Handle, 1); SendMessage(handle, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(handle, WM_CAP_SET_PREVIEWRATE, 30, 0); sendMessage(handle, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(handle, wm_cap_set_preview, 1, 0); end;
end. |
Ich habe denn Quelltext hier im Forum gefunden, weiß aber leider nicht was da genau vor sich geht könnte vlt irgendwer ein paar Worte dazu sagen. Wäre nett.
Aber meine nächste Frage wäre wie ich da aktuelle Bild abspeichern kann.
Bitte auch hier wenn irgendwer nen Quelltext postet bitte mit ein paar Kommentaren versehen das ich das auch verstehe was da vorsich geht.
Danke im Vorraus.
mfg.Philipp
Moderiert von UGrohne: Quote- durch Delphi-Tags ersetzt
|
|
chrisdrury
      
Beiträge: 184
WinXP
D5 Prof
|
Verfasst: Fr 16.05.08 07:17
|
|
Phil511 
      
Beiträge: 27
|
Verfasst: Fr 16.05.08 14:03
Zuerst einmal Danke.
Das Problem jedoch ist das sich das Programm starten lässt, wenn ich jedoch speichert er das Bild nicht!
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:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; const WM_CAP_DRIVER_CONNECT = WM_USER + 10; WM_CAP_EDIT_COPY = WM_USER + 30; WM_CAP_SET_PREVIEW = WM_USER + 50; WM_CAP_SET_OVERLAY = WM_USER + 51; WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); function SaveWebcamPictureDIB(pFileName: PChar;WebcamHandle: THandle):Boolean; procedure Button2Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
function capCreateCaptureWindow(lpszWindowName: LPCSTR; dwStyle: DWORD; x, y, nWidth, nHeight: integer; hwndParent: HWND; nID: integer): HWND; stdcall; external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';
procedure TForm1.Button1Click(Sender: TObject); var handle:THandle; begin handle := capCreateCaptureWindow('Video',ws_child+ws_visible, 0, 0, 320, 240, Panel1.Handle, 1); SendMessage(handle, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(handle, WM_CAP_SET_PREVIEWRATE, 30, 0); sendMessage(handle, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(handle, wm_cap_set_preview, 1, 0); end;
function Tform1.SaveWebcamPictureDIB(pFileName: PChar;WebcamHandle: THandle):Boolean; const WM_CAP_FILE_SAVEDIB = WM_USER + 25; begin if IsWindow(WebcamHandle) then result := (SendMessage(WebcamHandle,WM_CAP_FILE_SAVEDIB,0,LPARAM(pFileName)) <> 0) else result := false; end;
procedure TForm1.Button2Click(Sender: TObject); begin SaveWebcamPictureDIB(PChar('C:\test.jpg'),Panel1.Handle); end;
end. |
|
|
|