Ejemplo n.º 1
0
    def test_face_in_out(self):
        face_event_msg, face_location_msg = None, None
        fps = 25
        wait = 1.0/fps
        for _, _, _ in rosbag_msg_generator(get_rosbag_file('face')):
            face_location_msg, face_event_msg = wait_for_messages(
                ['/camera/face_locations', '/camera/face_event'],
                [Faces, FaceEvent], wait)
            if face_location_msg and face_location_msg.faces:
                self.assertEqual(len(face_location_msg.faces), 1)
                face = face_location_msg.faces[0]
                self.assertGreater(face.attention, 0.99)
            if face_event_msg:
                self.assertEqual(face_event_msg.face_event, 'new_face')

        for _, _, _ in rosbag_msg_generator(get_rosbag_file('empty')):
            face_event_msg = wait_for_message(
                '/camera/face_event', FaceEvent, wait)
            if face_event_msg:
                self.assertEqual(face_event_msg.face_event, 'lost_face')
Ejemplo n.º 2
0
    def test_face_in_out(self):
        face_event_msg, face_location_msg = None, None
        fps = 25
        wait = 1.0/fps
        for _, _, _ in rosbag_msg_generator(get_rosbag_file('face')):
            face_location_msg, face_event_msg = wait_for_messages(
                ['/camera/face_locations', '/camera/face_event'],
                [Faces, FaceEvent], wait)
            if face_location_msg and face_location_msg.faces:
                self.assertEqual(len(face_location_msg.faces), 1)
                face = face_location_msg.faces[0]
                self.assertGreater(face.attention, 0.99)
            if face_event_msg:
                self.assertEqual(face_event_msg.face_event, 'new_face')

        for _, _, _ in rosbag_msg_generator(get_rosbag_file('empty')):
            face_event_msg = wait_for_message(
                '/camera/face_event', FaceEvent, wait)
            if face_event_msg:
                self.assertEqual(face_event_msg.face_event, 'lost_face')
Ejemplo n.º 3
0
    def test_noface(self):
        bag_file = get_rosbag_file('empty')
        job = play_rosbag([bag_file, '-q'])
        face_event_msg, face_location_msg = None, None
        fps = 25
        wait = 1.0/fps
        while job.is_alive():
            face_location_msg, face_event_msg = wait_for_messages(
                ['/camera/face_locations', '/camera/face_event'],
                [Faces, FaceEvent], wait)
            self.assertFalse(bool(face_location_msg))
            self.assertFalse(bool(face_event_msg))

        job.join()
Ejemplo n.º 4
0
    def test_noface(self):
        bag_file = get_rosbag_file('empty')
        job = play_rosbag([bag_file, '-q'])
        face_event_msg, face_location_msg = None, None
        fps = 25
        wait = 1.0/fps
        while job.is_alive():
            face_location_msg, face_event_msg = wait_for_messages(
                ['/camera/face_locations', '/camera/face_event'],
                [Faces, FaceEvent], wait)
            self.assertFalse(face_location_msg)
            self.assertFalse(face_event_msg)

        job.join()
Ejemplo n.º 5
0
 def test_long_viseme(self):
     filename = get_rosbag_file("long_viseme")
     # job = play_rosbag(filename)
     # job.join()
     pub, msg_class = rostopic.create_publisher("/blender_api/queue_viseme", "blender_api_msgs/Viseme", True)
     bag = rosbag.Bag(filename)
     duration = bag.get_end_time() - bag.get_start_time()
     fps = bag.get_message_count() / float(duration)
     wait = 1.0 / fps / 10  # 10 times faster than the speed of the msg recoreded
     for topic, msg, _ in rosbag_msg_generator(filename):
         pub.publish(msg)
         time.sleep(wait)
     # Test if blender is still alive
     self.assertIn("/blender_api", rosnode.get_node_names())
     self.assertTrue(any(["blender_api" in name for name in self.runner.pm.get_active_names()]))
Ejemplo n.º 6
0
 def test_long_viseme(self):
     filename = get_rosbag_file('long_viseme')
     #job = play_rosbag(filename)
     #job.join()
     pub, msg_class = rostopic.create_publisher('/blender_api/queue_viseme',
                                                'blender_api_msgs/Viseme',
                                                True)
     bag = rosbag.Bag(filename)
     duration = bag.get_end_time() - bag.get_start_time()
     fps = bag.get_message_count() / float(duration)
     wait = 1.0 / fps / 10  # 10 times faster than the speed of the msg recoreded
     for topic, msg, _ in rosbag_msg_generator(filename):
         pub.publish(msg)
         time.sleep(wait)
     # Test if blender is still alive
     self.assertIn('/blender_api', rosnode.get_node_names())
     self.assertTrue(
         any([
             'blender_api' in name
             for name in self.runner.pm.get_active_names()
         ]))