I'm trying to combine the binary mask of humans, but masks are of different shape. Suppose in a frame there are four humans, I can get the individual mask for each of the four humans. I want to combine these masks of individual humans to display as a single mask.
individual_masks=[]
for body in bodies_list:
print("body ID ",body.id, " Position ",body.keypoint_2d[2])
mask=body.mask
temp=mask.get_data()
temp=temp.astype("float32")
individual_masks.append(temp)
result = individual_masks[0]
for i in range(len(individual_masks)):
result=result+individual_masks[i]
result = 255*(result)
result = result.clip(0, 255).astype("uint8")
cv2.imshow("mask",result)
cv2.waitKey(1)
The code works if only one human is present, If multiple humans are in the frame, it throws error since the masks will be of different shape.
Is there a way to solve this? or is there any better way to get combined mask?
