Skip to main content
. 2021 Apr 8;21(8):2614. doi: 10.3390/s21082614
Algorithm 1. Pseudocode for for checking the regions of the current image to which moving pixels belong.
1. seed_objects_image = np.zeros(diff_image.shape, np.uint8)
2. contours, = cv2.findContours(bin_acutal_image,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
3. # Each connected region of the original image is overlapped to the image difference
4. for cnt in contours:
5. # The image with the connected region is created.
6. region_image = np.zeros(diff_image.shape, np.uint8)
7. cv2.drawContours(region_image, [cnt], −1, 255, −1)
8. # Image with foreground pixels being those that both in the image and in the region image are foreground
9. movement_region_image = cv2.bitwise_and(diff_image, diff_image, mask = region_image)
10. # if there is foreground pixels → Si hay pixeles de primer plano → Add region to image
11. if not np.all(movement_region_image = 0):