Exemple #1
0
    def start_eye_process(self, eye_id):
        potential_locs = [
            os.path.join(self.g_pool.rec_dir, 'eye{}{}'.format(eye_id, ext))
            for ext in ('.mjpeg', '.mp4')
        ]
        existing_locs = [loc for loc in potential_locs if os.path.exists(loc)]
        timestamps_path = os.path.join(self.g_pool.rec_dir,
                                       'eye{}_timestamps.npy'.format(eye_id))

        if not existing_locs:
            logger.error("no eye video for eye '{}' found.".format(eye_id))
            self.detection_status[eye_id] = "No eye video found!"
            return
        if not os.path.exists(timestamps_path):
            logger.error(
                "no timestamps for eye video for eye '{}' found.".format(
                    eye_id))
            return

        video_loc = existing_locs[0]
        ts = np.load(timestamps_path)
        self.detection_progress[eye_id] = 0.
        capure_settings = 'File_Source', {
            'source_path': video_loc,
            'timestamps': ts,
            'timed_playback': False
        }
        eye_p = Process(target=eye,
                        name='eye{}'.format(eye_id),
                        args=(Value(c_double, 0), self.eyes_are_alive[eye_id],
                              self.ipc_pub_url, self.ipc_sub_url,
                              self.ipc_push_url, self.g_pool.user_dir,
                              self.g_pool.version, eye_id, capure_settings))
        eye_p.start()
        eye_p.video_path = video_loc
        eye_p.min_ts = ts[0]
        eye_p.max_ts = ts[-1]
        self.eye_processes[eye_id] = eye_p
        self.detection_status[eye_id] = "Detecting..."