La Web del Programador: Comunidad de Programadores
 
    Pregunta:  50767 - CAPTURAR Y MANIPULAR VIDEO DE WEB CAM EN PB
Autor:  Christian Barrios Tolosa
Que tal jovenes,

Quisiera saber si alguien ha podido capturar y manipular video de una web cam en power builder. Es para una aplicacion que estoy haciendo en mi empresa y necesito obtener el video de una camara y capturar la fotografia del empleado al momento del ingreso al establecimiento.

La camara es conenectada por USB. Si alguno tiene la respuesta le agradecere muchisimo.

  Respuesta:  Alejandro Gomez
Cristian , como estas, sabes existe una funcion api para capturar imagenes, yo lo he intentado pero no he logrado aun que guarde las imagenes .

//Local external functions.
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 iniciar 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...podrias enviarme tu correo para discutir del tema.
saludos