Logo
Acquisti Giochi Scienza Affari Notizie Societè Casa
Regionale Sport Computer Salute Tempo libero Consultazione  


Camera Capture

' translated in VB:NET from c#

' by Giuseppe Di Santo - Studio IT

 

Public Class CameraCapture

 

    Private _capture As Emgu.CV.Capture

    Private _captureInProgress As Boolean

 

    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 = "Stop"

                AddHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)

            End If

            _captureInProgress = Not _captureInProgress

        End If

    End Sub

 

    Private Sub flipHorizontalButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles flipHorizontalButton.Click

        If (Not _capture Is Nothing) Then

            _capture.FlipHorizontal = Not _capture.FlipHorizontal

        End If

    End Sub

 

    Private Sub flipVerticalButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles flipVerticalButton.Click

        If (Not _capture Is Nothing) Then

            _capture.FlipVertical = Not Me._capture.FlipVertical

        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

        Dim cannyFrame As Emgu.CV.Image(Of Emgu.CV.Structure.Gray, Byte) = smoothedGrayFrame.Canny(New Emgu.CV.Structure.Gray(100), New Emgu.CV.Structure.Gray(60))

 

        captureImageBox.Image = frame

        grayscaleImageBox.Image = grayFrame

        smoothedGrayscaleImageBox.Image = smoothedGrayFrame

        cannyImageBox.Image = cannyFrame

    End Sub

 

    Private Sub ReleaseData()

        If (Not _capture Is Nothing) Then

            _capture.Dispose()

        End If

    End Sub

 

 

End Class

 

<< back to index