?
Solved

Capture Video from WebCam in VB.NET

Posted on 2006-11-05
3
Medium Priority
?
1,466 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 1600 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

777 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