Exemplo n.º 1
0
 def test_iov3d_7dof_box(self):
     boxes1 = np.array(
         [[_degree_to_radians(0.1), 10.0, 20.0, 30.0, 5.0, 6.0, 4.0],
          [_degree_to_radians(0.2), 4.0, 5.0, 10.0, -1.0, 2.0, 3.0],
          [_degree_to_radians(-0.2), 4.0, 5.0, 1.0, -1.0, -2.0, 3.0]],
         dtype=np.float32)
     (rotation_z_radians1, length1, height1, width1,
      center1) = _decompose_box_tensor(boxes1)
     boxes2 = np.array(
         [[_degree_to_radians(0.1), 10.0, 20.0, 30.0, 5.0, 6.0, 4.0],
          [_degree_to_radians(0.2), 4.0, 5.0, 10.0, -1.0, 2.0, 3.0],
          [_degree_to_radians(-0.2), 4.0, 5.0, 1.0, -1.0, -2.0, 3.0],
          [_degree_to_radians(-0.2), 4.0, 5.0, 1.0, 100.0, 100.0, 100.0]],
         dtype=np.float32)
     (rotation_z_radians2, length2, height2, width2,
      center2) = _decompose_box_tensor(boxes2)
     iov = np_box_ops.iov3d_7dof_box(
         boxes1_length=length1,
         boxes1_height=height1,
         boxes1_width=width1,
         boxes1_center=center1,
         boxes1_rotation_z_radians=rotation_z_radians1,
         boxes2_length=length2,
         boxes2_height=height2,
         boxes2_width=width2,
         boxes2_center=center2,
         boxes2_rotation_z_radians=rotation_z_radians2)
     expected_iov = np.array(
         [[1.0, 0.25, 0.25, 0.0], [0.008, 1.0, 0.2, 0.0],
          [0.0008, 0.2, 1.0, 0.0]],
         dtype=np.float32)
     self.assertAllClose(iov, expected_iov, rtol=0.1, atol=1.0)
Exemplo n.º 2
0
def iov3d(boxlist1, boxlist2):
    """Computes pairwise intersection-over-volume between box collections.

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

  Returns:
    a numpy array with shape [N, M] representing pairwise iov scores.
  """
    boxlist1_rotation_matrix = boxlist1.get_rotation_matrix()
    boxlist2_rotation_matrix = boxlist2.get_rotation_matrix()
    if (boxlist1_rotation_matrix is not None) and (boxlist2_rotation_matrix
                                                   is not None):
        return np_box_ops.iov3d_9dof_box(
            boxes1_length=boxlist1.get_length(),
            boxes1_height=boxlist1.get_height(),
            boxes1_width=boxlist1.get_width(),
            boxes1_center=boxlist1.get_center(),
            boxes1_rotation_matrix=boxlist1.get_rotation_matrix(),
            boxes2_length=boxlist2.get_length(),
            boxes2_height=boxlist2.get_height(),
            boxes2_width=boxlist2.get_width(),
            boxes2_center=boxlist2.get_center(),
            boxes2_rotation_matrix=boxlist2.get_rotation_matrix())
    else:
        return np_box_ops.iov3d_7dof_box(
            boxes1_length=boxlist1.get_length(),
            boxes1_height=boxlist1.get_height(),
            boxes1_width=boxlist1.get_width(),
            boxes1_center=boxlist1.get_center(),
            boxes1_rotation_z_radians=boxlist1.get_rotation_z_radians(),
            boxes2_length=boxlist2.get_length(),
            boxes2_height=boxlist2.get_height(),
            boxes2_width=boxlist2.get_width(),
            boxes2_center=boxlist2.get_center(),
            boxes2_rotation_z_radians=boxlist2.get_rotation_z_radians())