即時圖片試圖將圖片從PictureBox
移動到另一個,該圖片被網絡攝像頭捕獲,但我的代碼無法正常工作。將圖像從圖片框移動到另一個圖片的另一個圖片盒
Public Class Form12
Private _capture As Emgu.CV.Capture
Private _captureInProgress As Boolean
Dim form23 As Form23
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
form23.SetPictureBoxImage(captureImageBox.Image)
form23.Show()
End Sub
Private Sub captureButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles captureButton.Click
If (_capture Is Nothing) Then
Try
_capture = New Emgu.CV.Capture
Catch excpt As NullReferenceException
MessageBox.Show(excpt.Message)
End Try
End If
If (Not _capture Is Nothing) Then
If _captureInProgress Then
Me.captureButton.Text = "Start Capture"
RemoveHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
Else
captureButton.Text = "Capture"
AddHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
End If
_captureInProgress = Not _captureInProgress
End If
End Sub
Private Sub ProcessFrame(ByVal sender As Object, ByVal arg As EventArgs)
Dim frame As Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte) = Me._capture.QueryFrame
Dim grayFrame As Emgu.CV.Image(Of Emgu.CV.Structure.Gray, Byte) = frame.Convert(Of Emgu.CV.Structure.Gray, Byte)()
Dim smoothedGrayFrame As Emgu.CV.Image(Of Emgu.CV.Structure.Gray, Byte) = grayFrame.PyrDown.PyrUp
captureImageBox.Image = frame.Bitmap
End Sub
Private Sub ReleaseData()
If (Not _capture Is Nothing) Then
_capture.Dispose()
End If
End Sub
第二表格
Public Class Form23
Public Sub SetPictureBoxImage(ByVal image As Bitmap)
PictureBox1.Image = image
End Sub
End Class
所有攝像頭的事情是工作,只是圖像的傳輸是沒有的。對不起,這裏只是一個新手。剛剛從教程中獲得這些代碼。謝謝!
對於開始,我沒有看到form23的實例;也VB不區分大小寫,所以'Dim form23作爲Form23'不是一個好主意。如果不能提供描述性名稱,請使用'frm23'。因爲,它看起來像你正在設置類,而不是形式,屬性。更改爲'Dim frm23作爲新的Form23'並修復引用到'frm23'並且它應該工作 – Plutonix 2014-10-18 19:57:52
它仍然沒有複製/轉移到另一個'PictureBox1'我的代碼還有什麼問題?hmm – 2014-10-18 20:06:16
哇!就這麼簡單,你再次拯救了我的未來! :) 謝謝你,先生! :) – 2014-10-18 20:15:57