11/15/2019

rect intersector check using image (python)



1. make image as numpy
2. add 1 all element for each inside of box
3. check if there is bigger element value than 1

Thank you.


#draw new image
img = np.zeros((int(height), int(width), 1), dtype = "uint8")
#draw new image
img.fill(0)
for i, v in enumerate(box_list):
left = int(v['bbox'][0])
top = int(v['bbox'][1])
right = int(v['bbox'][2])
bottom = int(v['bbox'][3])
img[top:bottom,left:right] += 1

#check overlap
imgv = img.reshape(height*width)
if sum(imgv > 1) > 0:
print('intersector found')