在VB.NET安装EMGU步骤

前端之家收集整理的这篇文章主要介绍了在VB.NET安装EMGU步骤前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
下载并安装EMGU http://sourceforge.net/projects/emgucv/
项目-解决方案资源管理器,然后在解决方案资源管理器 对windowsapplication1点右键 属性 引用 ,添加在EMGU安装目录下 emgucv-windows-x86 2.3.0.1416\bin的emgu.cv.dll和emgu.util.dll两个文件
类似其他Emgu.CV.GPU.dll之类的也可以引用,具体看需求了。之后将的emgu.cv.dll和emgu.util.dll拷入.exe的目录下


贴入下面代码,我在win7 vs2008 VB.net 下运行顺利


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))

'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


不过目前想尝试使用VB自带的picBox控件加载图片,使用cvinvoke的方法处理时,会提示类型不同。正在解决


附emgu函数说明

Function Mapping - Emgu.CV.CvInvoke

The CvInvoke class provides a way to directly invokeOpenCVfunction within .NET languages. Each method in this class corresponds to a function inOpenCVof the same name. For example,a call to

 IntPtr image = CvInvoke.cvCreateImage(new System.DrawingSize(400,300),CvEnumIPL_DEPTHIPL_DEPTH_8U,0)">1);
is equivalent to the following function call in C
 IplImage* image = cvCreateImage(cvSize(400, 300)1;

Both of which create a 400x300 of 8-bit unsigned grayscale image.

Structure Mapping - Emgu.CV.Structure.Mxxx

This type of structure is a direct mapping toOpenCVstructures.

Emgu CVStructure OpenCVstructure
Emgu.CV.Structure.MIplImage IplImage
Emgu.CV.Structure.MCvMat CvMat
... ...
Emgu.CV.Structure.Mxxxx xxxx

The prefixMhere stands for Managed structure.

Emgu CValso borrows some existing structures in .Net to represent structures inOpenCV:

.Net Structure OpenCVstructure
System.Drawing.Point CvPoint
System.Drawing.PointF CvPoint2D32f
System.Drawing.Size CvSize
System.Drawing.Rectangle CvRect

Enumeration Mapping - Emgu.CV.CvEnum

The CvEnum namespace provides direct mapping toOpenCVenumerations. For example,CvEnum.IPL_DEPTH.IPL_DEPTH_8Uhas the same value asIPL_DEPTH_8UinOpenCV; both of which equals8.

猜你在找的VB相关文章