0
votes

I am trying to detect 3 different classes of objects in images using Tensorflow Object Detection. I would like to set the bounding box color for each class to a custom color of my choice in order to suit my application.

For example, Class 1: Red Class 2: Blue Class 3: Green

Unfortunately, Tensorflow object detection automatically sets this colors and I do not know how to change them.

I would be very gratefull for any suggestions and help.

1

1 Answers

1
votes

You can achieve this by passing a track_ids to function visualize_boxes_and_labels_on_image_array.

Notice that when detection is performed, this plot function is called to visualize the bounding boxes on images.

Here is how to get the variable track_ids. First you should look at the STANDARD_COLORS list and get the index of the color you want to draw boxes with. For example, 'Red' color's index is 98. Then you should loop through the variable output_dict['detection_classes'] (this variable is also passed to the plot function), and when encounter class 1, track_ids is appended with 98. By doing this you will create a list of indexes of colors as track_ids, then transform this to a numpy array and pass it together into the plot function, then you should have all classes plotted as the color you assigned.