cam capture

Post on 15-May-2015

1.706 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Capturing web cam frames with a .Net application

TRANSCRIPT

Incorporating video capturing capabilities into our application.

Connecting Listing available video capture devices

Used to manipulate various windows.

Mechanism of .Net language calling unmanaged functions in DLL’s.

Calling Windows API functions Calling third-party functions provided in

DLLs

List all available capture devices installed in the system

Select the appropriate device Create a capture window Connect the camera Start camera preview and capture Disconnect camera Stop Recording and release memory

Dim DriverName As String = Space(80)Dim DriverVersion As String = Space(80) 

capGetDriverDescriptionA(0, DriverName, 80,DriverVersion, 80)

 

Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _ (ByVal wDriverIndex As Short, _ ByVal lpszName As String, ByVal cbName As Integer, _ ByVal lpszVer As String, _

ByVal cbVer As Integer) As Boolean

Private windowHandle As IntegerConst WS_CHILD = &H40000000 Const WS_VISIBLE = &H10000000nID = 0 (index of camera) (eg: index is 1 then

nID=1)

windowHandle = capCreateCaptureWindowA("My Cam", WS_CHILD Or WS_VISIBLE, xPos, yPos, wWidth, wHight, parentHandle, nId)

Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll“ (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer

Const WM_CAP_START = &H400S Const WM_CAP_DRIVER_CONNECT =

WM_CAP_START + 10

SendMessage(windowHandle, WM_CAP_DRIVER_CONNECT, 0, 0)

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Int32, ByVal lParam As Int32) As Integer

Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52

Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50Private frameRate As Integer = 25

'---start previewing the image--- SendMessage(windowHandle, WM_CAP_SET_PREVIEW, 1,0)

'---set the preview rate ---  SendMessage(windowHandle, M_CAP_SET_PREVIEWRATE, frameRate, 0)

‘--- Capturing---SendMessage(windowHandle, WM_CAP_SEQUENCE, 0, 0)

SendMessage(windowHandle, WM_CAP_DRIVER_DISCONNECT, 0, 0)

SendMessage(windowHandle, WM_CAP_STOP, 0, 0)

'--This function destroys the specified window— DestroyWindow(windowHandle) Declare Function DestroyWindow Lib

"user32" _ (ByVal hndw As Integer) As Boolean

top related