Fórum Webcam em Delphi #398903
08/04/2011
0
Olá amigos.
Estava tomando uma surra para capturar imagens via webcam.Segue abaixo o que funcionou para mim.
Espero ter colaborado.
Alexandre___________________________________________________________________
var
HwebCam: HWND;
function capCreateCaptureWindowA(lpszWindowName: pchar; dwStyle: dword; x, y, nWidth, nHeight: word; ParentWin: dword; nId: word): dword; stdcall external 'avicap32.dll';
implementation
Function CapturarWebCam(DestinoCapBMP:string) : Boolean;
const
WM_WEBCAM = $400;
WM_CONECTAR_DRIVER_WEBCAM = WM_WEBCAM + $a;
WM_DESCONECTAR_DRIVER_WEBCAM = WM_WEBCAM + $b;
WM_GUARDAR_CAPTURA = WM_WEBCAM + 25;
WM_FECHAR_WEBCAM = $0010;
begin
if HwebCam = 0 then
begin //WS_CHILD //WS_VISIBLE
HwebCam := capCreateCaptureWindowA('CaptureWindow', $40000000 and $10000000, 0, 0, 0, 0, GetDesktopWindow, 0);
if SendMessage(HwebCam, WM_CONECTAR_DRIVER_WEBCAM, 0, 0) <> 1 then
begin
HwebCam := 0;
Result := False;
end else begin
SendMessage(HwebCam, WM_GUARDAR_CAPTURA, wparam(0), lparam(PChar(DestinoCapBMP)));
SendMessage(HwebCam, WM_FECHAR_WEBCAM, 0, 0);
SendMessage(HwebCam, WM_FECHAR_WEBCAM, 0, 0);
HwebCam := 0;
Result := True;
end;
end else
Result := False;
end;
Procedure Capturar;
Const
Captura = 'C:\Users\Joel\Desktop\WebCam Captura.bmp';
begin
if not CapturarWebCam(Captura) then
MessageBox(0,Pchar('Não foi possivél capturar a webcam'#10':('),'Erro',16);
end;
Estava tomando uma surra para capturar imagens via webcam.Segue abaixo o que funcionou para mim.
Espero ter colaborado.
Alexandre___________________________________________________________________
var
HwebCam: HWND;
function capCreateCaptureWindowA(lpszWindowName: pchar; dwStyle: dword; x, y, nWidth, nHeight: word; ParentWin: dword; nId: word): dword; stdcall external 'avicap32.dll';
implementation
Function CapturarWebCam(DestinoCapBMP:string) : Boolean;
const
WM_WEBCAM = $400;
WM_CONECTAR_DRIVER_WEBCAM = WM_WEBCAM + $a;
WM_DESCONECTAR_DRIVER_WEBCAM = WM_WEBCAM + $b;
WM_GUARDAR_CAPTURA = WM_WEBCAM + 25;
WM_FECHAR_WEBCAM = $0010;
begin
if HwebCam = 0 then
begin //WS_CHILD //WS_VISIBLE
HwebCam := capCreateCaptureWindowA('CaptureWindow', $40000000 and $10000000, 0, 0, 0, 0, GetDesktopWindow, 0);
if SendMessage(HwebCam, WM_CONECTAR_DRIVER_WEBCAM, 0, 0) <> 1 then
begin
HwebCam := 0;
Result := False;
end else begin
SendMessage(HwebCam, WM_GUARDAR_CAPTURA, wparam(0), lparam(PChar(DestinoCapBMP)));
SendMessage(HwebCam, WM_FECHAR_WEBCAM, 0, 0);
SendMessage(HwebCam, WM_FECHAR_WEBCAM, 0, 0);
HwebCam := 0;
Result := True;
end;
end else
Result := False;
end;
Procedure Capturar;
Const
Captura = 'C:\Users\Joel\Desktop\WebCam Captura.bmp';
begin
if not CapturarWebCam(Captura) then
MessageBox(0,Pchar('Não foi possivél capturar a webcam'#10':('),'Erro',16);
end;
Alexandre
Curtir tópico
+ 0
Responder
Posts
18/04/2011
Marcos Paulo
Olá amigo, nao entendi como vc manipula essa função.
Nesta função aqui, o que devo passar? E como passar?
Function CapturarWebCam(DestinoCapBMP:string) : Boolean;
O Destino onde quero salvar o arquivo?To tentando passar assim: C:\TesteWebCan.
Nome da pasta ai no caso. È assim mesmo que devo fazer?
Tem como nesta mesma função, eu mostrar a imagem da WebCan antes de fotografar?
Te mais.
Nesta função aqui, o que devo passar? E como passar?
Function CapturarWebCam(DestinoCapBMP:string) : Boolean;
O Destino onde quero salvar o arquivo?To tentando passar assim: C:\TesteWebCan.
Nome da pasta ai no caso. È assim mesmo que devo fazer?
Tem como nesta mesma função, eu mostrar a imagem da WebCan antes de fotografar?
Te mais.
Responder
Gostei + 0
19/04/2011
Alexandre
Olá amigo...
Bom dia...
Eu estava usando essa função, mas achei algo bem melhor com um componente nativo do Delphi7
Baixe esse componente TScap32 no link: http://tscap32.sourceforge.net/
Tem um exemplo em Delphi7 já pronto.
Mas antes de rodar o exemplo, instale o componente.
O diver original da sua webcam, vc deixa instalado.
Ao rodar o executável que vem como exemplo nesse link, vc vai ver que está tudo bem "mastigado", fácil de entender.
QQ coisa, meu email é mecpobox@gmail.com
Boa sorte.
Espero ter ajudado.
Bom dia...
Eu estava usando essa função, mas achei algo bem melhor com um componente nativo do Delphi7
Baixe esse componente TScap32 no link: http://tscap32.sourceforge.net/
Tem um exemplo em Delphi7 já pronto.
Mas antes de rodar o exemplo, instale o componente.
O diver original da sua webcam, vc deixa instalado.
Ao rodar o executável que vem como exemplo nesse link, vc vai ver que está tudo bem "mastigado", fácil de entender.
QQ coisa, meu email é mecpobox@gmail.com
Boa sorte.
Espero ter ajudado.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)