Home » Developer & Programmer » Forms » Capturing video web cam using API
Capturing video web cam using API [message #426534] |
Fri, 16 October 2009 07:09 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
lancer26
Messages: 52 Registered: May 2006 Location: Pakistan
|
Member |
![a_hameed4umr](/forum/theme/orafaq/images/yahoo.png)
|
|
respected member, i want to capture video using webcam through developer 6i. i m using ora_ffi package. my package specs are:
PACKAGE CAM IS
WM_CAP CONSTANT PLS_INTEGER := 1024; -- EQUALS TO '&H400S'
WM_CAP_DRIVER_CONNECT CONSTANT INTEGER := WM_CAP + 10;
WM_CAP_DRIVER_DISCONNECT CONSTANT INTEGER := WM_CAP + 11;
WM_CAP_EDIT_COPY CONSTANT INTEGER := WM_CAP + 30;
WM_CAP_GET_STATUS CONSTANT INTEGER := WM_CAP + 54;
WM_CAP_DLG_VIDEOFORMAT CONSTANT INTEGER := WM_CAP + 41;
WM_CAP_SET_PREVIEW CONSTANT INTEGER := WM_CAP + 50;
WM_CAP_SET_PREVIEWRATE CONSTANT INTEGER := WM_CAP + 52;
WM_CAP_SET_SCALE CONSTANT INTEGER := WM_CAP + 53;
WS_CHILD CONSTANT INTEGER := 1073741824; -- EQUALS TO '&H40000000'
WS_VISIBLE CONSTANT INTEGER := 268435456; -- EQUALS TO '&H10000000'
SWP_NOMOVE CONSTANT PLS_INTEGER := 2; -- EQUALS TO '&H2S'
SWP_NOSIZE CONSTANT PLS_INTEGER := 1;
SWP_NOZORDER CONSTANT PLS_INTEGER := 4; -- EQUALS TO '&H4S'
HWND_BOTTOM CONSTANT PLS_INTEGER := 1;
hHwnd PLS_INTEGER;
TYPE POINTAPI IS RECORD(
X INTEGER,
Y INTEGER
);
TYPE CAPSTATUS IS RECORD(
UIIMAGEWIDTH INTEGER , -- Width of the image
UIIMAGEHEIGHT INTEGER , -- Height of the image
FLIVEWINDOW INTEGER , -- Now Previewing video?
FOVERLAYWINDOW INTEGER , -- Now Overlaying video?
FSCALE INTEGER , -- Scale image to client?
PTSCROLL POINTAPI , -- Scroll position
FUSINGDEFAULTPALETTE INTEGER , -- Using default driver palette?
FAUDIOHARDWARE INTEGER , -- Audio hardware present?
FCAPFILEEXISTS INTEGER , -- Does capture file exist?
DWCURRENTVIDEOFRAME INTEGER , -- # of video frames cap'td
DWCURRENTVIDEOFRAMEDROPPED INTEGER , -- # of video frames dropped
DWCURRENTWAVESAMPLES INTEGER , -- # of wave samples cap'td
DWCURRENTTIMEELAPSEDMS INTEGER , -- Elapsed capture duration
HPALCURRENT INTEGER , -- Current palette in use
FCAPTURINGNOW INTEGER , -- Capture in progress?
DWRETURN INTEGER , -- Error value after any operation
WNUMVIDEOALLOCATED INTEGER , -- Actual number of video buffers
WNUMAUDIOALLOCATED INTEGER -- Actual number of audio buffers
);
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM CAPSTATUS) RETURN BOOLEAN;
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM BOOLEAN,LPARAM INTEGER) RETURN BOOLEAN;
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM INTEGER) RETURN BOOLEAN;
FUNCTION SETWINDOWPOS(HWND INTEGER,HWNDINSERTAFTER INTEGER,X INTEGER,Y INTEGER,CX INTEGER,CY INTEGER,WFLAGS INTEGER) RETURN INTEGER;
FUNCTION DESTROYWINDOW(HWND INTEGER) RETURN BOOLEAN;
FUNCTION CAPCREATECAPTUREWINDOWA(LPSZWINDOWNAME VARCHAR2,DWSTYLE INTEGER,X INTEGER,Y INTEGER,NWIDTH INTEGER,NHEIGHT INTEGER,HWNDPARENT INTEGER,NID INTEGER) RETURN PLS_INTEGER;
FUNCTION CAPGETDRIVERDESCRIPTIONA(WDRIVER INTEGER,LPSZNAME VARCHAR2,CBNAME INTEGER,LPSZVER VARCHAR2,CBVER INTEGER) RETURN BOOLEAN;
END;
package body are:
PACKAGE BODY CAM IS
/* Declare the library and function handles. */
USER_LIB_HANDLE ORA_FFI.LIBHANDLETYPE;
AVCP_LIB_HANDLE ORA_FFI.LIBHANDLETYPE;
FH_SM1 ORA_FFI.FUNCHANDLETYPE;
FH_SM2 ORA_FFI.FUNCHANDLETYPE;
FH_SM3 ORA_FFI.FUNCHANDLETYPE;
FH_SWP ORA_FFI.FUNCHANDLETYPE;
FH_DW ORA_FFI.FUNCHANDLETYPE;
FH_CPW ORA_FFI.FUNCHANDLETYPE;
FH_GDD ORA_FFI.FUNCHANDLETYPE;
/* Create the PL/SQL function that will actually invoke the foreign function. */
FUNCTION FF_SENDMESSAGE1(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM CAPSTATUS) RETURN BOOLEAN;
FUNCTION FF_SENDMESSAGE2(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER,WMSG INTEGER,WPARAM BOOLEAN,LPARAM INTEGER) RETURN BOOLEAN;
FUNCTION FF_SENDMESSAGE3(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM INTEGER) RETURN BOOLEAN;
FUNCTION FF_SETWINDOWPOS(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER,HWNDINSERTAFTER INTEGER,X INTEGER,Y INTEGER,CX INTEGER,CY INTEGER,WFLAGS INTEGER) RETURN INTEGER;
FUNCTION FF_DESTROYWINDOW(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER) RETURN BOOLEAN;
FUNCTION FF_CAPCREATECAPTUREWINDOWA(FHANDLE ORA_FFI.FUNCHANDLETYPE,LPSZWINDOWNAME VARCHAR2,DWSTYLE INTEGER,X INTEGER,Y INTEGER,NWIDTH INTEGER,NHEIGHT INTEGER,HWNDPARENT INTEGER,NID INTEGER) RETURN INTEGER;
FUNCTION FF_CAPGETDRIVERDESCRIPTIONA(FHANDLE ORA_FFI.FUNCHANDLETYPE,WDRIVER INTEGER,LPSZNAME VARCHAR2,CBNAME INTEGER,LPSZVER VARCHAR2,CBVER INTEGER) RETURN BOOLEAN;
PRAGMA INTERFACE(C,FF_SENDMESSAGE1, 11265);
PRAGMA INTERFACE(C,FF_SENDMESSAGE2, 11265);
PRAGMA INTERFACE(C,FF_SENDMESSAGE3, 11265);
PRAGMA INTERFACE(C,FF_SETWINDOWPOS, 11265);
PRAGMA INTERFACE(C,FF_DESTROYWINDOW, 11265);
PRAGMA INTERFACE(C,FF_CAPCREATECAPTUREWINDOWA, 11265);
PRAGMA INTERFACE(C,FF_CAPGETDRIVERDESCRIPTIONA,11265);
-------------------------------------------------------------------------------------------------------------------
/* Create the PL/SQL function that is defined in the package spec.This function simply passes along the arguments */
/* it receives to ff_XXXXX (defined above), prepending the foreign function handle to the argument List. */
-------------------------------------------------------------------------------------------------------------------
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM CAPSTATUS) RETURN BOOLEAN IS
BEGIN
RETURN (FF_SENDMESSAGE1(FH_SM1,HWND,WMSG,WPARAM,LPARAM));
END SENDMESSAGE;
-------------------------------------------------------------------------------------------------------------------
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM BOOLEAN,LPARAM INTEGER) RETURN BOOLEAN IS
BEGIN
RETURN (FF_SENDMESSAGE2(FH_SM2,HWND,WMSG,WPARAM,LPARAM));
END SENDMESSAGE;
-------------------------------------------------------------------------------------------------------------------
FUNCTION SENDMESSAGE(HWND INTEGER,WMSG INTEGER,WPARAM INTEGER,LPARAM INTEGER) RETURN BOOLEAN IS
BEGIN
RETURN (FF_SENDMESSAGE3(FH_SM3,HWND,WMSG,WPARAM,LPARAM));
END SENDMESSAGE;
------------------------------------------------------------------------------------------------------------------
FUNCTION SETWINDOWPOS(HWND INTEGER,HWNDINSERTAFTER INTEGER,X INTEGER,Y INTEGER,CX INTEGER,CY INTEGER,WFLAGS INTEGER) RETURN INTEGER IS
BEGIN
RETURN (FF_SETWINDOWPOS(FH_SWP,HWND,HWNDINSERTAFTER,X,Y,CX,CY,WFLAGS));
END SETWINDOWPOS;
------------------------------------------------------------------------------------------------------------------
FUNCTION DESTROYWINDOW(HWND INTEGER) RETURN BOOLEAN IS
BEGIN
RETURN (FF_DESTROYWINDOW(FH_DW,HWND));
END DESTROYWINDOW;
------------------------------------------------------------------------------------------------------------------
FUNCTION CAPCREATECAPTUREWINDOWA(LPSZWINDOWNAME VARCHAR2,DWSTYLE INTEGER,X INTEGER,Y INTEGER,NWIDTH INTEGER,NHEIGHT INTEGER,HWNDPARENT INTEGER,NID INTEGER) RETURN PLS_INTEGER IS
BEGIN
RETURN (FF_CAPCREATECAPTUREWINDOWA(FH_CPW,LPSZWINDOWNAME,DWSTYLE,X,Y,NWIDTH,NHEIGHT,HWNDPARENT,NID));
END CAPCREATECAPTUREWINDOWA;
------------------------------------------------------------------------------------------------------------------
FUNCTION CAPGETDRIVERDESCRIPTIONA(WDRIVER INTEGER,LPSZNAME VARCHAR2,CBNAME INTEGER,LPSZVER VARCHAR2,CBVER INTEGER) RETURN BOOLEAN IS
BEGIN
RETURN (FF_CAPGETDRIVERDESCRIPTIONA(FH_GDD,WDRIVER,LPSZNAME,CBNAME,LPSZVER,CBVER));
END CAPGETDRIVERDESCRIPTIONA;
------------------------------------------------------------------------------------------------------------------
/* Define the body of package mathlib */
BEGIN
/* Load the library. */
USER_LIB_HANDLE := ORA_FFI.LOAD_LIBRARY('C:\WINDOWS\SYSTEM32\', 'USER32.DLL');
AVCP_LIB_HANDLE := ORA_FFI.LOAD_LIBRARY('C:\WINDOWS\SYSTEM32\', 'AVICAP32.DLL');
/* Register the foreign function. */
FH_SM1 := ORA_FFI.REGISTER_FUNCTION(USER_LIB_HANDLE,'SendMessageA',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_SM1,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM1,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM1,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM1,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_SM1,ORA_FFI.C_INT);
/* Register the foreign function. */
FH_SM2 := ORA_FFI.REGISTER_FUNCTION(USER_LIB_HANDLE,'SendMessageA',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_SM2,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM2,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM2,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM2,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_SM2,ORA_FFI.C_INT);
/* Register the foreign function. */
FH_SM3 := ORA_FFI.REGISTER_FUNCTION(USER_LIB_HANDLE,'SendMessageA',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_SM3,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM3,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM3,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SM3,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_SM3,ORA_FFI.C_INT);
/* Register the foreign function. */
FH_SWP := ORA_FFI.REGISTER_FUNCTION(USER_LIB_HANDLE,'SetWindowPos',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_SWP,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_SWP,ORA_FFI.C_INT);
--DESTROYWINDOW(FHANDLE ORA_FFI.FUNCHANDLETYPE,HWND INTEGER) RETURN BOOLEAN;
/* Register the foreign function. */
FH_DW := ORA_FFI.REGISTER_FUNCTION(USER_LIB_HANDLE,'DestroyWindow',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_DW,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_DW,ORA_FFI.C_INT);
/* Register the foreign function. */
FH_CPW := ORA_FFI.REGISTER_FUNCTION(AVCP_LIB_HANDLE,'capCreateCaptureWindowA',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_CHAR);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_LONG);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_CPW,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_CPW,ORA_FFI.C_INT);
/* Register the foreign function. */
FH_GDD := ORA_FFI.REGISTER_FUNCTION(AVCP_LIB_HANDLE,'capGetDriverDescriptionA',ORA_FFI.C_STD);
/* Register all parameters of function . */
ORA_FFI.REGISTER_PARAMETER(FH_GDD,ORA_FFI.C_LONG);
ORA_FFI.REGISTER_PARAMETER(FH_GDD,ORA_FFI.C_CHAR);
ORA_FFI.REGISTER_PARAMETER(FH_GDD,ORA_FFI.C_INT);
ORA_FFI.REGISTER_PARAMETER(FH_GDD,ORA_FFI.C_CHAR);
ORA_FFI.REGISTER_PARAMETER(FH_GDD,ORA_FFI.C_INT);
/* Register the return type. */
ORA_FFI.REGISTER_RETURN(FH_CPW,ORA_FFI.C_INT);
-- END;
/* Package Body Mathlib */
END;
now i call preview window through 'when-button-pressed' code is as:
DECLARE
IDEVICE INT := 0;
IHEIGHT INT := GET_ITEM_PROPERTY('BLOCK3.IMAGE',HEIGHT);
IWIDTH INT := GET_ITEM_PROPERTY('BLOCK3.IMAGE',WIDTH);
BRETURN BOOLEAN;RS INT;
S CAM.CAPSTATUS;
IMAGE_ID INT;
BEGIN
IMAGE_ID := GET_ITEM_PROPERTY('IMAGE',WINDOW_HANDLE);
--Open Preview window in picturebox
CAM.HHWND := CAM.CAPCREATECAPTUREWINDOWA(TO_CHAR(IDEVICE),CAM.WS_VISIBLE ,0,0,1280,1024,IMAGE_ID,0);
--Connect to device
IF CAM.SENDMESSAGE(CAM.HHWND,CAM.WM_CAP_DRIVER_CONNECT,IDEVICE,0) THEN
--Set the preview scale
BRETURN := CAM.SENDMESSAGE(CAM.HHWND,CAM.WM_CAP_SET_SCALE,TRUE,0);
--Set the preview rate in milliseconds
BRETURN := CAM.SENDMESSAGE(CAM.HHWND,CAM.WM_CAP_SET_PREVIEWRATE,66,0);
--Start previewing the image from the camera
BRETURN := CAM.SENDMESSAGE(CAM.HHWND,CAM.WM_CAP_SET_PREVIEW,TRUE,0);
--Resize window to fit in picturebox
RS := CAM.SETWINDOWPOS(CAM.HHWND,CAM.HWND_BOTTOM,0,0,IWIDTH,IHEIGHT,CAM.SWP_NOMOVE);
ELSE
MESSAGE('ERROR CONNECTING TO DEVICE');
BRETURN := CAM.SENDMESSAGE(CAM.HHWND,CAM.WM_CAP_DRIVER_DISCONNECT,IDEVICE,0);
BRETURN := CAM.DESTROYWINDOW(CAM.HHWND);
END IF;
EXCEPTION
WHEN OTHERS THEN
FOR I IN 1..Tool_Err.Nerrors LOOP
message (Tool_Err.Message);PAUSE;
Tool_Err.Pop;
END LOOP;
END;
when i run form, i will get "FRM-40734:internal error:PL/SQL error occurred.".
i checked form through debugger,it gives me "PDE-PPU007" error on this function BEGIN CLAUSE execution.
FUNCTION CAPCREATECAPTUREWINDOWA(LPSZWINDOWNAME VARCHAR2,DWSTYLE INTEGER,X INTEGER,Y INTEGER,NWIDTH INTEGER,NHEIGHT INTEGER,HWNDPARENT INTEGER,NID INTEGER) RETURN PLS_INTEGER IS
BEGIN
RETURN (FF_CAPCREATECAPTUREWINDOWA(FH_CPW,LPSZWINDOWNAME,DWSTYLE,X,Y,NWIDTH,NHEIGHT,HWNDPARENT,NID));
END CAPCREATECAPTUREWINDOWA;
please help me it's very urgent and i m running out of time.i've googled myself around 15 days to work it out but can't succeed.so i posted here for taking help.
FMB IS ATTACHED.
|
|
|
|
|
Re: Capturing video web cam using API [message #428777 is a reply to message #428760] |
Fri, 30 October 2009 00:20 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
lancer26
Messages: 52 Registered: May 2006 Location: Pakistan
|
Member |
![a_hameed4umr](/forum/theme/orafaq/images/yahoo.png)
|
|
hi david.
1. still i m unable to solve it.
2. camera capturing task already have done in vb.net and it's working fine but we want to do it with oracle developer..
(i also have used scanner activex. i am able to use access camera and scanned picture. but it runs scanner and camera wizard(window default program) and it doesn't fulfil our requirement
3. cam supplier gives us vb sample and it's implemented.
4. i run this form through debug mode. when debugger reaches that line it gives me "PDE-PPU007" error on this function BEGIN CLAUSE execution.
FUNCTION CAPCREATECAPTUREWINDOWA(LPSZWINDOWNAME VARCHAR2,DWSTYLE INTEGER,X INTEGER,Y INTEGER,NWIDTH INTEGER,NHEIGHT INTEGER,HWNDPARENT INTEGER,NID INTEGER) RETURN PLS_INTEGER IS
BEGIN
RETURN (FF_CAPCREATECAPTUREWINDOWA(FH_CPW,LPSZWINDOWNAME,DWSTYLE,X,Y,NWIDTH,NHEIGHT,HWNDPARENT,NID));
END CAPCREATECAPTUREWINDOWA;
5. it's not hardware fault because i can access it in vb.net and also camera scanner wizard.
6. we are using forms version Forms [32 Bit] Version 6.0.8.8.0 (Production)
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Sep 07 21:22:42 CDT 2024
|