我有完全一样的故事。当图像上仅显示一个数组时,得到了一个包含大约一百个框的数组( output_dict['detection_boxes']
)。深入研究绘制矩形的代码能够将其提取并用于我的inference.py
:
#so detection has happened and you've got output_dict as a
# result of your inference
# then assume you've got this in your inference.py in order to draw rectangles
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
output_dict['detection_boxes'],
output_dict['detection_classes'],
output_dict['detection_scores'],
category_index,
instance_masks=output_dict.get('detection_masks'),
use_normalized_coordinates=True,
line_thickness=8)
# This is the way I'm getting my coordinates
boxes = output_dict['detection_boxes']
# get all boxes from an array
max_boxes_to_draw = boxes.shape[0]
# get scores to get a threshold
scores = output_dict['detection_scores']
# this is set as a default but feel free to adjust it to your needs
min_score_thresh=.5
# iterate over all objects found
for i in range(min(max_boxes_to_draw, boxes.shape[0])):
#
if scores is None or scores[i] > min_score_thresh:
# boxes[i] is the box which will be drawn
class_name = category_index[output_dict['detection_classes'][i]]['name']
print ("This box is gonna get used", boxes[i], output_dict['detection_classes'][i])
0
我是python和Tensorflow的新手。我正在尝试从Tensorflow对象检测API运行object_detection_tutorial文件,但是当检测到对象时,我找不到在哪里可以获得边界框的坐标。
相关代码:
...
我假设绘制边界框的地方是这样的:
我尝试打印output_dict ['detection_boxes'],但不确定数字的含义。有很多。
......
我找到了类似问题的答案,但没有像box这样的变量叫做box。如何获得坐标?谢谢!