有人知道如何获得仅通过阈值的边界框坐标吗?
我找到了这个答案(这里是link),所以我尝试使用它并完成以下操作:
vis_util.visualize_boxes_and_labels_on_image_array(
image,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=1,
min_score_thresh=0.80)
for i,b in enumerate(boxes[0]):
ymin = boxes[0][i][0]*height
xmin = boxes[0][i][1]*width
ymax = boxes[0][i][2]*height
xmax = boxes[0][i][3]*width
print ("Top left")
print (xmin,ymin,)
print ("Bottom right")
print (xmax,ymax)
但是我注意到通过使用链接中提供的答案-返回所有值。从分类器检测到的所有边界框中(我不想要)。我想要的只是传递“ min_score_thresh”的边界框中的值。
我觉得这应该很简单,但是我确实缺乏这方面的知识。 如果我能找到答案,则一定会在此处发布,但是如果其他人知道答案并可以节省一些时间,我将不胜感激。
答案 0 :(得分:0)
更新:
先前函数返回的boxes
和scores
都是 numpy数组对象,因此您可以使用布尔索引过滤掉阈值以下的框。
这应该为您提供超过阈值的框。
true_boxes = boxes[0][scores[0] > min_score_thresh]
然后您就可以
for i in range(true_boxes.shape[0]):
ymin = true_boxes[i,0]*height
xmin = true_boxes[i,1]*width
ymax = true_boxes[i,2]*height
xmax = true_boxes[i,3]*width
print ("Top left")
print (xmin,ymin,)
print ("Bottom right")
print (xmax,ymax)