Click here to Skip to main content
15,896,154 members

connecting a webcam using aforge.net in vb.net

Revision 3
Hi everyone,

I am new to this forum and am a beginner programmer.

I wish to develop a motion detector program in Visual Basic.NET. I've tried the windows API for connecting the webcam to my project.
While surfing the net I came across to this forum and found a project which uses AForge.net. I downloaded and installed the framework and tried a certain project, to learn what is what.
I decided to rewrite the code myself, but encountered an error in the line
VB
If VideoSourcePlayer1.Isrunning = True Then

It says that VideoSourcePlayer1 is not declared. It may be inaccessible due to its protection level.

Here is the code that I am trying to rewrite. The VideoSourcePlayer1 doesn't have an error.
I'm merely rewriting the code, so why am I encountering an error when it seems to work fine on the other project?

Kindly help me.

Thanks in advance.

VB
Imports AForge.Video
Imports AForge.Video.DirectShow

Public Class MainWindow
    Dim VideoCaptureSource As VideoCaptureDevice
    Dim WCdevices As New FilterInfoCollection(FilterCategory.VideoInputDevice)


    Private Sub MainWindow_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim MyWebcam As FilterInfo

        If WCdevices.Count = 0 Then
            lstWCdevices.Items.Add("No Webcam Device Detected")
        Else
            For Each MyWebcam In WCdevices
                lstWCdevices.Items.Add(MyWebcam.Name)
            Next
        End If
        lstWCdevices.SelectedIndex = 0
    End Sub



    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
        If lstWCdevices.SelectedItem <> "No Video Devices" Then


            If VideoSourcePlayer1.IsRunning = True Then
                VideoSourcePlayer1.SignalToStop()
                VideoSourcePlayer1.WaitForStop()
            End If

            VideoCaptureSource = New VideoCaptureDevice(VideoDevices(cboVideoSource.SelectedIndex).MonikerString)
            VideoSourcePlayer1.VideoSource = VideoCaptureSource
            VideoSourcePlayer1.Start()
        End If
    End Sub
End Class
Posted 27-Jan-13 3:20am by Member 9626615.
Tags: