Solved

Capture Video from WebCam in VB.NET

Posted on 2006-11-05
3
1,454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
ID: 17876526
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
ID: 18035842
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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