Я использую следующий код, чтобы получить ограничивающие рамки позиций объектов на изображении.
image = Image.open(image_path)
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
output_dict = run_inference_for_single_image(image_np, detection_graph)
# Visualization of the results of a 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=2)
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
width = 1024
height = 600
for i,j in zip(output_dict['detection_boxes'],output_dict['detection_scores']):
if(j>0.5):
print(i[0]*width,i[2]*height,i[1]*width,i[3]*height)
Размер тестового изображения (1024 600).Приведенный выше код выводит следующее
456.1627197265625 433.97676944732666 659.828125 562.1794939041138
430.4501953125 364.17006254196167 612.30224609375 440.01832008361816
453.7798156738281 326.9976854324341 584.5558471679688 374.18121099472046
, которое, я думаю, имеет порядок x_min,y_min,x_max,y_max
Пожалуйста, дайте мне знать, если это ожидаемый / желаемый вывод, и если нет, как мне изменить мой код?