0

Most simply put, I want to connect to a built in web cam in my computer using visual basic, take a single picture, and save that in a file. I have spent about an hour or so looking for a reasonable way to do this, and have found a few suggestions. Unfortunately many the methods that I have tried seem unnecessarily complicated and I have yet to see one of them work on my computer. For example, I have tried using the icam class referenced in several places, where this code

Public Class Form1

    Private Sub Snap()
        Dim Webcam As iCam = New iCam
        Webcam.initCam(PictureBox1.Handle.ToInt32)
        Application.DoEvents()
        If Webcam.iRunning Then
            PictureBox2.Image = Webcam.copyFrame(PictureBox1, New RectangleF(0, 0, PictureBox1.Width, PictureBox1.Height))
        End If
        Webcam.closeCam()
        Webcam = Nothing
    End Sub

    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click

    End Sub
End Class

Threw this error:

An unhandled exception of type 'System.InvalidOperationException' occurred in facerecognition.exe
Additional information: An error occurred creating the form. See Exception.InnerException for details.  The error is: Failed to initialize because CategoryName is missing.

While with some work I could probably get the class functioning as it is meant to, the issue remains that there is really no simple and clean solution to this that I know of. Does anyone have a better idea of how to do this?

Tim Williams
  • 137,250
  • 8
  • 88
  • 114
trevorKirkby
  • 1,896
  • 18
  • 46

0 Answers0