Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Captura de imagen de la webcam (https://www.clubdelphi.com/foros/showthread.php?t=66780)

webon 11-03-2010 23:24:04

Captura de imagen de la webcam
 
Buenas compañeros!
Tengo un problema para capturar la imagen de la webcam y almacenarla en la base de datos.
Esto es lo que tengo.

La base de datos esta en Acces 2007 y se llama Foto. Tiene una unica tabla que se llama tabla1 y el campo donde se almacena la imagen se llama bd_imagen que es tipo "Datos adjuntos".

Tengo una forma con los siguientes objetos
Image1 = donde cargo la webcam
Button1 = ejecuto la webcam
Button2 = Cancelo la webcam
Button3 = Capturo la imagen para guardarla en la base de datos.

Este es el codigo que tengo

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;
WM_CAP_EDIT_COPY = WM_CAP_START + 30;
WM_CAP_SET_PREVIEW = WM_CAP_START + 50;
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52;


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.Button1Click(Sender: TObject);
begin
Ventana := capCreateCaptureWindowA('Ventana de captura',
WS_CHILD or WS_VISIBLE, image1.Left, image1.Top, image1.Width,
image1.Height, form1.Handle, 0);
if Ventana <> 0 then
begin
try
SendMessage(Ventana, WM_CAP_DRIVER_CONNECT, 0, 0);
SendMessage(Ventana, WM_CAP_SET_PREVIEWRATE, 40, 0);
SendMessage(Ventana, WM_CAP_SET_PREVIEW, 1, 0);
except
raise;
end;
end
else
begin
MessageDlg('Error al conectar Webcam', mtError, [mbok], 0);
end;
end;


__________________________________________
procedure TForm1.Button2Click(Sender: TObject);
begin
if Ventana <> 0 then
begin
SendMessage(Ventana, WM_CAP_DRIVER_DISCONNECT, 0, 0);
Ventana := 0;
end;
end;


__________________________________________
EN ESTE ES QUE TENGO EL PROBLEMA
__________________________________________
procedure TForm1.Button3Click(Sender: TObject);
var
Stream: TStringStream;

begin
Stream := TStringStream.Create('');
try
Image1.Picture.Graphic.SaveToStream(Stream);
ADOTable1.Append;
AdoTable1.FieldByName('id').AsString := '002';
AdoTable1.FieldByName('bd_imagen').AsString := Stream.DataString;
AdoTable1.Post;
finally
Stream.Free;
end;
end;

El problema que tengo en la captura de la imagen si me pueden ayudar les agradeceria mucho, soy novato en delphi y quiero aprender.

Casimiro Notevi 12-03-2010 00:13:06

Justo abajo, al final de esta página, encontrarás varios enlaces que seguramente te solucionarán el problema :)

webon 12-03-2010 03:48:55

Gracias
 
Te agradesco por tratar de ayudarme, voy a revisarlo, espero que me sea de mucha utilidad


La franja horaria es GMT +2. Ahora son las 01:58:56.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi