pupil_recording_interface.VideoReader

class pupil_recording_interface.VideoReader(folder, stream='world', color_format=None, norm_pos=None, roi_size=None, interpolation_method='linear', video_offset=0.0, subsampling=None, undistort=False)

Reader for video data.

__init__(folder, stream='world', color_format=None, norm_pos=None, roi_size=None, interpolation_method='linear', video_offset=0.0, subsampling=None, undistort=False)

Constructor.

Parameters
  • folder (str or pathlib.Path) – Path to the recording folder.

  • stream (str, default 'world') – The name of the video stream to read.

  • color_format (str, optional) – If ‘gray’, convert video frames to grayscale.

  • norm_pos (xarray DataArray, optional) – If specified, extract an ROI around the norm pos for each frame. The DataArray must contain a coordinate named ‘time’ with the timestamps which will be used to match the timestamps of the video frames. The parameter roi_size must also be specified.

  • roi_size (int, optional) – The size of the ROI in pixels (see norm_pos).

  • interpolation_method (str, default 'linear') – Interpolation method for matching norm pos timestamps with video timestamps (see norm_pos).

  • video_offset (float, default 0.) – The offset of the video frames wrt to their recorded timestamps. It might be necessary to adjust this in order to fix synchronization issues between norm pos timestamps and video timestamps (see norm_pos).

  • subsampling (float, optional) – If specified, sub-sample each frame by this factor. Sub-sampling is applied before ROI extraction.

Methods

__init__(folder[, stream, color_format, …])

Constructor.

convert_color(frame)

Convert color format of a video frame.

convert_to_uint8(frame)

Convert a video frame to uint8 dtype.

get_roi(frame, norm_pos)

Extract the ROI from a video frame.

load_dataset([dropna, start, end])

Load video data as an xarray Dataset

load_frame([idx, return_timestamp])

Load a single processed video frame.

load_pldata(topic)

Load data from a .pldata file as a list of dicts.

load_raw_frame([idx])

Load a single un-processed video frame.

load_timestamps()

Load the timestamps for the video file.

process_frame(frame[, norm_pos])

Process a video frame.

read_frames([start, end, raw, …])

Generator for frames.

save_pldata(topic, data)

Save data from a list of dicts as a .pldata file.

subsample_frame(frame)

Sub-sample a video frame.

undistort_frame(frame)

Un-distort a video frame.

undistort_point(point)

Un-distort a two-dimensional point.

write_netcdf([filename])

Export data to netCDF.

Attributes

current_frame_index

Index of current video frame.

export_name

Name of exported files.

video_info

Video metadata.