PDA

View Full Version : motion


001
02-02-2006, 05:08 AM
'theres this motion detection program i'am trying to understand but i cant seem to get the concepts - could some please comment this - visual basic
'thanks


Private Sub fillRegion(px As Integer, py As Integer, depth As Integer, ByRef minX As Integer, ByRef maxX As Integer, ByRef minY As Integer, ByRef maxY As Integer)
'fills a region with the given colour


If (motion(px, py, 0)) And (motion(px, py, 1) = 0) Then

motion(px, py, 1) = True
RegionArea = RegionArea + 1

If (px < minX) Then
minX = px
End If
If (px > maxX) Then
maxX = px
End If
If (py < minY) Then
minY = py
End If
If (py > maxY) Then
maxY = py
End If

If (depth < 100) Then

If (py > 0) Then
Call fillRegion(px, py - 1, depth + 1, minX, maxX, minY, maxY)
End If

If (px < MotionResolution - 1) And (py > 0) Then
Call fillRegion(px + 1, py - 1, depth + 1, minX, maxX, minY, maxY)
End If

If (px < MotionResolution - 1) Then
Call fillRegion(px + 1, py, depth + 1, minX, maxX, minY, maxY)
End If

If (px < MotionResolution - 1) And (py < MotionResolution - 2) Then
Call fillRegion(px + 1, py + 1, depth + 1, minX, maxX, minY, maxY)
End If

If (py < MotionResolution - 1) Then
Call fillRegion(px, py + 1, depth + 1, minX, maxX, minY, maxY)
End If

If (px > 0) Then
Call fillRegion(px - 1, py, depth + 1, minX, maxX, minY, maxY)
End If

If (px > 0) And (py > 0) Then
Call fillRegion(px - 1, py - 1, depth + 1, minX, maxX, minY, maxY)
End If

If (px > 0) And (py < MotionResolution - 1) Then
Call fillRegion(px - 1, py + 1, depth + 1, minX, maxX, minY, maxY)
End If

If (px < MotionResolution - 1) And (py < MotionResolution - 1) Then
Call fillRegion(px + 1, py + 1, depth + 1, minX, maxX, minY, maxY)
End If

End If
End If
End Sub