BossZard / rotation-yolov5

rotation detection based on yolov5
GNU General Public License v3.0
377 stars 97 forks source link

the function of def rectlong2opencv(boxes) #15

Open cs-heibao opened 3 years ago

cs-heibao commented 3 years ago

可以解释一下这个函数吗?

def rectlong2opencv(boxes):

    boxes_ = boxes.copy()
    boxes_[boxes[..., 4] < 0, 2] = boxes[boxes[..., 4] < 0, 3]
    boxes_[boxes[..., 4] < 0, 3] = boxes[boxes[..., 4] < 0, 2]
    boxes_[boxes[..., 4] >= 0, 4] = boxes[boxes[..., 4] >= 0, 4] - 90
    gt_box = boxes_.copy()
    gt_box[..., 2] = boxes_[..., 3]
    gt_box[..., 3] = boxes_[..., 2]
    return gt_box
boxes_[boxes[..., 4] < 0, 2] = boxes[boxes[..., 4] < 0, 3]
boxes_[boxes[..., 4] < 0, 3] = boxes[boxes[..., 4] < 0, 2]
这里第三四个参数互换,然后下面又换了过来
gt_box[..., 2] = boxes_[..., 3]
gt_box[..., 3] = boxes_[..., 2]
BossZard commented 3 years ago

意思就是长短边表示旋转矩形格式转换为opencv表示的格式,方便后面使用opencv函数处理box