17

Cam Capture

Embed Size (px)

DESCRIPTION

Capturing web cam frames with a .Net application

Citation preview

Page 1: Cam Capture
Page 2: Cam Capture
Page 3: Cam Capture
Page 4: Cam Capture

Incorporating video capturing capabilities into our application.

Connecting Listing available video capture devices

Page 5: Cam Capture

Used to manipulate various windows.

Page 6: Cam Capture

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

Calling Windows API functions Calling third-party functions provided in

DLLs

Page 7: Cam Capture

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

Page 8: Cam Capture

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

Page 9: Cam Capture
Page 10: Cam Capture

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)

Page 11: Cam Capture

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

Page 12: Cam Capture

Const WM_CAP_START = &H400S Const WM_CAP_DRIVER_CONNECT =

WM_CAP_START + 10

SendMessage(windowHandle, WM_CAP_DRIVER_CONNECT, 0, 0)

Page 13: Cam Capture

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

Page 14: Cam Capture

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)

Page 15: Cam Capture

SendMessage(windowHandle, WM_CAP_DRIVER_DISCONNECT, 0, 0)

Page 16: Cam Capture

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

Page 17: Cam Capture