mp.CalculatorGraph

The primary API for the MediaPipe Framework.

MediaPipe processing takes place inside a graph, which defines packet flow paths between nodes. A graph can have any number of inputs and outputs, and data flow can branch and merge. Generally data flows forward, but backward loops are possible.

binary_config

graph_input_stream_add_mode

max_queue_size

text_config

Methods

add_packet_to_input_stream

add_packet_to_input_stream(self: mediapipe.python._framework_bindings.calculator_graph.CalculatorGraph, stream: str, packet: mediapipe.python._framework_bindings.packet.Packet, timestamp: mediapipe.python._framework_bindings.timestamp.Timestamp = ) -> None

Add a packet to a graph input stream.

If the graph input stream add mode is ADD_IF_NOT_FULL, the packet will not be added if any queue exceeds the max queue size specified by the graph config and will raise a Python runtime error. The WAIT_TILL_NOT_FULL mode (default) will block until the queues fall below the max queue size before adding the packet. If the mode is max queue size is -1, then the packet is added regardless of the sizes of the queues in the graph. The input stream must have been specified in the configuration as a graph level input stream. On error, nothing is added.

Args: stream: The name of the graph input stream. packet: The packet to be added into the input stream. timestamp: The timestamp of the packet. If set, the original packet timestamp will be overwritten.

Raises: RuntimeError: If the stream is not a graph input stream or the packet can't be added into the input stream due to the limited queue size or the wrong packet type. ValueError: If the timestamp of the Packet is invalid to be the timestamp of a Packet in a stream.

Examples: graph.add_packet_to_input_stream( stream='in', packet=packet_creator.create_string('hello world').at(0))

graph.add_packet_to_input_stream(
    stream='in',
    packet=packet_creator.create_string('hello world'),
    timstamp=1)

close

close(self: mediapipe.python._framework_bindings.calculator_graph.CalculatorGraph) -> None

Close all the input sources and shutdown the graph.

close_all_packet_sources

close_all_packet_sources(self: mediapipe.python._framework_bindings.calculator_graph.CalculatorGraph) -> None

Closes all the graph input streams and source calculator nodes.

close_input_stream

close_input_stream(self: mediapipe.python._framework_bindings.calculator_graph.CalculatorGraph, arg0: str) -> None

Close the named graph input stream.

Args: stream: The name of the stream to be closed.

Raises: RuntimeError: If the stream is not a graph input stream.

get_combined_error_message

get_combined_error_message(self: mediapipe.python._framework_bindings.calculator_graph.CalculatorGraph) -> str

Combines error messages as a single string.

Examples: if graph.has_error(): print(graph.get_comb