0

我想在 VB 2015 中修改我的程序,该程序使用网络摄像头捕获照片并将其保存到我的文件夹中。问题是它替换了拍摄的每张照片,我想用这种格式名称图片01、图片02等保存每张图片。

信息:我正在使用 Emgu。

图片

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Try
      PictureBox1.Image = capture.QueryFrame.ToBitmap()
    Catch ex As Exception
      capture = New Emgu.CV.Capture
    End Try
End Sub


Private Sub startWebcam_Click(sender As Object, e As EventArgs) Handles startWebcam.Click
    Timer1.Start()
End Sub

Private Sub captWebcam_Click(sender As Object, e As EventArgs) Handles captWebcam.Click
    Dim picnumber As Integer = 0
    Timer1.Stop()
    'Save the picture
    PictureBox1.Image.Save("D:\WEBCAM\Img01.JPEG", Imaging.ImageFormat.Jpeg)
    capture.Dispose()
End Sub
4

2 回答 2

0

您还可以使用简单的整数增量:

Private FileID as Integer = 0
Private Sub captWebcam_Click(sender As Object, e As EventArgs) Handles captWebcam.Click
    Timer1.Stop()

    'Save the picture
    FileID += 1
    PictureBox1.Image.Save("D:\WEBCAM\Img" & FileID.ToString("00") & ".JPEG", Imaging.ImageFormat.Jpeg)
    capture.Dispose()
End Sub
于 2020-02-21T00:02:46.057 回答
0

你可以让你的文件名成为一个日期戳,这样它就永远是唯一的:

Dim a As String = Now.ToShortDateString & Now.ToLongTimeString
a = a.Replace(":", "").Replace("/", "").Replace("\", "")

PictureBox1.Image.Save("D:\WEBCAM\" & a & ".JPEG", Imaging.ImageFormat.Jpeg)
于 2020-02-20T22:59:29.227 回答