(img,
                    coors_range,
                    boxes,
                    color,
                    thickness=1,
                    labels=None,
                    label_color=None)
return img
Args:
        boxes: center format.
Args:
        boxes: center format.
Args : boxes : center format .
def draw_box_in_bev(img,
                    coors_range,
                    boxes,
                    color,
                    thickness=1,
                    labels=None,
                    label_color=None):
    """
    Args:
        boxes: center format.
    """
    coors_range = np.array(coors_range)
    bev_corners = box_np_ops.center_to_corner_box2d(
        boxes[:, [0, 1]], boxes[:, [3, 4]], boxes[:, 6])
    bev_corners -= coors_range[:2]
    bev_corners *= np.array(
        img.shape[:2])[::-1] / (coors_range[3:5] - coors_range[:2])
    standup = box_np_ops.corner_to_standup_nd(bev_corners)
    text_center = standup[:, 2:]
    text_center[:, 1] -= (standup[:, 3] - standup[:, 1]) / 2

    bev_lines = np.concatenate(
        [bev_corners[:, [0, 2, 3]], bev_corners[:, [1, 3, 0]]], axis=2)
    bev_lines = bev_lines.reshape(-1, 4)
    colors = np.tile(np.array(color).reshape(1, 3), [bev_lines.shape[0], 1])
    colors = colors.astype(np.int32)
    img = cv2_draw_lines(img, bev_lines, colors, thickness)
    if boxes.shape[1] == 9:
        # draw velocity arrows
        for box in boxes:
            velo = box[-2:]
            # velo = np.array([-np.sin(box[6]), -np.cos(box[6])])
            velo_unified = velo
            if np.isnan(velo_unified[0]):
                continue
            velo_unified = velo_unified * np.array(
                img.shape[:2])[::-1] / (coors_range[3:5] - coors_range[:2])
            center = box[:2] - coors_range[:2]
            center = center * np.array(
                img.shape[:2])[::-1] / (coors_range[3:5] - coors_range[:2])
            center = tuple(map(lambda x: int(x), center))
            center2 = tuple(map(lambda x: int(x), center + velo_unified))
            cv2.arrowedLine(img, center, center2, color, thickness, tipLength=0.3)
    if labels is not None:
        if label_color is None:
            label_color = colors
        else:
            label_color = np.tile(
                np.array(label_color).reshape(1, 3), [bev_lines.shape[0], 1])
            label_color = label_color.astype(np.int32)

        img = cv2_draw_text(img, text_center, labels, label_color,
                            thickness)
    return img
def draw_box_in_bev ( img , coors_range , boxes , color , thickness = 1 , labels = None , label_color = None ) : coors_range = np . array ( coors_range ) bev_corners = box_np_ops . center_to_corner_box2d ( boxes [ : , [ 0 , 1 ] ] , boxes [ : , [ 3 , 4 ] ] , boxes [ : , 6 ] ) bev_corners -= coors_range [ : 2 ] bev_corners *= np . array ( img . shape [ : 2 ] ) [ : : - 1 ] / ( coors_range [ 3 : 5 ] - coors_range [ : 2 ] ) standup = box_np_ops . corner_to_standup_nd ( bev_corners ) text_center = standup [ : , 2 : ] text_center [ : , 1 ] -= ( standup [ : , 3 ] - standup [ : , 1 ] ) / 2 bev_lines = np . concatenate ( [ bev_corners [ : , [ 0 , 2 , 3 ] ] , bev_corners [ : , [ 1 , 3 , 0 ] ] ] , axis = 2 ) bev_lines = bev_lines . reshape ( - 1 , 4 ) colors = np . tile ( np . array ( color ) . reshape ( 1 , 3 ) , [ bev_lines . shape [ 0 ] , 1 ] ) colors = colors . astype ( np . int32 ) img = cv2_draw_lines ( img , bev_lines , colors , thickness ) if boxes . shape [ 1 ] == 9 : # draw velocity arrows for box in boxes : velo = box [ - 2 : ] # velo = np.array([-np.sin(box[6]), -np.cos(box[6])]) velo_unified = velo if np . isnan ( velo_unified [ 0 ] ) : continue velo_unified = velo_unified * np . array ( img . shape [ : 2 ] ) [ : : - 1 ] / ( coors_range [ 3 : 5 ] - coors_range [ : 2 ] ) center = box [ : 2 ] - coors_range [ : 2 ] center = center * np . array ( img . shape [ : 2 ] ) [ : : - 1 ] / ( coors_range [ 3 : 5 ] - coors_range [ : 2 ] ) center = tuple ( map ( lambda x : int ( x ) , center ) ) center2 = tuple ( map ( lambda x : int ( x ) , center + velo_unified ) ) cv2 . arrowedLine ( img , center , center2 , color , thickness , tipLength = 0.3 ) if labels is not None : if label_color is None : label_color = colors else : label_color = np . tile ( np . array ( label_color ) . reshape ( 1 , 3 ) , [ bev_lines . shape [ 0 ] , 1 ] ) label_color = label_color . astype ( np . int32 ) img = cv2_draw_text ( img , text_center , labels , label_color , thickness ) return img