python检测边界_python – 在TensorFlow对象检测API教程中获取边界框坐标

本文解释了在使用图像处理算法时如何正确理解并计算检测框坐标。详细介绍了坐标系统的概念,特别是当使用归一化坐标时,如何将检测框的坐标转换为图像上的实际位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I tried printing output_dict[‘detection_boxes’] but I am not sure what

the numbers mean

您可以自己查看代码. visualize_boxes_and_labels_on_image_array定义为here.

请注意,您正在传递use_normalized_coordinates = True.如果你跟踪函数调用,你会看到你的数字[0.56213236,0.691205]等是图像坐标所在的值[ymin,xmin,ymax,xmax]:

(left,right,top,bottom) = (xmin * im_width,xmax * im_width,ymin * im_height,ymax * im_height)

由函数计算:

def draw_bounding_box_on_image(image,ymin,xmax,color='red',thickness=4,display_str_list=(),use_normalized_coordinates=True):

"""Adds a bounding box to an image.

Bounding box coordinates can be specified in either absolute (pixel) or

normalized coordinates by setting the use_normalized_coordinates argument.

Each string in display_str_list is displayed on a separate line above the

bounding box in black text on a rectangle filled with the input 'color'.

If the top of the bounding box extends to the edge of the image,the strings

are displayed below the bounding box.

Args:

image: a PIL.Image object.

ymin: ymin of bounding box.

xmin: xmin of bounding box.

ymax: ymax of bounding box.

xmax: xmax of bounding box.

color: color to draw bounding box. Default is red.

thickness: line thickness. Default value is 4.

display_str_list: list of strings to display in box

(each to be shown on its own line).

use_normalized_coordinates: If True (default),treat coordinates

ymin,xmax as relative to the image. Otherwise treat

coordinates as absolute.

"""

draw = ImageDraw.Draw(image)

im_width,im_height = image.size

if use_normalized_coordinates:

(left,ymax * im_height)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值