Results 1 to 3 of 3

Thread: webcam motion detector help vb.net 2005

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    5

    webcam motion detector help vb.net 2005

    Good day

    im creating a program which detects motion according to how much difference does the two images have. take note images come from a live webcam stream. the problem is how to compare the two images.

    description of the program

    a sensitivity text box will be placed on the program where it will compare with the computed difference of the two images. i have a program in vb6.0 that compares images like this

    Code:
    Private Sub Timer1_Timer()
    'getting picture from camera
    SendMessage mCapHwnd, GET_FRAME, 0, 0
    SendMessage mCapHwnd, COPY, 0, 0
    Picture1.Picture = Clipboard.GetData: Clipboard.Clear
    
    
    stepp = 3 'Grid dense
    
    Dim qan, qann As Long
    qan = 0
    qann = 0
    
    For i = 1 To Picture1.Width / Screen.TwipsPerPixelX Step stepp
    For j = 1 To Picture1.Height / Screen.TwipsPerPixelY Step stepp
    
    If Different(Picture1.Point(i * stepp * Screen.TwipsPerPixelX, j * stepp * Screen.TwipsPerPixelY), Picture2.Point(Screen.TwipsPerPixelX * i * stepp, j * stepp * Screen.TwipsPerPixelY)) Then
    Picture1.Circle (i * stepp * Screen.TwipsPerPixelX, Screen.TwipsPerPixelY * j * stepp), 1, RGB(255, 0, 0)
    qann = qann + 1
    End If
    
    Next
    Next
    Label1.Caption = Int(qann * 100 / 910) & "%" 'Counting motion in percents
    ProgressBar1.Value = Int(qann * 100 / 910)
    End Sub
    
    
    
    thats where the comparing is and the difference is this
    
    Private Function Different(ByVal a As Long, ByVal b As Long) As Boolean
    'Checks different of two colors
    ar = a Mod 256: a = a \ 256
    ag = a Mod 256: a = a \ 256
    ab = a Mod 256: a = a \ 256
    
    br = b Mod 256: b = b \ 256
    bg = b Mod 256: b = b \ 256
    bb = b Mod 256: b = b \ 256
    sense = 255 - Text1.Text * 5
    
    Different = (Sqr((ar - br) * (ar - br) + (ag - bg) * (ag - bg) + (ab - bb) * (ab - bb)) > sense) 'formula for counting different
    End Function


    now i cant translate this in vb.net i have included what i have now
    Attached Files Attached Files

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: webcam motion detector help vb.net 2005

    Moved from the CodeBank

  3. #3
    New Member
    Join Date
    Mar 2009
    Posts
    3

    Re: webcam motion detector help vb.net 2005

    is anyone can help to explain each line of that codes...

    thank you so much...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width