Пример #1
0
def _copy_info_csv(source_folder, destination_folder):
    # TODO: The iMotions export still relies on the old-style info.csv, so we have to
    # generate this here manually. We should clarify with iMotions whether we can update
    # this to our new recording format.
    recording = PupilRecording(source_folder)
    meta = recording.meta_info

    # NOTE: This is potentially incorrect, since we don't know the timezone. But we are
    # keeping this format for backwards compatibility with the old-style info.csv.
    start_datetime = datetime.datetime.fromtimestamp(meta.start_time_system_s)
    start_date = start_datetime.strftime("%d.%m.%Y")
    start_time = start_datetime.strftime("%H:%M:%S")

    duration_full_s = meta.duration_s
    duration_h = int(duration_full_s // 3600)
    duration_m = int((duration_full_s % 3600) // 60)
    duration_s = int(round(duration_full_s % 3600 % 60))
    duration_time = f"{duration_h:02}:{duration_m:02}:{duration_s:02}"

    try:
        world_video = recording.files().core().world().videos()[0]
    except IndexError:
        logger.error(
            "Error while exporting iMotions data. World video not found!")
        return

    cap = File_Source(SimpleNamespace(), world_video)
    world_frames = cap.get_frame_count()
    world_resolution = f"{cap.frame_size[0]}x{cap.frame_size[1]}"

    data = {}
    data["Recording Name"] = meta.recording_name
    data["Start Date"] = start_date
    data["Start Time"] = start_time
    data["Start Time (System)"] = meta.start_time_system_s
    data["Start Time (Synced)"] = meta.start_time_synced_s
    data["Recording UUID"] = str(meta.recording_uuid)
    data["Duration Time"] = duration_time
    data["World Camera Frames"] = world_frames
    data["World Camera Resolution"] = world_resolution
    data["Capture Software Version"] = meta.recording_software_version
    data["Data Format Version"] = str(meta.min_player_version)
    data["System Info"] = meta.system_info

    info_dest = os.path.join(destination_folder, "iMotions_info.csv")
    with open(info_dest, "w", newline="", encoding="utf-8") as f:
        csv_utils.write_key_value_file(f, data)
Пример #2
0
def generate_frames(g_pool):
    recording = PupilRecording(g_pool.rec_dir)
    video_path = recording.files().world().videos()[0]

    fs = File_Source(g_pool, source_path=video_path, fill_gaps=True)

    total_frame_count = fs.get_frame_count()

    while True:
        try:
            current_frame = fs.get_frame()
        except EndofVideoError:
            break

        progress = current_frame.index / total_frame_count

        yield progress, current_frame