DSAPI之摄像头追踪指定颜色物体

Private CAM As New DSAPI.摄像头_avicap32Private Clr As Color = Color.FromArgb(230, 50, 50)Private _Location As PointPrivate Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosingEndEnd SubPrivate Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.LoadCheckForIllegalCrossThreadCalls = FalseCAM.在指定控件上启动视频预览(Label1)MSK.Show()MSK.Owner = MeDim T As New Threading.Thread(AddressOf DoThd)T.Start()End SubPrivate Sub DoThd()While TrueUsing B As New DSAPI.图形图像.图像识别(CAM.截取图像)Dim Rct As Rectangle = B.获取指定颜色最大包含区域(Clr, 0.2)Rct = Label1.RectangleToScreen(Rct)_Location = Rct.Location + New Point(Rct.Width / 2, Rct.Height / 2)Me.Invoke(New CrossAppDomainDelegate(AddressOf SetMove))'MSK.Location = New Point(Rct.X + Rct.Width / 2, Rct.Y + Rct.Height / 2)'Me.Text = Rct.Location.ToStringEnd UsingThreading.Thread.SpinWait(100)Application.DoEvents()End WhileEnd SubPrivate Sub SetMove()MSK.Location = _Location – New Point(MSK.Width / 2, MSK.Height / 2)End Sub

版权声明:本文为博主原创文章,,未经博主允许不得转载。

有一些穿高跟鞋走不到的路,

DSAPI之摄像头追踪指定颜色物体

相关文章:

你感兴趣的文章:

标签云: