Timeline
Introduction
Timeline widget is used to display video timeline. It can be used to get current frame and display information about the frame or it's annotation.
Function signature
timeline = Timeline(
frames_count=31,
intervals=[[0, 6], [6, 11], [12, 15], [16, 17], [18, 19], [20, 31]],
colors=["#DB7093", "#93db70", "#7093db", "#70dbb8", "#db8370", "#db70c9"],
height="30px",
)Parameters
frames_count
int
Timeline frames count
intervals
List[List[int]]
Frame intervals
colors
List[str]
Intervals colors in hex color codes
height
str
Timeline height in px
pointer_color
str
Color of the pointer
tooltip_content
Widget
Content of the tooltip
widget_id
str
ID of the widget
frames_count
Timeline (video) frames count.
type: int
intervals
Set frame intervals. Each interval is a list of two integers: [start_frame, end_frame]. Intervals and color lists must be the same length.
type: List[List[int]]
colors
Set interval colors in hex color codes. Intervals and color lists must be the same length.
type: List[str]
height
Set widget height in px.
type: str
default value: 30px
pointer_color
Color of the pointer. Set hex color code or None to use the default color.
type: str
default value: None
tooltip_content
Content of Tooltip.
type: Widget
default value: None
widget_id
ID of the widget.
type: str
default value: None
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/controls/008_timeline/src/main.py
Import libraries
Write a function for dividing the total number of frames by ranges
Write function generating random hex colors for each range
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Initialize Video ID we will use
Video ID we will useGet video info from server and prepare VideoThumbnail widget
Get video intervals and colors from video frame count
Initialize Timeline widget
Create InputNumber widget for setting current frame
Create Timeline container
Create app layout
Create app using layout
Create an app object with layout parameter.
Add callbacks for changing the current frame
Last updated
Was this helpful?