visiannot.visiannot.components.VideoWidget

Summary

Module defining VideoWidget

Classes

visiannot.visiannot.components.VideoWidget.VideoWidget(…)

Subclass of pyqtgraph.PlotWidget for displaying a video

API

Class VideoWidget

class visiannot.visiannot.components.VideoWidget.VideoWidget(lay, widget_position, data_video)[source]

Bases: pyqtgraph.widgets.PlotWidget.PlotWidget

Subclass of pyqtgraph.PlotWidget for displaying a video

Parameters
  • lay (PyQt5.QtWidgets.QGridLayout) – layout where the video widget must be displayed

  • widget_position (tuple or list) – position of the widget in the layout

  • data_video (tuple) – see value of ViSiAnnoT.video_data_dict

Methods:

displayImage()

Displays the current frame stored in image

setAndDisplayImage(*args)

Reads video at the specified frame and displays image

setDataVideo(data_video)

Sets the attributes with video data

setImage(frame_id)

Reads video at the specified frame

setSynchro(frame_id)

Finds the video file to read and the temporal offset to apply when reading frames

Attributes:

data_video

(cv2.VideoCapture) Video data currently being played

name

(str) Basename of the video currently being played

data_video_synchro

(tuple) Information for video synchronization in case of long recording (ignored otherwise), 3 elements:

offset_synchro

(float) Temporal offset in frames number to apply to the current frame to read in case of long recording (ignored otherwise)

previous_frame_id

(int) Index of the previously read frame

image

(numpy array) Current frame image

img_item

(pyqtgraph.ImageItem) Displayed image item

displayImage()[source]

Displays the current frame stored in image

It sets the attribute img_item.

setAndDisplayImage(*args)[source]

Reads video at the specified frame and displays image

It calls the methods setImage() and displayImage().

Parameters

args – positional arguments of setImage()

setDataVideo(data_video)[source]

Sets the attributes with video data

In case of long recording, it sets the attributes data_video_synchro and resets the attributes data_video, offset_synchro and name to None. Otherwise, it only sets the attributes data_video and name.

Parameters

data_video (tuple) – see third positional argument of the constructor of VideoWidget

setImage(frame_id)[source]

Reads video at the specified frame

It sets the attributes previous_frame_id and image.

Parameters

frame_id (int) – frame to read

Returns

code (0 success, 1 pause, 2 error)

Return type

int

setSynchro(frame_id)[source]

Finds the video file to read and the temporal offset to apply when reading frames

It sets the attributes data_video, name and offset_synchro.

Parameters

frame_id (int) – next frame to read

data_video

(cv2.VideoCapture) Video data currently being played

data_video_synchro

(tuple) Information for video synchronization in case of long recording (ignored otherwise), 3 elements:

  • (list) Instances of cv2.VideoCapture containing the video data spanning the current file in the long recording

  • (list) Names of the video files spanning the current file in the long recording (same ordering than list of cv2.VideoCapture instances)

  • (numpy array) Array of shape (n, 2) (n is equal to the length of the list of video data), each row corresponds to an element of the list of cv2.VideoCapture instances (same ordering) and contains the bounding frames that the video spans in the current file in the long recording

image

(numpy array) Current frame image

img_item

(pyqtgraph.ImageItem) Displayed image item

name

(str) Basename of the video currently being played

offset_synchro

(float) Temporal offset in frames number to apply to the current frame to read in case of long recording (ignored otherwise)

previous_frame_id

(int) Index of the previously read frame