visiannot.visiannot.ViSiAnnoT

Summary

Module defining ViSiAnnoT

Classes

visiannot.visiannot.ViSiAnnoT.ViSiAnnoT(…)

Class defining the visualization and annotation GUI for a set of synchronized video(s) and signal(s).

API

Class ViSiAnnoT

class visiannot.visiannot.ViSiAnnoT.ViSiAnnoT(video_dict, signal_dict, annotevent_dict={}, annotimage_list=[], threshold_dict={}, interval_dict={}, y_range_dict={}, poswid_dict={}, layout_mode=1, flag_long_rec=False, from_cursor_list=[], zoom_factor=2, nb_ticks=10, flag_annot_overlap=False, annot_dir='Annotations', flag_pause_status=False, max_points=5000, time_zone='Europe/Paris', flag_infinite_loop=True, bg_color=(244, 244, 244), bg_color_plot=(255, 255, 255), font_name='Times', font_size=12, font_size_title=16, font_color=(0, 0, 0), current_fmt='%Y-%m-%dT%H:%M:%S.%s', range_fmt='%H:%M:%S.%s', ticks_fmt='%H:%M:%S.%s', ticks_color=(93, 91, 89), ticks_size=12, ticks_offset=5, y_ticks_width=30, nb_table_annot=5, height_widget_signal=150)[source]

Bases: object

Class defining the visualization and annotation GUI for a set of synchronized video(s) and signal(s).

The constructor takes as arguments dictionaries with the path to the video files and signal files. It calls the method set_all_data() in order to load data and store them in attributes.

For a given video file, data are loaded in an instance of cv2.VideoCapture. The set of video data is stored in video_data_dict. The widgets for plotting video are stored in wid_vid_dict.

For a given signal file, data are loaded in an instance of Signal. The supported formats are txt, mat, h5 and wav. The set of Signal instances is stored in sig_dict. The widgets for plotting signals are stored in wid_sig_list.

The reference frequency ViSiAnnoT.fps is defined as the video frequency. If there is no video to display, ViSiAnnoT.fps is defined as the frequency of the first signal to plot. The playback speed (both video and signal temporal cursor) is at the reference frequency.

The temporal range is defined by first_frame and last_frame (sampled at ViSiAnnoT.fps). The signal widgets display the signal between those bounds. So when zooming in/out, the temporal range is modified and then the display is updated with the method update_signal_plot().

The playback is managed with two separate threads:

  • Reading next video frame - an instance of threading.Thread with the method update_video_frame() as target,

  • Updating plot - an instance of QtCore.QTimer connected to the method update_plot().

The current position in the video file (i.e. the current position of the temporal cursor) is frame_id (sampled at ViSiAnnoT.fps).

Parameters
  • video_dict (dict) –

    video configuration, each item corresponds to one camera. Key is the camera ID (string). Value is a configuration list with 4 elements:

    • (str) Path to the video file,

    • (str) Delimiter to get beginning datetime in the video file name,

    • (int) Position of the beginning datetime in the video file name, according to the delimiter,

    • (str) Format of the beginning datetime in the video file name (either "posix" or a format compliant with datetime.strptime()).

  • signal_dict (dict) –

    signal configuration, each item corresponds to one signal widget. Key is the widget ID (Y axis label, string). Value is a nested list of signal configurations. Each element of the nested list corresponds to one signal plot and is a configuration list of 7 elements:

    • (str) Path to the signal file, data must be stored in a 1D array if regularly sampled, otherwise in a 2D array (where first column is the timestamp in milliseconds and the second column the signal value)

    • (str) Delimiter to get beginning datetime in the signal file name,

    • (int) Position of the beginning datetime in the signal file name, according to the delimiter,

    • (str) Format of the beginning datetime in the signal file name (either "posix" or a format compliant with datetime.strptime()),

    • (str) Key to access the data (in case of .mat or .h5 file),

    • (int or float or str) Signal frequency, set it to 0 if signal non regularly sampled, set it to -1 if same frequency as ViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file - in case of 2D data with several value columns, then the column index must be specified, e.g. "key - 1" or "key - colName" if there is an attribute at key named columns with columns name being comma-separated (first column is always the timestamps),

    • (dict) Plot style, see https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html for details, set it to None for default.

    See Signal visualization for details and examples.

  • annotevent_dict (dict) – events annotation configuration, key is the label (string), value is the associated color (RGBA)

  • annotimage_list (list) – labels for image extraction

  • threshold_dict (dict) –

    threshold configuration. Each item corresponds to a signal widget on which to plot threshold(s). The key must be the same as in signal_dict. Value is a list of configuration lists. This is a nested list because there can be several thresholds plotted in the same widget. A configuration list has 2 elements:

    • (int or float) Threshold value on Y axis,

    • (tuple or list) Plot color (RGB).

  • interval_dict (dict) –

    interval configuration. Each item corresponds to a signal widget on which to plot intervals. The key must be the same as in signal_dict. Value is a nested list of interval configurations. Each element of the nested list corresponds to one type of interval to be plotted on the same signal widget and is a configuration list of 7 elements:

    • (str) Path to the interval file, data can be stored as a 2D array (where each line has 2 elements: start and stop frames) or a 1D array (time series of 0 and 1),

    • (str) Delimiter to get beginning datetime in the interval file name,

    • (int) Position of the beginning datetime in the interval file name, according to the delimiter,

    • (str) Format of the beginning datetime in the interval file name (either "posix" or a format compliant with datetime.strptime()),

    • (str) Key to access the data (in case of .mat or .h5 file),

    • (int) Signal frequency, set it to -1 if same frequency as ViSiAnnoT.fps, it may be a string with the path to the frequency attribute in a .h5 file,

    • (tuple or list) Plot color (RGBA).

  • y_range_dict (dict) – visible Y range for signal widgets, each item corresponds to a signal widget. The key must be the same as in signal_dict. Value is a list/tuple of length 2 with the min and max values to display on the Y axis. The signal widgets that are not specified in this dictionary have auto-range enabled for Y axis.

  • poswid_dict (dict) –

    custom organization of widgets positioning in the window layout. Value is a tuple of length 2 (row, col) or 4 (row, col, rowspan, colspan). Key identifies the widget:

    • "video"

    • "select_manual"

    • "select_from_cursor"

    • "annot_event"

    • "annot_image"

    • "visi"

    • "zoomin"

    • "zoomout"

    • "progress"

    The signal widgets are automatically positioned below the progress bar.

  • layout_mode (int) –

    organization of widgets positioning in the window layout (ignored if custom layout organization provided with keyword argument poswid_dict), one of the following:

    • 1 (focus on video, works better with a big screen),

    • 2 (focus on signal, suitable for a laptop screen),

    • 3 (compact display with some features disabled),

    • 4 (adapted to portrait screen orientation).

  • flag_long_rec (bool) – specify if ViSiAnnoT is launched in the context of ViSiAnnoTLongRec (long recording)

  • from_cursor_list (list) – (tool for fast navigation) list of durations that are available in the combo box to select a temporal range duration in order to display a new temporal range that will begin at the current position of the temporal cursor. Each element is a tuple of length 2 (min, sec). An example: [[0,30],[1,0],[2,0],[3,0],[4,0],[5,0]].

  • zoom_factor (int) – zoom factor

  • nb_ticks (int) – number of temporal ticks on the X axis of the signals widgets

  • flag_annot_overlap (bool) – specify if overlap of events annotations is enabled

  • annot_dir (str) – directory where to save annotations, automatically created if it does not exist

  • flag_pause_status (bool) – specify if the video is paused when launching ViSiAnnoT

  • max_points (int) – maximum number of points to plot for the signals

  • time_zone (str) – time zone (compliant package pytz)

  • flag_infinite_loop (bool) – specify if an infinite loop is set after creating the window. Set it to False if several ViSiAnnoT windows must be displayed simultaneousely, do not forget to store each instance of ViSiAnnoT in a variable and to set manually the infinite loop with infinite_loop_gui()

  • bg_color (tuple or str) – backgroud color of the GUI, RGB or HEX string

  • bg_color_plot (tuple or str) – background color of the signal plots, RGB or HEX string

  • font_name (str) – font used for the text in the GUI (must be available in PyQt5)

  • font_size (int) – font size of the text in the GUI

  • font_size_title (int) – font size of the titles in the GUI (progress bar and video widgets)

  • font_color (tuple) – font color of the text in the GUI, RGB

  • current_fmt (str) – datetime string format of the current temporal position in progress bar, see keyword argument fmt of convert_datetime_to_string()

  • range_fmt (str) – datetime string format of the temporal range duration in progress bar, see keyword argument fmt of convert_datetime_to_string()

  • ticks_fmt (str) – datetime string format of X axis ticks text, see keyword argument fmt of convert_datetime_to_string()

  • ticks_color (tuple or str) – color of the ticks in the signal plots, RGB or HEX string

  • ticks_size (int) – size of the ticks values in the signal plots

  • ticks_offset (int) – offset between the ticks and associated values in the signal plots

  • y_ticks_width (int) – horizontal space in pixels for the text of Y axis ticks in signal widgets

  • nb_table_annot (int) – maximum number of labels in a row in the widgets for events annotation and image annotation

  • height_widget_signal (int) – minimum height in pixel of the signal widgets

Methods for plotting region items (pyqtgraph.LinearRegionItem):

add_item_to_signals(item_list)

Displays items in the signal widgets

add_region_to_widgets(bound_1, bound_2[, color])

Creates and displays a region item (pyqtgraph.LinearRegionItem) for the progress bar (wid_progress) and the signal widgets (wid_sig_list)

create_text_item(text, pos_ms, pos_y_list[, …])

Adds a text item to the signal widgets (wid_sig_list)

remove_region_in_widgets(region_list)

Removes a region item from the progress bar widget and the signal widgets

Methods for conversion between milliseconds and frame number:

convert_ms_to_frame_ref(frame_ms)

Converts milliseconds to frame number sampled at the reference frequency ViSiAnnoT.fps

get_current_range_in_ms()

Converts the current temporal range defined by ViSiAnnoT.first_frame and ViSiAnnoT.last_frame to milliseconds

get_frame_id_in_ms(frame_id)

Converts a frame number to milliseconds

Methods for setting video and signal data:

get_data_frequency(path, freq)

Gets the frequency of data in a file

get_synchro_info_signal(line)

In case of long recording, gets the path to data file and the start second of a line of a temporary signal synchronization file

get_synchro_info_video(line)

In case of long recording, gets the path to video file, the start second and end second of a line of a temporary signal synchronization file

get_synchro_signal(path, delimiter, pos, …)

Gets synchronized signal data for current file in the long recording

get_synchro_video(path)

Gets info for video synchronization for the current file in the long recording

set_all_data(video_dict, signal_dict, …)

Sets video and signal data (to be called before plotting)

Methods for mouse interaction with plots:

get_mouse_y_position(ev)

Gets position of the mouse on the Y axis of all the signal widgets

zoom_or_annot_clicked(ev, pos_frame, pos_ms)

Manages mouse click for zoom or annotation

Methods for displaying video, signals and progress bar:

init_signal_plot(progbar_wid_pos[, y_range_dict])

Creates the signal widgets and initializes the signal plots

plot_frame_id_position()

Updates the displayed video frame and the plots of the temporal cursor at the current frame position frame_id

stop_processing()

Closes streams (elements of video_data_dict) and deletes temporary signal folder

update_frame_id(frame_id)

Sets the value of current frame frame_id and updates the displayed video frame and the plots of the temporal cursor at new current frame

update_plot()

Updates (during playback) the displayed video frame and the plots of the temporal cursor at the current frame frame_id

update_plot_new_frame(new_frame_id[, …])

Updates plots after having set the current frame to display by changing file in long recording or defining a custom temporal range

update_signal_plot([…])

Updates the signal plots and the progress bar so that they span the current temporal range defined by first_frame and last_frame

update_video_frame()

Reads the video stream (launched in a thread)

Callback method for key press interaction:

key_press(ev)

Callback method for key press interaction, see Keyboard

key_release(ev)

Callback method for key release interaction, see Keyboard

Attributes:

ticks_fmt

(str) Datetime string format of the text of X axis ticks

nb_ticks

(int) Number of temporal ticks on the X axis of the signals plots

time_zone

(str) Time zone (as in package pytz)

max_points

(int) Maximum number of points to plot for the signals

plot_style_list

(list) Default plot styles for signals on a single widget (length 10)

annot_dir

(str) Directory where the events annotations and extracted images are saved

flag_long_rec

(bool) Specify if ViSiAnnoT is launched in the context of ViSiAnnoTLongRec

video_data_dict

(dict) Video data, each item corresponds to one camera

sig_dict

(dict) Signal data, each item corresponds to a signal widget

interval_dict

(dict) Intervals to plot on signals, each item corresponds to one signal widget

fps

(int) Reference frequency

nframes

(int) Number of frames in the video (or the first signal if there is no video)

beginning_datetime

(datetime.datetime) Beginning datetime of the data (current file in case of long recording)

threshold_dict

(dict) Thresholds to plot on signals widgets, each item corresponds to one signal widget

zoom_pos_1

(int) Start position (frame number) for custom manual zoom (set to -1 if not defined)

zoom_pos_2

(int) End position (frame number) for custom manual zoom (set to -1 if not defined)

region_zoom_list

(list) Instances of pyqtgraph.LinearRegionItem with all the grey regions for custom manual zoom

region_zoom_text_item_list

(list) Instances of pyqtgraph.TextItem with the duration of the custom manual zoom

flag_pause_status

(bool) Specify if the video is paused

frame_id

(int) Index of the current frame

first_frame

(int) First frame that is displayed in the signal plots

last_frame

(int) Last frame that is displayed in the signal plots

flag_processing

(bool) Specify if the window is running

app

(QtWidgets.QApplication) GUI initializer

win

(QtWidgets.QWidget) Window container

lay

(QtWidgets.QGridLayout) layout filling the window

menu_bar

(MenuBar) Menu bar item, instance of a sub-class of QtWidgets.QMenuBar, by default it is hidden, see key_release() for the keyword shortcut for displaying it

wid_time_edit

(CustomTemporalRangeWidget) Widget for defining a custom temporal range

wid_from_cursor

(FromCursorTemporalRangeWidget) Widget for selecting a duration of temporal range to be started at the current frame

wid_progress

(ProgressWidget) Widget containing the progress bar

wid_vid_dict

(dict) Video widgets, each item corresponds to one camera

wid_sig_list

(list) Signal widgets, each element is an instance of SignalWidget (same order as sig_dict)

wid_visi

(FullVisiWidget) Widget for zooming out to the full temporal range

wid_zoomin

(ZoomInWidget) Widget for zooming in

wid_zoomout

(ZoomOutWidget) Widget for zooming out

wid_annotevent

(AnnotEventWidget) Widget for events annotation

wid_annotimage

(AnnotImageWidget) Widget for image extraction

update_frame_thread

(threading.Thread) Thread for getting video frames, connected to the method ViSiAnnoT.update_video_frame()

timer

(QtCore.QTimer) Thread for updating the current frame position, connected to the method ViSiAnnoT.update_plot()

add_item_to_signals(item_list)[source]

Displays items in the signal widgets

Parameters

item_list (list) – items to display in the signal widgets, same length as wid_sig_list, each element corresponds to one signal widget

add_region_to_widgets(bound_1, bound_2, color=(150, 150, 150, 50))[source]

Creates and displays a region item (pyqtgraph.LinearRegionItem) for the progress bar (wid_progress) and the signal widgets (wid_sig_list)

Parameters
  • bound_1 (int) – start frame of the region item (sampled at the reference frequency ViSiAnnoT.fps)

  • bound_2 (int) – end frame of the region item (sampled at the reference frequency ViSiAnnoT.fps)

  • color (tuple or list) – plot color (RGBA)

Returns

instances of pyqtgraph.LinearRegionItem (corresponding to the same region), first element displayed in the progress bar widget, remaining elements displayed in the widget signals

Return type

list

convert_ms_to_frame_ref(frame_ms)[source]

Converts milliseconds to frame number sampled at the reference frequency ViSiAnnoT.fps

Parameters

frame_ms (float) – frame number in milliseconds

Returns

frame number sampled at the reference frequency ViSiAnnoT.fps

Return type

int

create_text_item(text, pos_ms, pos_y_list, text_color=(0, 0, 0), border_color=(255, 255, 255), border_width=3)[source]

Adds a text item to the signal widgets (wid_sig_list)

See https://pyqtgraph.readthedocs.io/en/latest/functions.html#pyqtgraph.mkColor for supported color formats.

Parameters
  • text (str) – text to display in the signal widgets (it is the same in each widget)

  • pos_ms (float) – temporal position (X axis) of the text item in milliseconds

  • pos_y_list (float) – position on the Y axis of the text item in each signal widget, same length as wid_sig_list

  • text_color (tuple or list or str) – color of the text

  • border_color (tuple or list or str) – color of the text item border

  • border_width (int) – width of the text item border in pixels

Returns

instances of pyqtgraph.TextItem, each element corresponds to a signal widget, same length and order as wid_sig_list

Return type

list

get_current_range_in_ms()[source]

Converts the current temporal range defined by ViSiAnnoT.first_frame and ViSiAnnoT.last_frame to milliseconds

Returns

  • first_frame_ms (int) – first frame of the current temporal range in milliseconds

  • last_frame_ms (int) – last frame of the current temporal range in milliseconds

get_data_frequency(path, freq)[source]

Gets the frequency of data in a file

Parameters
  • path (str) – path to the data file

  • freq (str or float) – data frequency as retrieved from input configuration dictionary (it may be directly the frequency, or the key to get frequency in a H5 file)

Returns

data frequency

Return type

float

get_frame_id_in_ms(frame_id)[source]

Converts a frame number to milliseconds

Parameters

frame_id (int) – frame number sampled at the reference frequency ViSiAnnoT.fps

Returns

frame number in milliseconds

Return type

float

get_mouse_y_position(ev)[source]

Gets position of the mouse on the Y axis of all the signal widgets

Parameters

ev (QtGui.QMouseEvent) – emitted when the mouse is clicked/moved

Returns

same length as wid_sig_list, each element is the position of the mouse on the Y axis in the corresponding signal widget, it returns [] if the mouse clicked on a label item (most likely the widget title)

Return type

list

get_synchro_info_signal(line)[source]

In case of long recording, gets the path to data file and the start second of a line of a temporary signal synchronization file

Parameters
  • line (str) – line of a temporary signal synchronization file

  • delimiter (str) – delimiter used to split the line

Returns

  • path (str) – path to the signal file

  • start_sec (float) – start second

get_synchro_info_video(line)[source]

In case of long recording, gets the path to video file, the start second and end second of a line of a temporary signal synchronization file

Parameters
  • line (str) – line of a temporary signal synchronization file

  • delimiter (str) – delimiter used to split the line

Returns

  • path (str) – path to the signal file

  • start_sec (float) – start second

  • end_sec (float) – end second

get_synchro_signal(path, delimiter, pos, fmt, key_data, freq_data, signal_id, flag_interval=False)[source]

Gets synchronized signal data for current file in the long recording

Parameters
  • path (str) – path to the temporary synchronization file

  • delimiter (str) – delimiter to get the signal file timestamp in the file name

  • pos (int) – position of the signal file timestamp in the file name

  • fmt (str) – format of signal file timestamp found in the file name

  • key_data (str) – key to access the data (in case of .h5 or .mat file)

  • freq_data (float or str) – signal frequency as found in the configuration file, in case this is a string, then the frequency is retrieved in the data file

  • signal_id (str) – signal type (key in the dictionary signal_dict, second positional argument of ViSiAnnoT constructor)

  • tmp_delimiter (str) – delimiter used to split the lines of the temporary signal files

  • flag_interval (bool) – specify if data to load is intervals

Returns

  • data (numpy array) – synchronized signal data

  • freq_data (float) – signal frequency

get_synchro_video(path)[source]

Gets info for video synchronization for the current file in the long recording

It is assumed that all videos have the same frequency, stored as reference frequency in attribute fps.

Parameters

path (str) – path to the current temporary synchronization file

Returns

  • video_data_list (list) – instances of cv2.VideoCapture with video data spanning the current file in the long recording

  • path_list (list) – names of the video files corresponding to the elements of video_data_list

  • frame_array (numpy array) – shape (n, 2), where n is equal to the length of video_data_list, each row corresponds to an element of video_data_list (same ordering) and gives the starting frame and ending frame (sampled at video FPS) that the video spans in the current file of the long recording

init_signal_plot(progbar_wid_pos, y_range_dict={}, **kwargs)[source]

Creates the signal widgets and initializes the signal plots

The widgets are automatically positioned below the progress bar.

It sets the attribute ViSiAnnoT.wid_sig_list.

Make sure the attributes ViSiAnnoT.lay, ViSiAnnoT.sig_dict, ViSiAnnoT.threshold_dict and ViSiAnnoT.interval_dict are defined before calling this method.

Parameters
  • progbar_wid_pos (tuple of list) – position of the progress bar widget, length 2 (row, col) or 4 (row, col, rowspan, colspan)

  • y_range_dict (dict) – visible Y range for signal widgets, see positional argument y_range_dict of ViSiAnnoT constructor

  • kwargs – keyword arguments of the constructor of SignalWidget, except y_range and left_label

key_press(ev)[source]

Callback method for key press interaction, see Keyboard

Parameters

ev (QtGui.QKeyEvent) – emmited when a key is pressed

key_release(ev)[source]

Callback method for key release interaction, see Keyboard

Parameters

ev (QtGui.QKeyEvent) – emmited when a key is released

plot_frame_id_position()[source]

Updates the displayed video frame and the plots of the temporal cursor at the current frame position frame_id

If frame_id is out of the temporal range (defined by first_frame and last_frame), then the temporal range is updated. For example, in the context of long recording, this might happen when navigating from one file to another. If the temporal range is updated, then the method update_signal_plot() is called in order to update the signal plots with the new temporal range.

The attribute img_vid_dict is set with the values in im_dict in order to update the displayed video frame.

If the navigation point of the progress bar is not dragged, then the attribute wid_progress is modified in order to update the position of the navigation point.

The attribute current_cursor_list is set in order to update the position of the temporal cursor in the signal widgets.

remove_region_in_widgets(region_list)[source]

Removes a region item from the progress bar widget and the signal widgets

Parameters

region_list (list) – instances of pyqtgraph.LinearRegionItem, all elements correspond to the same region displayed in the different widgets, first element is the region item displayed in the progress bar widget (wid_progress) and the remaining elements are the region items displayed in the signal widgets (same order as wid_sig_list)

set_all_data(video_dict, signal_dict, interval_dict)[source]

Sets video and signal data (to be called before plotting)

Make sure the following attributes are defined before calling this method:

Make sure the follwing attributes are initialized before calling this method (it can be empty):

Otherwise the video thread throws a RunTime error. These attributes are then set thanks to the positional arguments video_dict, signal_dict and interval_dict.

This method sets the following attributes:

If there is no video, the attributes nframes, ViSiAnnoT.fps and beginning_datetime are set with the first signal in signal_dict.

Parameters
  • video_dict (dict) – same as first positional argument of ViSiAnnoT constructor

  • signal_dict (dict) – same as second positional argument of ViSiAnnoT constructor

  • interval_dict (dict) – same as keyword argument of ViSiAnnoT constructor

stop_processing()[source]

Closes streams (elements of video_data_dict) and deletes temporary signal folder

It sets the value of flag_processing to False so that the thread update_frame_thread is stopped.

update_frame_id(frame_id)[source]

Sets the value of current frame frame_id and updates the displayed video frame and the plots of the temporal cursor at new current frame

The displayed video frame and the plots are updated by calling the method plot_frame_id_position().

Parameters

frame_id (int) – new current frame index

update_plot()[source]

Updates (during playback) the displayed video frame and the plots of the temporal cursor at the current frame frame_id

It is called by the thread timer.

The displayed video frame and the plots are updated by calling the method plot_frame_id_position().

It is only effective if flag_pause_status is False.

It increments the value of frame_id.

update_plot_new_frame(new_frame_id, new_temporal_range=None, flag_previous_scroll=False)[source]

Updates plots after having set the current frame to display by changing file in long recording or defining a custom temporal range

Parameters
  • new_frame_id (int) – new current frame number (sampled at the reference frequency ViSiAnnoT.fps)

  • new_temporal_range (tuple) – new temporal range (first frame, last frame), if last frame is above ViSiAnnoT.nframes, then it is truncated - by default it starts at 0 (or at the end of the file in case of backward scrolling) and keeps the same current temporal range duration

  • flag_previous_scroll (bool) – specify if the new file is reach backward by scrolling

update_signal_plot(flag_reset_combo_from_cursor=True)[source]

Updates the signal plots and the progress bar so that they span the current temporal range defined by first_frame and last_frame

Parameters

flag_reset_combo_from_cursor (bool) – specify if the combo box of wid_from_cursor must be reset

update_video_frame()[source]

Reads the video stream (launched in a thread)

Called by the thread update_frame_thread.

It updates the attribute wid_vid_dict with the image at the current frame for each camera.

zoom_or_annot_clicked(ev, pos_frame, pos_ms)[source]

Manages mouse click for zoom or annotation

Parameters
  • ev (QtGui.QMouseEvent) – emitted when the mouse is clicked/moved

  • pos_frame (int) – mouse position on the X axis in frame number (sampled at the reference frequency ViSiAnnoT.fps)

  • pos_ms (int) – mouse position on the X axis in milliseconds

annot_dir

(str) Directory where the events annotations and extracted images are saved

app

(QtWidgets.QApplication) GUI initializer

beginning_datetime

(datetime.datetime) Beginning datetime of the data (current file in case of long recording)

first_frame

(int) First frame that is displayed in the signal plots

flag_long_rec

(bool) Specify if ViSiAnnoT is launched in the context of ViSiAnnoTLongRec

flag_pause_status

(bool) Specify if the video is paused

flag_processing

(bool) Specify if the window is running

fps

(int) Reference frequency

frame_id

(int) Index of the current frame

interval_dict

(dict) Intervals to plot on signals, each item corresponds to one signal widget

Key is the data type of the signal widget on which to plot (same as in positional argument signal_dict of the constructor of ViSiAnnoT)

Value is a list of lists, so that several intervals files can be plotted on the same signal widget. Each sub-list has 3 elements:

  • (numpy array) Intervals data, shape (n_{intervals}, 2)

  • (float) Frequency (0 if timestamps, -1 if same as signal)

  • (tuple) Plot color (RGBA)

last_frame

(int) Last frame that is displayed in the signal plots

Actually, the last frame that is displayed is last_frame` - 1, because of zero-indexation.

lay

(QtWidgets.QGridLayout) layout filling the window

max_points

(int) Maximum number of points to plot for the signals

menu_bar

(MenuBar) Menu bar item, instance of a sub-class of QtWidgets.QMenuBar, by default it is hidden, see key_release() for the keyword shortcut for displaying it

nb_ticks

(int) Number of temporal ticks on the X axis of the signals plots

nframes

(int) Number of frames in the video (or the first signal if there is no video)

plot_style_list

(list) Default plot styles for signals on a single widget (length 10)

region_zoom_list

(list) Instances of pyqtgraph.LinearRegionItem with all the grey regions for custom manual zoom

region_zoom_text_item_list

(list) Instances of pyqtgraph.TextItem with the duration of the custom manual zoom

Same length and order as ViSiAnnoT.wid_sig_list, so that one element corresponds to one signal widget

sig_dict

(dict) Signal data, each item corresponds to a signal widget

Key is the data type (same keys as signal_dict, positional argument of the constructor), used as label of the Y axis of the corresponding widget.

Value is a list of instances of Signal to plot on the corresponding widget

threshold_dict

(dict) Thresholds to plot on signals widgets, each item corresponds to one signal widget

Key is the data type of the signal widget on which to plot (same as in positional argument signal_dict of the constructor of ViSiAnnoT)

Value is a list of length 2:

  • (float) Value of the threshold on Y axis

  • (tuple) Color to plot (RGB), it can also be a string with HEX color

ticks_fmt

(str) Datetime string format of the text of X axis ticks

time_zone

(str) Time zone (as in package pytz)

timer

(QtCore.QTimer) Thread for updating the current frame position, connected to the method ViSiAnnoT.update_plot()

update_frame_thread

(threading.Thread) Thread for getting video frames, connected to the method ViSiAnnoT.update_video_frame()

video_data_dict

(dict) Video data, each item corresponds to one camera

Key is the camera ID (same keys as video_dict, positional argument of the constructor of ViSiAnnoT).

If flag_long_rec is False, value is a tuple of 2 elements:

  • (cv2.VideoCapture) Video data

  • (str) Name of the video file

If flag_long_rec is True, value is a tuple of 3 elements:

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

  • (list) Names of the 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

wid_annotevent

(AnnotEventWidget) Widget for events annotation

wid_annotimage

(AnnotImageWidget) Widget for image extraction

wid_from_cursor

(FromCursorTemporalRangeWidget) Widget for selecting a duration of temporal range to be started at the current frame

wid_progress

(ProgressWidget) Widget containing the progress bar

wid_sig_list

(list) Signal widgets, each element is an instance of SignalWidget (same order as sig_dict)

wid_time_edit

(CustomTemporalRangeWidget) Widget for defining a custom temporal range

wid_vid_dict

(dict) Video widgets, each item corresponds to one camera

Key is the camera ID (same keys as the positional argument video_dict of the constructor of ViSiAnnoT).

Value is an instance of VideoWidget where the corresponding camera is displayed.

wid_visi

(FullVisiWidget) Widget for zooming out to the full temporal range

wid_zoomin

(ZoomInWidget) Widget for zooming in

wid_zoomout

(ZoomOutWidget) Widget for zooming out

win

(QtWidgets.QWidget) Window container

zoom_pos_1

(int) Start position (frame number) for custom manual zoom (set to -1 if not defined)

zoom_pos_2

(int) End position (frame number) for custom manual zoom (set to -1 if not defined)