def testIsWithinRotatedBBox(self): bbox = tf.constant([[[.2, 0.], [1., .2], [.8, 1.], [0., .8]]], dtype=tf.float32) points = tf.constant([[0., 0.], [1., 0], [1., 1.], [0., 1.], [.5, .5]], dtype=tf.float32) with self.session() as sess: is_inside = sess.run(geometry.IsWithinBBox(points, bbox)) expected = [[False]] * 4 + [[True]] self.assertAllEqual(expected, is_inside)
def testIsWithinBBox(self): bbox = tf.constant([[[0., 0.], [1., 0.], [1., 1.], [0., 1.]]], dtype=tf.float32) points = tf.constant( [[-.5, -.5], [.5, -.5], [1.5, -.5], [1.5, .5], [1.5, 1.5], [.5, 1.5], [-.5, 1.5], [-.5, .5], [1., 1.], [.5, .5]], dtype=tf.float32) with self.session(): is_inside = self.evaluate(geometry.IsWithinBBox(points, bbox)) expected = [[False]] * 8 + [[True]] * 2 self.assertAllEqual(expected, is_inside)