DSAPI camera tracks the specified Color object

Source: Internet
Author: User










Private CAM As New DSAPI. Camera_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. Start video preview on the specified control (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. Graphic image. Image recognition (CAM. Capture image)
                Dim Rct As Rectangle = B. Get the maximum contained area of the specified color (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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.