Example #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", ".mkv")
        ]
        existing_locs = [loc for loc in potential_locs if os.path.exists(loc)]
        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
        rec, file_ = os.path.split(existing_locs[0])
        set_name = os.path.splitext(file_)[0]
        self.videoset = VideoSet(rec, set_name, fill_gaps=False)
        self.videoset.load_or_build_lookup()
        timestamp_len = (self.videoset.lookup.container_idx > -1).sum()
        if not timestamp_len:
            logger.error(
                "no timestamps for eye video for eye '{}' found.".format(
                    eye_id))
            self.detection_status[eye_id] = "No eye video found."
            return
        video_loc = existing_locs[0]
        self.eye_frame_num[eye_id] = timestamp_len

        capure_settings = "File_Source", {
            "source_path": video_loc,
            "timing": None
        }
        self.notify_all({
            "subject": "eye_process.should_start",
            "eye_id": eye_id,
            "overwrite_cap_settings": capure_settings,
        })
        self.eye_video_loc[eye_id] = video_loc
        self.detection_status[eye_id] = "Detecting..."
Example #2
0
def generate_frame_indices_with_deserialized_gaze(g_pool):
    recording = PupilRecording(g_pool.rec_dir)
    video_name = recording.files().world().videos()[0].stem

    videoset = VideoSet(rec=g_pool.rec_dir, name=video_name, fill_gaps=True)
    videoset.load_or_build_lookup()

    frame_indices = np.flatnonzero(videoset.lookup.container_idx > -1)
    frame_count = len(frame_indices)

    for frame_index in frame_indices:
        progress = (frame_index + 1) / frame_count
        frame_ts_window = pm.enclosing_window(g_pool.timestamps, frame_index)
        gaze_data = g_pool.gaze_positions.by_ts_window(frame_ts_window)
        gaze_data = [(frame_index, g["timestamp"], g["norm_pos"][0],
                      g["norm_pos"][1]) for g in gaze_data
                     if g["confidence"] >= g_pool.min_data_confidence]
        gaze_data = scan_path_numpy_array_from(gaze_data)
        yield progress, gaze_data