Esempio n. 1
0
    def match_targets_to_proposals(self, proposal, target):
        box1, box2 = proposal.bbox, target.bbox

        box1_np = box1.data.cpu().numpy()
        box2_np = box2.data.cpu().numpy()
        ch_box1 = box1_np.copy()
        ch_box11 = ch_box1[:, [0, 1, 3, 4, 6]]
        ch_box2 = box2_np.copy()
        ch_box22 = ch_box2[:, [0, 1, 3, 4, 6]]

        match_quality_matrix2 = box_np_ops.riou_cc(ch_box22, ch_box11)
        match_quality_matrix2 = torch.from_numpy(
            match_quality_matrix2).float().to(box1.device)
        #match_quality_matrix = boxlist_iou(proposal, target)

        #print(match_quality_matrix)
        #print(match_quality_matrix2)
        matched_idxs = self.proposal_matcher(match_quality_matrix2)
        # print('matched_idxs', matched_idxs)
        # Fast RCNN only need "labels" field for selecting the targets
        target = target.copy_with_fields("labels")
        #print("this is target")
        #print(len(target) , target)
        # get the targets corresponding GT for each proposal
        # NB: need to clamp the indices because we can have a single
        # GT in the image, and matched_idxs can be -2, which goes
        # out of bounds
        matched_targets = target[matched_idxs.clamp(min=0)]
        matched_targets.add_field("matched_idxs", matched_idxs)
        return matched_targets
Esempio n. 2
0
    def _compare(self, boxes1, boxes2):
        """Compute pairwise IOU similarity between the two BoxLists.

    Args:
      boxlist1: BoxList holding N boxes.
      boxlist2: BoxList holding M boxes.

    Returns:
      A tensor with shape [N, M] representing pairwise iou scores.
    """

        return box_np_ops.riou_cc(boxes1, boxes2)
Esempio n. 3
0
def bev_box_overlap(boxes, qboxes, criterion=-1, stable=True):
    if USE_GPU:
        riou = rotate_iou_gpu_eval(boxes, qboxes, criterion)
    else:
        riou = box_np_ops.riou_cc(boxes, qboxes)
    return riou
Esempio n. 4
0
def bev_box_overlap(boxes, qboxes, criterion=-1, stable=True):
    riou = box_np_ops.riou_cc(boxes, qboxes)
    return riou
Esempio n. 5
0
            #loading data anti to clock-wise
            rn = ((boxes[n, 0], boxes[n,
                                      1]), (boxes[n,
                                                  2], boxes[n,
                                                            3]), -boxes[n, 4])
            rk = ((query_boxes[k, 0], query_boxes[k, 1]),
                  (query_boxes[k, 2], query_boxes[k, 3]), -query_boxes[k, 4])
            int_pts = cv2.rotatedRectangleIntersection(rk, rn)[1]

            if int_pts is not None:
                order_pts = cv2.convexHull(int_pts, returnPoints=True)
                int_area = cv2.contourArea(order_pts)
                overlaps[n, k] = int_area * 1.0 / (query_area + box_area -
                                                   int_area)
    return overlaps


# (x,y,w,l,r)
box1 = np.array([[0, 0, 2, 2, 0.3]], dtype=np.float32)
box2 = np.array([[2, 0, 4, 1, 0.3]], dtype=np.float32)
iou1 = rotate_iou_gpu(box1, box2)  # 1/7
print(iou1)

iou2 = riou_cc(box1, box2)  # 1/7
print(iou2)

box1[..., [0, 1]] += 100
box2[..., [0, 1]] += 100
iou3 = cv2_rbbx_overlaps(box1, box2)
print(iou3)
Esempio n. 6
0
def bev_box_overlap(boxes, qboxes, criterion=-1, stable=False):
    if stable:
        riou = box_np_ops.riou_cc(boxes, qboxes)
    else:
        riou = rotate_iou_gpu_eval(boxes, qboxes, criterion)
    return riou