def test_intersection3d_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) intersections = np_box_ops.intersection3d_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_intersections = np.array( [[6000.0, 49.91, 4.492, 0.0], [49.91, 200.0, 19.93, 0.0], [4.492, 19.93, 20.0, 0.0]], dtype=np.float32) self.assertAllClose(intersections, expected_intersections, rtol=0.1, atol=1.0)
def intersection3d(boxlist1, boxlist2): """Computes pairwise intersection areas between boxes. Args: boxlist1: BoxList3d holding N boxes. boxlist2: BoxList3d holding M boxes. Returns: a numpy array with shape [N*M] representing pairwise intersection area """ 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.intersection3d_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_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_rotation_matrix) else: return np_box_ops.intersection3d_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())