【发布时间】:2019-09-26 16:22:22
【问题描述】:
目前我正在使用我自己的数据集使用 Tensorflow 对象检测 Api。我想每 5 帧“隐藏”一次检测边界框。因此,这些边界框将显示为“闪烁”,并且在使用检测框架时会受到更多关注。
我已经搞砸了 visualization_utils.py 并尝试使用另一种方法来可视化边界框,并将其与 while 循环一起使用:
def draw_bounding_box_every5(image,
ymin,
xmin,
ymax,
xmax,
count,
use_normalized_coordinates=True):
#while True:
count+=1
draw = ImageDraw.Draw(image)
im_width, im_height = image.size
## with the "if" below, I'm aiming to have only 1 bounding box to display from every 5 frames.##
if(count %5 == 0):
if use_normalized_coordinates:
(left, right, top, bottom) = (xmin * im_width, xmax * im_width,
ymin * im_height, ymax * im_height)
else:
(left, right, top, bottom) = (xmin, xmax, ymin, ymax)
draw.line([(left, top), (left, bottom), (right, bottom),
(right, top), (left, top)])
print("line drawed")
如果我一开始不使用 while True 循环,Tensorflow 将继续按预期显示检测到的对象。但是当我使用它时,它会崩溃。我猜想在显示边界框之前创建一个无限循环,在绘制时禁用一些回调函数。 如果有人知道如何制作闪烁的边界框,我会全力以赴。
提前致谢。
【问题讨论】:
标签: python tensorflow bounding-box object-detection-api