---
# System prepended metadata

title: show object center (dot)

---

regions = [
	region1 = (area)
	region2
	region3
	region4
]

region_bg = img - (area1234
bitwise_and



current = {id: state}

output = []


for frame in frames:


    for object in obejcts:

        x,y = object.center
        if region_bg[x][y]:
            continue  # to next object


        if not object.id in current:
            current[id] = object.region

        elif:
            for region in regions 
            current[id] == o
			



for object in obejct:
	x,y = object.center
	if mask1[x][y] == 1:
		pass
		object.id
		break
	elif mask2[x][y] == 1:
		pass



current = {
	16: 2.  # id: in_region


}


# show object center (dot)
img_center = cv2.line(img, (round(x), round(y)), (round(x), round(y)), (255, 255, 0), 10)


--------track.py---------------

96
    # Initialize counting module
    masks = initialize_counting()


173
    # Stream results
    im0 = annotator.result()
    im0 = show_counting(im0, masks) # Overlay masks to output image

--------counting.py------------

import cv2
import numpy as np


def initialize_counting():
    """
    Load four section masks of intersection
    """
    mask1 = cv2.imread('./road_roi/1.jpg', cv2.IMREAD_GRAYSCALE)
    mask2 = cv2.imread('./road_roi/2.jpg', cv2.IMREAD_GRAYSCALE)
    mask3 = cv2.imread('./road_roi/3.jpg', cv2.IMREAD_GRAYSCALE)
    mask4 = cv2.imread('./road_roi/4.jpg', cv2.IMREAD_GRAYSCALE)

    masks = [mask1, mask2, mask3, mask4]

    print('mask1.shape: ', mask1.shape)

    mask_background = mask1.copy()
    for mask in [mask2, mask3, mask4]:
        mask_background = cv2.bitwise_or(mask_background, mask)





    return masks



def show_counting(img, masks):

    # Set color for each mask
    colors = [
        (0, 0, 200),    # mask1: red
        (200, 0, 0),    # mask2: blue
        (0, 200, 0),    # mask3: green
        (0, 100, 200)   # mask4: brown
    ]

    # Copy 4 images to overlay
    mask_images = []
    for _ in range(4):
        mask_images.append(img.copy())

    # Assign colors to each mask
    for image, mask, color in zip(mask_images, masks, colors):
        image[mask > 0] = color

    # Overlay colored masks to image
    output = img.copy()
    for mask_image in mask_images:
        cv2.addWeighted(mask_image, 0.2, output, 0.8, 0, output)

    return output



