def show_occlusion(detection, rgb, depth, camera, bb_width):
pixels = compute_2Dboundingbox(detection, camera, bb_width)
depth_crop = depth[pixels[0, 0]:pixels[1, 0], pixels[0, 1]:pixels[2, 1]].astype(np.float)
mask = np.bitwise_and(depth_crop < 880, depth_crop != 0)
mask = cv2.erode(mask.astype(np.uint8), np.ones((3, 3)))
print("Occlusion level : {}".format(np.sum(mask) / (mask.shape[0] * mask.shape[1])))
cv2.imshow("object crop mask", (mask * 255))
cv2.imshow("object crop depth", ((depth_crop / np.max(depth_crop) * 255).astype(np.uint8)))
cv2.rectangle(rgb, tuple(pixels[0][::-1]), tuple(pixels[3][::-1]), (0, 0, 255), 2)
评论列表
文章目录