Figment API
How to work with Figment.
Last updated
Was this helpful?
How to work with Figment.
Last updated
Was this helpful?
Activates Figment. If the set_render_video
option is enabled, the output is rendered to the #figment
<div>
.
To ensure that all parts of Figment are loaded before using the interface, .activate()
returns a Promise. The intended way to activate Figment is as follows:
returns: Promise
Deactivates Figment. All rendering and computations are stopped.
Figment also stops the input MediaStream when deactivated. So, before reactivating, a new input MediaStream must be set, otherwise a MediaStream with default parameters is read.
returns: Promise
Lets you set the that Figment uses as video input.
Usage:
Usage:
Usage:
returns: MediaStream
General function to change the internal state of Figment. This function may be executed before or while Figment is running.
option: Option to be set. Available options are: set_background_img | blur_background | set_render_video | activate_quality_mode | activate_performance_mode | show_hide_performance | set_mask_behavior
set_background_img
— sets the current background image. value: path_to_image
.
blur_background
— blurs the background. We offer three different blur strengths: weak, balanced and strong. value: weak | balanced | strong
set_render_video
— Option to control whether Figment should render its output into the #figment
<div>
. value: true (default) | false
activate_quality_mode (default)
— uses the model with emphasis on segmentation quality. Slight drop in FPS is expected. value: ''
activate_performance_mode
— uses the model with emphasis on performance. Slight decrease in segmentation quality expected. value: ''
show_hide_performance
— allows to show and hide a transparent performance bar showing frames per second (FPS) and inference times in milliseconds. value: show | hide
set_mask_behavior
— Allows switching between a tight or a slightly looser mask. Both masks aim to accurately segment the person. The loose mask shows small fractions of the background in order to preserve the whole person, while the tight mask aims to show as little background as possible with the possibility that the mask may cut into the person at times. value: tight (default) | loose
value: value specifying the set option.
Usage examples:
or
Allows to set the for the input video. In this case, the input video is read by Figment using:
Lets you receive Figment's output containing the final segmentation result. This function should only be executed after Figment fires its FigmentOutputUpdated
event.