(img, class_label_map, class_boxes_map)
return img
this method using cv2 to show boxes on image with various class labels
    :param img:
    :param class_label_map: {1: 'Car', 2: 'Pedestrian'}
    :param class_boxes_map: {1: [box1, box2..], 2: [..]}, in every box is [bb_left, bb_top, bb_width, bb_height, prob]
    :return:
this method using cv2 to show boxes on image with various class labels
    :param img:
    :param class_label_map: {1: 'Car', 2: 'Pedestrian'}
    :param class_boxes_map: {1: [box1, box2..], 2: [..]}, in every box is [bb_left, bb_top, bb_width, bb_height, prob]
    :return:
this method using cv2 to show boxes on image with various class labels : param img : : param class_label_map : { 1 : Car 2 : Pedestrian } : param class_boxes_map : { 1 : [ box1 box2 .. ] 2 : [ .. ] } in every box is [ bb_left bb_top bb_width bb_height prob ] : return :
def draw_boxes_and_label_on_image_cv2(img, class_label_map, class_boxes_map):
    """
    this method using cv2 to show boxes on image with various class labels
    :param img:
    :param class_label_map: {1: 'Car', 2: 'Pedestrian'}
    :param class_boxes_map: {1: [box1, box2..], 2: [..]}, in every box is [bb_left, bb_top, bb_width, bb_height, prob]
    :return:
    """
    for c, boxes in class_boxes_map.items():
        for box in boxes:
            assert len(box) == 5, 'class_boxes_map every item must be [bb_left, bb_top, bb_width, bb_height, prob]'
            # checking box order is bb_left, bb_top, bb_width, bb_height
            # make sure all box should be int for OpenCV
            bb_left = int(box[0])
            bb_top = int(box[1])
            bb_width = int(box[2])
            bb_height = int(box[3])

            # prob will round 2 digits
            prob = round(box[4], 2)
            unique_color = _create_unique_color_uchar(c)
            cv2.rectangle(img, (bb_left, bb_top), (bb_width, bb_height), unique_color, 2)

            text_label = '{} {}'.format(class_label_map[c], prob)
            (ret_val, base_line) = cv2.getTextSize(text_label, cv2.FONT_HERSHEY_COMPLEX, 1, 1)
            text_org = (bb_left, bb_top - 0)

            cv2.rectangle(img, (text_org[0] - 5, text_org[1] + base_line - 5),
                          (text_org[0] + ret_val[0] + 5, text_org[1] - ret_val[1] + 5), unique_color, 2)
            # this rectangle for fill text rect
            cv2.rectangle(img, (text_org[0] - 5, text_org[1] + base_line - 5),
                          (text_org[0] + ret_val[0] + 5, text_org[1] - ret_val[1] + 5),
                          unique_color, -1)
            cv2.putText(img, text_label, text_org, cv2.FONT_HERSHEY_DUPLEX, 0.6, (255, 255, 255), 1)
    return img
def draw_boxes_and_label_on_image_cv2 ( img , class_label_map , class_boxes_map ) : for c , boxes in class_boxes_map . items ( ) : for box in boxes : assert len ( box ) == 5 , 'class_boxes_map every item must be [bb_left, bb_top, bb_width, bb_height, prob]' # checking box order is bb_left, bb_top, bb_width, bb_height # make sure all box should be int for OpenCV bb_left = int ( box [ 0 ] ) bb_top = int ( box [ 1 ] ) bb_width = int ( box [ 2 ] ) bb_height = int ( box [ 3 ] ) # prob will round 2 digits prob = round ( box [ 4 ] , 2 ) unique_color = _create_unique_color_uchar ( c ) cv2 . rectangle ( img , ( bb_left , bb_top ) , ( bb_width , bb_height ) , unique_color , 2 ) text_label = '{} {}' . format ( class_label_map [ c ] , prob ) ( ret_val , base_line ) = cv2 . getTextSize ( text_label , cv2 . FONT_HERSHEY_COMPLEX , 1 , 1 ) text_org = ( bb_left , bb_top - 0 ) cv2 . rectangle ( img , ( text_org [ 0 ] - 5 , text_org [ 1 ] + base_line - 5 ) , ( text_org [ 0 ] + ret_val [ 0 ] + 5 , text_org [ 1 ] - ret_val [ 1 ] + 5 ) , unique_color , 2 ) # this rectangle for fill text rect cv2 . rectangle ( img , ( text_org [ 0 ] - 5 , text_org [ 1 ] + base_line - 5 ) , ( text_org [ 0 ] + ret_val [ 0 ] + 5 , text_org [ 1 ] - ret_val [ 1 ] + 5 ) , unique_color , - 1 ) cv2 . putText ( img , text_label , text_org , cv2 . FONT_HERSHEY_DUPLEX , 0.6 , ( 255 , 255 , 255 ) , 1 ) return img