La Web del Programador: Comunidad de Programadores
 
    Pregunta:  59734 - CAPTURAR Y GUARDAR UNA FOTO DESDE UNA CAMARA WEB
Autor:  luzwin zavala
hola, tengo un problema ... quiero capturar una foto tomada de un camara web desde power builder 10.0 y mandarlo directamente a la base de datos q esta en sql 2000... y que la foto se redimencione a un tamaño espesifico al momento de tomarla ... digamos tamaño carnet ... no se como hacerlo... derrepente tengo q usar algun dll o api o algunas funciones especiales ya q quisiera q esto se pueda hacer a cualquier lugar donde lleve mi aplicacion con cualquier camara ... de antemano muchas gracias por atender mi consulta ... gracias.

  Respuesta:  Alejandro Gomez
Como estas Luzwin, yo estoy tratando de hacer lo mismo y por lo que he averiguado existe una funcion api para hacer esto..pero no he logrado que funcione bien.. este es el codigo:

//Local external function
function ulong capCreateCaptureWindowA(string lpszWindowName,ulong dwStyle,long li_x ,long li_y ,long nWidth ,long nHeight ,ulong ParentWin ,long nId ) LIBRARY 'AVICAP32.DLL'

//Instance Variables
Uint lhand
Constant long GET_FRAME = 1084
Constant long COPY = 1054
Constant long WM_USER = 1024
Constant long WM_CAP_START = WM_USER
Constant long WM_CAP_STOP = WM_CAP_START + 68
Constant long WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Constant long WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
Constant long WM_CAP_SAVEDIB = WM_CAP_START + 25
Constant long WM_CAP_GRAB_FRAME = WM_CAP_START + 60
Constant long WM_CAP_SEQUENCE = WM_CAP_START + 62
Constant long WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20
Constant long WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63
Constant long WM_CAP_SET_OVERLAY =WM_CAP_START+ 51
Constant long WM_CAP_SET_PREVIEW =WM_CAP_START+ 50
Constant long WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6
Constant long WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2
Constant long WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3
Constant long WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5
Constant long WM_CAP_SET_SCALE=WM_CAP_START+ 53
Constant long WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52

Long wm_cap_savedatdib = 1049
Long wm_cap_dlg_videoformat = 1065
Long wm_cap_dlg_videosource = 1066
Long wm_cap_dlg_videodisplay = 1067
Long wm_cap_get_videoformat = 1068
Long wm_cap_set_videoformat = 1069
Long wm_cap_dlg_videocompression = 1070
Long cf_bitmap = 2
Long wm_close = 16
Ulong scrcopy = 32
string gs_pic_path
string gs_cd_path
string gs_path
string gs_ds_pic
string gs_ds_cd
string gs_cd_rq
long gl_pic_sj = 0

//Boton inicia camara

string lpszName
ulong l1
l1=handle(parent)

lpszName='webcam.'
lhand=capCreateCaptureWindowA(lpszName,262144+12582912+1073741824 + 268435456 ,10,10,200,200,l1,0)
if lhand <> 0 then
send(lhand, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
send(lhand, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)

send(lhand, WM_CAP_DRIVER_CONNECT, 0, 0)
send(lhand, WM_CAP_SET_SCALE, 1, 0)
send(lhand,WM_CAP_GRAB_FRAME, 0, 0)
Send(lhand, WM_CAP_SAVEDIB, 0, 0)
send(lhand, WM_CAP_SET_PREVIEWRATE, 66, 0)
send(lhand, WM_CAP_SET_OVERLAY, 1, 0)
send(lhand, WM_CAP_SET_PREVIEW, 1, 0)
end if

//boton grabar imagen
string s_map
s_map='c:save.bmp'
if FileExists(s_map) then FileDelete(s_map)
if lhand <> 0 then

Send(lhand,WM_CAP_FILE_SET_CAPTURE_FILEA,0,s_map);
p_2.visible = true
st_1.visible = false
p_1.picturename = s_map
SendMessage(lhand, WM_CAP_DRIVER_DISCONNECT, 0, 0)
lhand =0
this.enabled = false
cb_1.enabled = true
end if

//Boton captura video
string s
s='c:save.avi'
if lhand <>0 then
Send(lhand,WM_CAP_FILE_SET_CAPTURE_FILEA,0, s);
Send(lhand,WM_CAP_SEQUENCE, 0, 0)
end if

Ojala te sirva de algo..si tu lo lograste hacer funcionar..te agradeceria que me indcaras como hacerlo..mi correo es [email protected]

saludos.