Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK



Articles

1.Windows API reference
2.HTML to WML Converter
3.Webcam streaming in VB.NET
4.Remoting with firewalls
5.RSA from first principles
6.Key & MouseLogger in .NET
7.Networking Resource Kit for .NET
8.Automatic Reboot with .NET
9.XAML Schema
10.Migrating VB6 Winsock to VB.NET
11.Migrating C++ sockets to C#
12.RFC Reference guide
13.Lingua - Localization webservice
14.COM Reference guide
15.WMI Reference guide
16.SQL stored procedures
17.TCP & UDP port reference
18..NET Framework reference
19.Ethernet Type codes
20.IP to country webservice
21.MAC address assignments
22.DLL entry point reference
23.WHOIS server list
24. Turing Numbers
25. Boost SQL performance
26. Progress Bar in ASP.NET
27. OleDb WebService
27. Internet Explorer

Contact us

Streaming WebCam video with VB.NET

No DirectX, No ActiveX/COM, No Intermediary file, just live video stream at speeds up to 30 FPS.

This project is a bare-bones implementation of a webcam (web camera) viewer using VB.NET code. It uses the VFW (Video for windows) API, which is built into all versions of windows (95 and up). It is used to map the output of any VFW compliant Webcam to a window handle, such as that of a VB.NET picture box.

Most Webcams are VFW compliant, this does exclude some Intel models that are incompatible with this demonstration. As most web cam users are aware, this application cannot run in tandem with another application that is accessing the same camera driver. Unfortunately, most Webcams developed Post-Windows-XP, all use the same WDM (Windows Driver Model) driver, and therefore cannot run concurrently with any other modern webcam. However it is possible to run two Non-WDM Webcams using VFW drivers simultaneously, by changing the wDriver parameter in capGetDriverDescriptionA.

To begin coding this application, start a new VB.NET application project in Visual Studio .NET, and then drag a picture-box named camSrc to the form. It should be 320 pixels wide, and 240 pixels high. Double click on the form, and add the following code

Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal _

eventArgs As System.EventArgs) Handles MyBase.Load

MapWebcamToWindow(camSrc.Width, camSrc.Height, _

camSrc.Handle.ToInt32)

End Sub

Next, select the ‘closed’ event from the drop down list, and type the following code:

Private Sub Form1_Closed(ByVal eventSender As System.Object, ByVal _

 eventArgs As System.EventArgs) Handles MyBase.Closed

CloseWebcam()

End Sub

These two subs, used to start and stop the webcam are implemented in a separate module, which we add to the project by right clicking on solution explorer and selecting new module. This new module, I have called WebcamCapture

To the top of this module, we add a public variable lwndC, which keeps track of a handle to the capture window. We also define a few constants, which are used as parameters to some API calls, which we shall see later.

Public lwndC As Integer

Public Const WS_CHILD As Integer = &H40000000

Public Const WS_VISIBLE As Integer = &H10000000

Public Const SWP_NOMOVE As Short = &H2S

Public Const SWP_NOZORDER As Short = &H4S

Public Const WM_USER As Short = &H400S

Page 2  Page 3  Page 4 



Google

Free SMS UK Free SMS Ireland SMS Gratis Norway SMS Gratis Sverige Ilmainen SMS Suomi SMS Gratis Danmark SMS Tasuta Eestisse SMS Nemokamai Lietuva SMS Bezmaksas Latviju Darmowe smsy Polska SMS Zdarma Ceské SMS Zdarma Slovensko SMS Gratis Deutschland SMS Gratis Schweiz SMS Gratis Österreich SMS Gratuit Belgique SMS Gratis Nederland SMS Gratuit France SMS Gratis España SMS Gratis Portugal Free SMS South Africa Free SMS USA SMS Percuma Malaysia Free SMS Hong Kong