Hello World in VB.NET

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Revision as of 20:48, 5 July 2011 by Zian (talk | contribs) (Created the apge)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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
       '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
           'Destory the window
       End Using
   End Sub

End Class