Пример #1
0
 def testTransformBBoxes3DConsistentWithPoints(self):
   num_boxes, num_points = 20, 100
   points = tf.random_uniform((num_points, 3))
   bboxes_3d = tf.random_uniform((num_boxes, 7))
   in_bboxes = geometry.IsWithinBBox3D(points, bboxes_3d)
   transforms = self._MakeTransformTestTranslationMatrices(1)[0]
   points_transformed = geometry.TransformPoints(points, transforms)
   bboxes_3d_transformed = geometry.TransformBBoxes3D(bboxes_3d, transforms)
   in_bboxes_transformed = geometry.IsWithinBBox3D(points_transformed,
                                                   bboxes_3d_transformed)
   with self.session() as sess:
     actual_in_bboxes, actual_in_bboxes_transformed = sess.run(
         (in_bboxes, in_bboxes_transformed))
   self.assertAllEqual(actual_in_bboxes, actual_in_bboxes_transformed)
Пример #2
0
  def testTransformBBoxes3D(self):
    batch_size, num_boxes = 10, 20
    bboxes_3d = tf.random_uniform((batch_size, num_boxes, 7))
    transforms = self._MakeTransformTestTranslationMatrices(batch_size)
    bboxes_3d_transformed = geometry.TransformBBoxes3D(bboxes_3d, transforms)
    with self.session() as sess:
      actual_bboxes_3d, actual_bboxes_3d_transformed = sess.run(
          (bboxes_3d, bboxes_3d_transformed))

    self.assertAllEqual(actual_bboxes_3d.shape,
                        actual_bboxes_3d_transformed.shape)

    # Dimensions (slice 3:6) should remain unchanged.
    self.assertAllClose(actual_bboxes_3d[..., 3:6],
                        actual_bboxes_3d_transformed[..., 3:6])

    # Rotation should remain unchanged.
    self.assertAllClose(actual_bboxes_3d[..., 6],
                        actual_bboxes_3d_transformed[..., 6])

    # Center xyz should be different.
    self.assertNotAllClose(actual_bboxes_3d[..., :3],
                           actual_bboxes_3d_transformed[..., :3])