如何让 tensorflow 边界框每 "n" 秒出现一次?

How to make tensorflow bounding boxes to show up every "n" seconds?

目前我正在使用我自己的数据集玩 Tensorflow 对象检测 Api。我想 "hide" 每 5 帧检测边界框。因此,这些边界框将显示为 "blinking",并且在使用检测框架时它们会受到更多关注。

我已经搞砸了 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 将继续按预期显示检测到的对象。但是当我使用它时,它崩溃了。我想在显示边界框之前创建一个无限循环会在绘制时禁用一些回调函数。 如果有人知道如何制作闪烁的边界框,我洗耳恭听。

提前致谢。

我放弃了。我没有去掉边界框,而是在其中添加了另一种颜色。边界框现在会在固定时间内改变颜色。