Solved

Capture Video from WebCam in VB.NET

Posted on 2006-11-05
3
1,429 Views
Last Modified: 2010-05-18
I would like to capture video from a webcam in VB.Net.  The following sourcecode displays the video correctly:

Private Sub cmdCapture_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCapture.Click
Dim temp As Integer      
hwdc = capCreateCaptureWindow("Dixanta Vision System", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.Handle.ToInt32, 0)
If (hwdc <> 0) Then
   temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
   temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
   temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
   startcap = True
Else
   MsgBox("No Webcam found")
End If
End Sub

I have added the code temp = SendMessage(hwdc, WM_CAP_SEQUENCE, 0, 0L)
This does create a video file - however there is no video, only sound.

Can you help me to get this snippet to work - or do you have other full source code that you can share?
0
Comment
Question by:ErichN
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
Comment Utility
There is the way to do this using pure .NET code, without PInvoke - search for VB .NET DirectShow samples. This sample is written in C#, but this is class which can be placed to Class Library and used from any .NET language:

http://www.codeproject.com/cs/media/directxcapture.asp

Notice that capCreateCaptureWindow is part of Video Capture SDK. This SDK is not recommended for use by Microsoft both in managed and unmanaged applications, and replaced by DirectShow SDK.
0
 

Author Comment

by:ErichN
Comment Utility
Thank you Alex.  Your answer has helped me implementing my project.  As a small thankyou I have increased the points for you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now