Search code examples
pythontensorflowbounding-boxobject-detection-api

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


Currently I'm playing with Tensorflow Object Detection Api with my own dataset. I want to "hide" detection bounding boxes for every 5 frames. Thus, those bounding boxes will be displayed as "blinking" and they will get much more attention while using detection framework.

I've already messed up with visualization_utils.py and tried to have another method for visualizing bounding boxes for this purpose and used it with a while loop:

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")

If I don't use while True loop at the beginning, Tensorflow will continue to display detected objects as expected. But when I use that, it crashes. I guess creating an infinite loop before displaying bounding boxes disabling some callback functions when drawing. If anyone knows how to make blinking bounding boxes, i'm all ears.

Thanks in advance.


Solution

  • I gave up on this. Instead of getting rid of bounding boxes, I've just added another color into them. Bounding boxes are now changing color within a fixed time.