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