zoukankan      html  css  js  c++  java
  • DSAPI之摄像头追踪指定颜色物体



        Private CAM As New DSAPI.摄像头_avicap32
        Private Clr As Color = Color.FromArgb(230, 50, 50)
        Private _Location As Point
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            End
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            CheckForIllegalCrossThreadCalls = False
            CAM.在指定控件上启动视频预览(Label1)
            MSK.Show()
            MSK.Owner = Me
            Dim T As New Threading.Thread(AddressOf DoThd)
            T.Start()
        End Sub
        Private Sub DoThd()
            While True
                Using 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.ToString
                End Using
                Threading.Thread.SpinWait(100)
                Application.DoEvents()
            End While
        End Sub
        Private Sub SetMove()
            MSK.Location = _Location - New Point(MSK.Width / 2, MSK.Height / 2)
        End Sub




    自动备注:本博所有文章均为博主本人编写,未经许可谢绝任何形式的转载。
    博主使用VB.NET语言,如您使用C#语言,可下载VB.NET/C#代码转换工具
  • 相关阅读:
    菜根谭#219
    菜根谭#218
    菜根谭#217
    菜根谭#216
    有了OpenMP,MPI,为什么还要MapReduce? (转载)
    人生就是一场战略
    SDAccel 开发环境
    各种加速卡 异构计算
    Nvidia Tesla (GPGPU)系列发展流程
    Nvidia 架构发展
  • 原文地址:https://www.cnblogs.com/dylike/p/10575980.html
Copyright © 2011-2022 走看看