I am implementing "BBAVectors-Oriented-Object-Detection" https://github.com/yijingru/BBAVectors-Oriented-Object-Detection model. After testing the model, all the detected objects are shown with same colour bounding-boxes.
Following is the link to the test.py code https://github.com/yijingru/BBAVectors-Oriented-Object-Detection/blob/master/test.py . I figured out the following line of code changes the bounding boxes colour.
ori_image = cv2.drawContours(ori_image, [np.int0(box)], -1, (255,0,255),1,1)
However, it only takes a single colour at a time.
In addition, in another file "dataset_dota.py" of "BBAVectors-Oriented-Object-Detection" https://github.com/yijingru/BBAVectors-Oriented-Object-Detection/blob/master/datasets/dataset_dota.py I found the assigned colours to each objects category.
class DOTA(BaseDataset):
def __init__(self, data_dir, phase, input_h=None, input_w=None, down_ratio=None):
super(DOTA, self).__init__(data_dir, phase, input_h, input_w, down_ratio)
self.category = ['plane',
'baseball-diamond',
'bridge',
'ground-track-field',
'small-vehicle',
'large-vehicle',
'ship',
'tennis-court',
'basketball-court',
'storage-tank',
'soccer-ball-field',
'roundabout',
'harbor',
'swimming-pool',
'helicopter'
]
self.color_pans = [(204,78,210),
(0,192,255),
(0,131,0),
(240,176,0),
(254,100,38),
(0,0,255),
(182,117,46),
(185,60,129),
(204,153,255),
(80,208,146),
(0,0,204),
(17,90,197),
(0,255,255),
(102,255,102),
(255,255,0)]
self.num_classes = len(self.category)
self.cat_ids = {cat:i for i,cat in enumerate(self.category)}
self.img_ids = self.load_img_ids()
self.image_path = os.path.join(data_dir, 'images')
self.label_path = os.path.join(data_dir, 'labelTxt')
I am fresher in Python and Opencv. I will be thankful if someone can help me to link these files and show the detected objects in different colour bounding boxes or another method to show the different object categories in different colour bounding boxes. Thank you
In the current version the detected objects are shown as follows:
Here is a snippet :
# Initialize the DOTA Class
dota_object = DOTA(data_dir, phase)
# Get color
object = 'plane'
id = dota_object.category.index(object)
color = dota_object.color_pans[id]
# Display the image
ori_image = cv2.drawContours(ori_image, [np.int0(box)], -1, color,1,1)
Replace the variables with the ones in your code ( ori_image
, dota_object
, data_dir
, phase
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.