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()
    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()
    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')
    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')