I have created a per_frame function that is fed into ImageAI's detector. I want to draw a line between centroid that meet the distance criteria (if distance >= find_dist_ratio(x1, y1)). Lines should be drawn between the centroids of all objects that meet the criteria, I tried changing it and finally got it without errors but the line does not show up in the output video. Thanks for the help!
def dist_func(counting, output_objects_array,output_objects_count):
a =[]
ret, frame = camera.read()
for d in output_objects_array:
x1 = d['box_points'][0]
y1 = d['box_points'][1]
x2 = d['box_points'][2]
y2 = d['box_points'][3]
centroid = (int((x1 + x2) / 2), int((y1 + y2) / 2))
a.append(centroid)
for i in range(len(a)):
for j in range(i+1, len(a)):
distance = euc_dist(a[i],a[j])
if distance >= find_dist_ratio(x1, y1):
print('close enough')
x, y = a[i]
X, Y = a[j]
cv2.line(frame, (x, y), (X, Y), (255, 0, 0), 5)