Skip to main content
. 2023 Feb 16;23(4):2235. doi: 10.3390/s23042235
Algorithm 1 Motion objects contour processing
Input:Mm—binary mask of objects in motion, h,w—height and width of the image
Output:Cm—list of final objects in motion
1: functionfilterMotionMasks (Mm)
2:      minhw0.0001                  ▹ min. contour area
3:      maxhw0.2                     ▹ max. contour area
4:      maxdisth0.05              ▹ min. distance for contour merging
5:      cnt findContours(Mm)        ▹ motion mask contours and object labeling
6:      cnt filterContoursByArea(cnt,min,max)  ▹ filtering objects of extreme sizes
7:      cnt mergeCloseContours(cnt, maxdist)      ▹ merging close objects using
Euclidean distance
8:      Cm[]
9:      for ccnt do
10:            cconvexHull(c)                  ▹ convex hulls of objects
11:            Cm.append(c)
12:      end for
13:      return Cm                       ▹ filtered moving objects
14: end function