Scene video class#
- class pyneon.video.NeonVideo(video_file: Path, timestamps_file: Path, info_file: Path)#
Bases:
VideoCapture
Loaded video file with timestamps.
- Parameters:
video_file (
pathlib.Path
) – Path to the video file.timestamps_file (
pathlib.Path
) – Path to the timestamps file.
- timestamps#
Timestamps of the video frames in nanoseconds.
- Type:
np.ndarray
- ts#
Alias for timestamps.
- Type:
np.ndarray
- plot_frame(index: int = 0, ax: Axes | None = None, auto_title: bool = True, show: bool = True)#
Plot a frame from the video on a matplotlib axis.
- Parameters:
index (int) – Index of the frame to plot.
ax (
matplotlib.pyplot.Axes
or None) – Axis to plot the frame on. IfNone
, a new figure is created. Defaults toNone
.auto_title (bool) – Whether to automatically set the title of the axis. The automatic title includes the video file name and the frame index. Defaults to
True
.
- Returns:
fig (
matplotlib.pyplot.Figure
) – Figure object containing the plot.ax (
matplotlib.pyplot.Axes
) – Axis object containing the plot.
- pyneon.video.sync_gaze_to_video(rec: NeonRecording, window_size: int | None = None) DataFrame #
Synchronize gaze data to video frames by applying windowed averaging around each video frame timestamp. See
window_average()
for details on the averaging process.Parameters:#
- recNeonRecording
Recording object containing gaze and video data.
- window_sizeint, optional
The size of the time window (in nanoseconds) over which to compute the average around each new timestamp. If
None
(default), the window size is set to the median interval between the new timestamps, i.e.,np.median(np.diff(new_ts))
. The window size must be larger than the median interval between the original data timestamps, i.e.,window_size > np.median(np.diff(data.index))
.
Returns:#
- pd.DataFrame
DataFrame containing gaze data mapped to video timestamps.