Please use FireFox to view this page

This website has been designed for use with the FireFox browser. Please use FireFox to view this page.

Most properties for the webcam are set and retrieved using
windows messaging, that is, using the SendMessage API to issue windows messages
(WM_) to the capture window. This is quite an arcane means of setting
properties, so it is best that we encapsulate these into separate functions as
follows:

Function capDriverConnect(ByVal lwnd AsInteger, ByVal i AsShort) _AsBooleancapDriverConnect =
SendMessage(lwnd, WM_CAP_DRIVER_CONNECT, i, 0)EndFunctionThe
capDriverConnect API call connects a VFW driver to a previously created capture
window. The ‘i’ parameter is the index of the driver, which, in this
application is always set to 0, but when used with multiple drivers, could be
any number between 0 and 10.Function capDriverDisconnect(ByVal lwnd AsInteger) AsBooleancapDriverDisconnect =
SendMessage(lwnd, WM_CAP_DRIVER_DISCONNECT, _0, 0)EndFunctionThe
capDriverDisconnect gracefully disconnects a VFW driver from a capture window.
Failure to call this method before exiting the application could stop other
webcam applications from accessing the camera.
Function capSetVideoFormat(ByVal hCapWnd AsInteger,ByRef
BmpFormat _ As BITMAPINFO, ByVal CapFormatSize AsInteger) AsBooleancapSetVideoFormat =
SendMessageAsBitMap(hCapWnd, _WM_CAP_SET_VIDEOFORMAT,
CapFormatSize, BmpFormat)EndFunctionThe
capSetVideoFormat API is used to indicate to the webcam the format of image to
be returned. Many cameras do not support all ranges of bitmap formats, however,
24 bit colour 320 x 240 and 640 x 480 are quite common.
Function capPreview(ByVal lwnd AsInteger, ByVal f AsBoolean) As _BooleancapPreview = SendMessage(lwnd,
WM_CAP_SET_PREVIEW, f, 0)EndFunctionThe
capPreview function is used to initiate the streaming of images between the VFW
driver and the capture window.
Function capPreviewRate(ByVal lwnd AsInteger,ByVal wMS AsShort)As _BooleancapPreviewRate =
SendMessage(lwnd, WM_CAP_SET_PREVIEWRATE, wMS, 0)

EndFunction

The capPreviewRate function determines the refresh rate by
specifying the refresh interval in milliseconds. In our case, it is set to 66
ms (15 Frames Per second).