我想知道对象检测api中边界框的大小 [英] I want to know the size of bounding box in object-detection api

查看:41
本文介绍了我想知道对象检测api中边界框的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过API

(https://github.com/tensorflow/models/tree/master/object_detection)

然后,

我如何知道边界框的长度?

How would I know the length of bounding box?

我在 github 上实时使用了 Tutorial IPython notebook.

I have used Tutorial IPython notebook on github in real-time.

但是我不知道用哪个命令来计算盒子的长度.

But I don't know use which command to calculate the length of boxes.

推荐答案

只是为了扩展 Beta 的答案:

Just to extend Beta's answer:

您可以从检测图中获取预测的边界框.github 上的教程 IPython 笔记本 中给出了一个示例.这就是 Beta 代码截断的来源.访问 detection_graph 并从张量中提取预测边界框的坐标:

You can get the predicted bounding boxes from the detection graph. An example for this is given in the Tutorial IPython notebook on github. This is where Beta's code snipped comes from. Access the detection_graph and extract the coordinates of the predicted bounding boxes from the tensor:

通过调用 np.squeeze(boxes) 将它们重塑为 (m, 4),其中 m 表示预测框的数量.您现在可以访问这些框并计算长度、面积或任何您想要的.

By calling np.squeeze(boxes) you reshape them to (m, 4), where m denotes the amount of predicted boxes. You can now access the boxes and compute the length, area or what ever you want.

但请记住,预测的框坐标是标准化的!它们的顺序如下:

But remember that the predicted box coordinates are normalized! They are in the following order:

[ymin, xmin, ymax, xmax]

因此计算以像素为单位的长度将类似于:

So computing the length in pixel would be something like:

def length_of_bounding_box(bbox):
    return bbox[3]*IMG_WIDTH - bbox[1]*IMG_WIDTH

这篇关于我想知道对象检测api中边界框的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆