def test_compute_procrustes_aligned_mpjpes_case_6(self):
     target_points = tf.constant([[2.0, 2.0, 2.0], [-1.5, -1.0, 0.0],
                                  [2.5, 1.3, 1.4]])
     source_points = tf.constant([[1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                  [1.0, 1.0, 1.0]])
     mpjpes = keypoint_utils.compute_procrustes_aligned_mpjpes(
         target_points, source_points)
     self.assertAlmostEqual(self.evaluate(mpjpes), 0.3496029, places=5)
 def test_compute_procrustes_aligned_mpjpes_case_3(self):
     target_points = tf.constant([[1.0, 1.0, 0.0], [5.0, 2.0, 2.0],
                                  [4.0, 0.0, 0.0], [-1.0, -2.0, 3.0]])
     source_points = tf.constant([[1.5, 0.5, 0.0], [5.0, 2.0, 2.2],
                                  [4.1, 0.0, -1.0], [-1.0, -2.5, -2.0]])
     mpjpes = keypoint_utils.compute_procrustes_aligned_mpjpes(
         target_points, source_points)
     self.assertAlmostEqual(self.evaluate(mpjpes), 1.00227, places=5)
 def test_compute_procrustes_aligned_mpjpes_case_4(self):
   target_points = tf.constant([[1.0, 1.0, 0.0], [5.0, 2.0, 2.0],
                                [4.0, 0.0, 0.0], [-1.0, -2.0, 3.0]])
   source_points = tf.constant([[-10.0, -24.5, -49.5], [-9.0, -22.5, -49.0],
                                [-10.0, -23.0, -50.0], [-8.5, -25.5, -51.0]])
   mpjpes = keypoint_utils.compute_procrustes_aligned_mpjpes(
       target_points, source_points)
   self.assertAlmostEqual(self.evaluate(mpjpes), 0.0, places=5)
 def test_compute_procrustes_aligned_mpjpes_case_1(self):
     target_points = tf.constant([[[1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                   [1.0, 1.0, 1.0]],
                                  [[2.0, 2.0, 2.0], [-1.5, -1.0, 0.0],
                                   [2.5, 1.3, 1.4]]])
     source_points = tf.constant([[[2.0, 2.0, 2.0], [-1.5, -1.0, 0.0],
                                   [2.5, 1.3, 1.4]],
                                  [[1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                   [1.0, 1.0, 1.0]]])
     mpjpes = keypoint_utils.compute_procrustes_aligned_mpjpes(
         target_points, source_points)
     self.assertAllClose(mpjpes, [0.133016, 0.3496029])
 def test_compute_procrustes_aligned_mpjpes_with_masks(self):
   # Shape = [5, 3].
   target_points = tf.constant([[2.0, 2.0, 2.0], [-1.5, -1.0, 0.0],
                                [100.0, 200.0, 300.0], [2.5, 1.3, 1.4],
                                [400.0, 500.0, 600.0]])
   source_points = tf.constant([[1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                [700.0, 800.0, 900.0], [1.0, 1.0, 1.0],
                                [800.0, 700.0, 600.0]])
   # Shape = [5].
   point_masks = tf.constant([1.0, 1.0, 0.0, 1.0, 0.0])
   mpjpes = keypoint_utils.compute_procrustes_aligned_mpjpes(
       target_points, source_points, point_masks=point_masks)
   self.assertAlmostEqual(self.evaluate(mpjpes), 0.3496029, places=5)