Difference between revisions of "Hello World in VB.NET"

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to navigation Jump to search
(Created the apge)
 
m (Added <source>)
 
Line 1: Line 1:
 
This is a direct conversion of the C# source code into VB .NET. The conversion was done manually and has been successfully compiled and executed with Visual Studio 2010 on Windows 7.
 
This is a direct conversion of the C# source code into VB .NET. The conversion was done manually and has been successfully compiled and executed with Visual Studio 2010 on Windows 7.
  
 +
<source lang="vb">
 
Imports Emgu.CV
 
Imports Emgu.CV
 
Imports Emgu.CV.CvEnum
 
Imports Emgu.CV.CvEnum
Line 31: Line 32:
 
     End Sub
 
     End Sub
 
End Class
 
End Class
 +
</source>

Latest revision as of 20:49, 5 July 2011

This is a direct conversion of the C# source code into VB .NET. The conversion was done manually and has been successfully compiled and executed with Visual Studio 2010 on Windows 7.

Imports Emgu.CV
Imports Emgu.CV.CvEnum
Imports Emgu.CV.Structure

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'The name of the window
        Dim win1 = "Test Window"

        'Create the window using the specific name
        CvInvoke.cvNamedWindow(win1)

        'Create an image of 400x200 of Blue color
        Using img As Image(Of Bgr, Byte) = New Image(Of Bgr, Byte)(400, 200, New Bgr(255, 0, 0))

            'Create the font
            Dim f = New MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0)
            'Draw "Hello, world." on the image using the specific font
            img.Draw("Hello, world", f, New Point(10, 80), New Bgr(0, 255, 0))

            'Show the image
            CvInvoke.cvShowImage(win1, img.Ptr)
            'Wait for the key pressing event
            CvInvoke.cvWaitKey(0)
            'Destory the window
            CvInvoke.cvDestroyWindow(win1)
        End Using
    End Sub
End Class