2

我发现这个很棒的类用于查看网络摄像头Vb-Net-WebCam-Class,但它需要图片框,您不能在控制台应用程序中使用它。

所以我只是想知道是否有任何方法可以在使用该类的控制台应用程序中使用网络摄像头拍摄快照?

我正在使用 Visual Basic .NET (2010)


如果有人感兴趣,这是使用表单应用程序拍摄快照的代码:

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

1 回答 1

0

You could still use the class to get the job done, but you'd probably need to edit it. You could first try passing Nothing as the picturebox parameter, but this would only work if the class is checking if the picturebox IsNot Nothing.

If that is not the case, it still wouldn't be too difficult to edit. It looks like the webcam updates the "source picturebox" with the image, and the copyFrame function retrieves the image from that picturebox after it has an image assigned. Instead of using this picturebox, you could save the picturebox from the webcam to a file and modify the copyFrame function to retrieve the image it will return from that image path, instead of from the picturebox.

于 2015-01-15T23:54:17.043 回答