我刚接触Python和Tensorflow. 我试图运行来自Tensorflow目标检测API的对象检测教程文件,但我找不到当对象被检测到时获取边界框坐标的位置。
相关代码:
# The following processing is only for single image
detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0])
detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0])
我假设边界框绘制的位置是这样的:
# Visualization of the results of detection.
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)
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
我试过打印 output_dict['detection_boxes']
,但是我不确定这些数字代表什么意思。有很多。
array([[ 0.56213236, 0.2780568 , 0.91445708, 0.69120586],
[ 0.56261235, 0.86368728, 0.59286624, 0.8893863 ],
[ 0.57073039, 0.87096912, 0.61292225, 0.90354401],
[ 0.51422435, 0.78449738, 0.53994244, 0.79437423],
......
[ 0.32784131, 0.5461576 , 0.36972913, 0.56903434],
[ 0.03005961, 0.02714229, 0.47211722, 0.44683522],
[ 0.43143299, 0.09211366, 0.58121657, 0.3509962 ]], dtype=float32)
我找到了一些类似问题的答案,但我没有像他们那样叫做boxes的变量。如何获取坐标?
visualize_boxes_and_labels_on_image_array
函数的输入变量中的min_score_thresh
值,你就可以限制重叠框的数量。默认情况下,它设置为0.5。例如,对于我的项目,我不得不将其增加到0.8。 - Web Nexusymin,xmin,ymax,xmax
。https://github.com/tensorflow/models/blob/3db445c7b0404f9b98cbc47616bab08bfa3d8130/research/object_detection/utils/visualization_utils.py#L1235 - mrtpk