示例#1
0
def test_file_source_recent_events():
    '''
    recent_events setup correct or not
    '''
    file_source = File_Source(Empty(),
                              source_path=single_data,
                              timing="external")
    assert file_source.recent_events == file_source.recent_events_external_timing
    file_source = File_Source(Empty(), source_path=single_data, timing=None)
    assert file_source.recent_events == file_source.recent_events_own_timing
示例#2
0
def test_file_source_recent_events():
    """
    recent_events setup correct or not
    """
    file_source = File_Source(
        SimpleNamespace(), source_path=single_data, timing="external"
    )
    assert file_source.recent_events == file_source.recent_events_external_timing
    file_source = File_Source(SimpleNamespace(), source_path=single_data, timing=None)
    assert file_source.recent_events == file_source.recent_events_own_timing
示例#3
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)
示例#4
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
示例#5
0
def test_file_source_not_source_path(caplog):
    """
    Failed if we don't pass source_path to file_source
    """
    caplog.set_level(logging.INFO)
    with pytest.raises(AssertionError) as excinfo:
        _ = File_Source(SimpleNamespace())
    assert "Init failed. Source file could not be found at" in caplog.text
示例#6
0
def test_file_source_not_source_path(caplog):
    '''
    Failed if we don't pass source_path to file_source
    '''
    caplog.set_level(logging.INFO)
    with pytest.raises(AssertionError) as excinfo:
        _ = File_Source(Empty())
    assert ("Init failed. Source file could not be found at" in caplog.text)
示例#7
0
文件: __init__.py 项目: zcyroot/pupil
def _generate_all_lookup_tables(rec_dir: str):
    recording = PupilRecording(rec_dir)
    videosets = [
        recording.files().core().world().videos(),
        recording.files().core().eye0().videos(),
        recording.files().core().eye1().videos(),
    ]
    for videos in videosets:
        if not videos:
            continue
        File_Source(
            SimpleNamespace(), source_path=videos[0], fill_gaps=True, timing=None
        )
示例#8
0
def broken_fill_gaps():
    """Returns broken data"""
    return File_Source(SimpleNamespace(), source_path=broken_data)
示例#9
0
def multiple_fill_gaps():
    """Returns multiple data"""
    return File_Source(SimpleNamespace(),
                       source_path=multiple_data,
                       fill_gaps=True)
示例#10
0
def single_fill_gaps():
    """Returns single data"""
    return File_Source(SimpleNamespace(),
                       source_path=single_data,
                       fill_gaps=True)
示例#11
0
def broken_fill_gaps():
    '''Returns broken data'''
    return File_Source(Empty(), source_path=broken_data)
示例#12
0
def multiple_fill_gaps():
    '''Returns multiple data'''
    return File_Source(Empty(), source_path=multiple_data, fill_gaps=True)
示例#13
0
def single_fill_gaps():
    '''Returns single data'''
    return File_Source(Empty(), source_path=single_data, fill_gaps=True)