Capsules

A capsule is a single file with a .cap file extension. It contains the code, metadata, model files, and any other files the capsule needs to operate. See the Introduction to Capsules section in the User Manual for more information.

API Methods

BrainFrameAPI.get_plugin(name, timeout=30)brainframe.api.bf_codecs.plugin_codecs.Plugin
Parameters
  • name – The name of the plugin to get

  • timeout – The timeout to use for this request

Returns

Plugin with the given name

BrainFrameAPI.get_plugins(timeout=30) → List[brainframe.api.bf_codecs.plugin_codecs.Plugin]
Parameters

timeout – The timeout to use for this request

Returns

All available plugins

BrainFrameAPI.get_plugin_option_vals(plugin_name, stream_id=None, timeout=30) → Dict[str, object]

Gets the current values for every plugin option. See the documentation for the PluginOption codec for more info about global and stream level options and how they interact.

Parameters
  • plugin_name – The plugin to find options for

  • stream_id – The ID of the stream. If this value is None, then the global options are returned for that plugin

  • timeout – The timeout to use for this request

Returns

A dict where the key is the option name and the value is the option’s current value

BrainFrameAPI.set_plugin_option_vals(*, plugin_name, stream_id=None, option_vals: Dict[str, object], timeout=30)

Sets option values for a plugin.

Parameters
  • plugin_name – The name of the plugin whose options to set

  • stream_id – The ID of the stream, if these are stream-level options. If this value is None, then the global options are set

  • option_vals – A dict where the key is the name of the option to set, and the value is the value to set that option to

  • timeout – The timeout to use for this request

BrainFrameAPI.patch_plugin_option_vals(*, plugin_name, stream_id=None, option_vals: Dict[str, object], timeout=30)

Patches option values for a plugin. Only the provided options are changed. To unset an option, provide that option with a value of None.

Parameters
  • plugin_name – The name of the plugin whose options to set

  • stream_id – The ID of the stream, if these are stream-level options. If this value is None, then the global options are set

  • option_vals – A dict where the key is the name of the option to set, and the value is the value to set that option to

  • timeout – The timeout to use for this request

BrainFrameAPI.is_plugin_active(plugin_name, stream_id=None, timeout=30) → bool

Returns True if the plugin is active. If a plugin is not marked as active, it will not run. Like plugin options, this can be configured globally and on a per-stream level.

Parameters
  • plugin_name – The name of the plugin to get activity for

  • stream_id – The ID of the stream, if you want the per-stream active setting

  • timeout – The timeout to use for this request

Returns

True if the plugin is active

BrainFrameAPI.set_plugin_active(*, plugin_name, stream_id=None, active: Optional[bool], timeout=30)

Sets whether or not the plugin is active. If a plugin is active, it will be run on frames.

Parameters
  • plugin_name – The name of the plugin to set activity for

  • stream_id – The ID of the stream, if you want to set the per-stream active setting

  • active – True if the plugin should be set to active

  • timeout – The timeout to use for this request

Data Structures

class NodeDescription(*, size: brainframe.api.bf_codecs.plugin_codecs.SizeType, detections: List[str], attributes: Dict[str, List[str]], encoded: bool, tracked: bool, extra_data: List[str])

A description of a DetectionNode, used by plugins to define what kinds of inputs and outputs a plugin uses.

attributes: Dict[str, List[str]]

Key-value pairs whose key is the classification type and whose value is a list of possible attributes. A DetectionNode that meets this description must have a classification for each classification type listed here.

detections: List[str]

A list of detection class names, like “person” or “vehicle”. A DetectionNode that meets this description must have a class name that is present in this list.

encoded: bool

If True, the DetectionNode must be encoded to meet this description

extra_data: List[str]

A list of keys in a NodeDescription’s extra_data. A DetectionNode that meets this description must have extra data for each name listed here.

size: SizeType

Describes the amount of DetectionNodes the node either takes in as input or provides as output

tracked: bool

If True, the DetectionNode must be tracked to meet this description

class OptionType(value)

The data type of a plugin option

class Plugin(*, name: str, version: int, description: str, input_type: brainframe.api.bf_codecs.plugin_codecs.NodeDescription, output_type: brainframe.api.bf_codecs.plugin_codecs.NodeDescription, capability: brainframe.api.bf_codecs.plugin_codecs.NodeDescription, options: Dict[str, brainframe.api.bf_codecs.plugin_codecs.PluginOption])

Metadata on a loaded plugin.

capability: NodeDescription

A NodeDescription which describes what this plugin does to its input. It is the difference between the input and output NodeDescriptions. This field is useful for inspecting a plugin to find what it can do.

description: str

A human-readable description of what the plugin does

input_type: NodeDescription

Describes the type of inference data that this plugin takes as input

name: str

The name of the plugin

options: Dict[str, PluginOption]

A dict describing the configurable options of this plugin

output_type: NodeDescription

Describes the type of inference data that this plugin produces

version: int

The plugin’s version

class PluginOption(*, type_: brainframe.api.bf_codecs.plugin_codecs.OptionType, default: Any, constraints: dict, description: str)

A single configuration option for a plugin. Defines what type of option it is and its potential values.

There are two kinds of plugin options. Stream plugin options apply only to the stream they are attached to. Global plugin options apply to all streams, but are overridden by stream plugin options.

constraints: dict

Describes the range of valid values for this option. The content of this dict depends on the type field.

OptionType.FLOAT:

max_val: The maximum valid float value

min_val: The minimum valid float value

OptionType.INT:

max_val: The maximum valid int value

min_val: The minimum valid int value

OptionType.ENUM:

choices: A list of strings. The option’s value must be one of these strings.

OptionType.BOOL:

This object has no constraints.

default: Any

The default value for this option

description: str

A human-readable description of the plugin’s capabilities

type: OptionType

The data type of this option’s value

class SizeType(value)

Describes the amount of DetectionNodes a plugin takes as input or provides as output.

ALL = 'all'

Input: The plugin takes all instances of a class as input, like for a tracker.

Output: The plugin provides all instances of a class as output, like for a detector.

NONE = 'none'

Input: The plugin takes nothing as input, like for an object detector.

Output: Plugins cannot have a NONE output.

SINGLE = 'single'

Input: The plugin takes a single DetectionNode as input, like for a classifier.

Output: The plugin provides a single modified DetectionNode as output, like for a classifier.