class_docstr: The common base class for the high-level MediaPipe Solution APIs.
  
  The SolutionBase class contains the shared logic among the high-level solution
  APIs including graph initialization, processing image/audio data, and graph
  shutdown.
  
  Example usage:
    with solution_base.SolutionBase(
        binary_graph_path='mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb',
        side_inputs={'num_hands': 2}) as hand_tracker:
      # Read an image and convert the BGR image to RGB.
      input_image = cv2.cvtColor(cv2.imread('/tmp/hand.png'), COLOR_BGR2RGB)
      results = hand_tracker.process(input_image)
      print(results.palm_detections)
      print(results.multi_hand_landmarks)
class_docstr_tok: ["The","common","base","class","for","the","high-level","MediaPipe","Solution","APIs",".","The","SolutionBase","class","contains","the","shared","logic","among","the","high-level","solution","APIs","including","graph","initialization",",","processing","image\/audio","data",",","and","graph","shutdown",".","Example","usage",":","with","solution_base.SolutionBase","(","binary_graph_path='mediapipe\/modules\/hand_landmark\/hand_landmark_tracking_cpu.binarypb","'",",","side_inputs=","{","'num_hands","'",":","2","}",")","as","hand_tracker",":","#","Read","an","image","and","convert","the","BGR","image","to","RGB",".","input_image","=","cv2.cvtColor","(","cv2.imread","(","'\/tmp\/hand.png","'",")",",","COLOR_BGR2RGB",")","results","=","hand_tracker.process","(","input_image",")","print","(","results.palm_detections",")","print","(","results.multi_hand_landmarks",")"]
docstr: Initializes the SolutionBase object.
  
  Args:
    binary_graph_path: The path to a binary mediapipe graph file (.binarypb).
    graph_config: A CalculatorGraphConfig proto message or its text proto
      format.
    calculator_params: A mapping from the
      {calculator_name}.{options_field_name} str to the field value.
    graph_options: The graph options protobuf for the mediapipe graph.
    side_inputs: A mapping from the side packet name to the packet raw data.
    outputs: A list of the graph output stream names to observe. If the list
      is empty, all the output streams listed in the graph config will be
      automatically observed by default.
    stream_type_hints: A mapping from the stream name to its packet type hint.
  
  Raises:
    FileNotFoundError: If the binary graph file can't be found.
    RuntimeError: If the underlying calculator graph can't be successfully
      initialized or started.
    ValueError: If any of the following:
      a) If not exactly one of 'binary_graph_path' or 'graph_config' arguments
      is provided.
      b) If the graph validation process contains error.
      c) If the registered type name of the streams and side packets can't be
      found.
      d) If the calculator options of the calculator listed in
      calculator_params is not allowed to be modified.
      e) If the calculator options field is a repeated field but the field
      value to be set is not iterable.
      f) If not all calculator params are valid.
docstr_tok: ["Initializes","the","SolutionBase","object",".","Args",":","binary_graph_path",":","The","path","to","a","binary","mediapipe","graph","file","(",".binarypb",")",".","graph_config",":","A","CalculatorGraphConfig","proto","message","or","its","text","proto","format",".","calculator_params",":","A","mapping","from","the","{","calculator_name","}",".","{","options_field_name","}","str","to","the","field","value",".","graph_options",":","The","graph","options","protobuf","for","the","mediapipe","graph",".","side_inputs",":","A","mapping","from","the","side","packet","name","to","the","packet","raw","data",".","outputs",":","A","list","of","the","graph","output","stream","names","to","observe",".","If","the","list","is","empty",",","all","the","output","streams","listed","in","the","graph","config","will","be","automatically","observed","by","default",".","stream_type_hints",":","A","mapping","from","the","stream","name","to","its","packet","type","hint",".","Raises",":","FileNotFoundError",":","If","the","binary","graph","file","ca","n't","be","found",".","RuntimeError",":","If","the","underlying","calculator","graph","ca","n't","be","successfully","initialized","or","started",".","ValueError",":","If","any","of","the","following",":","a",")","If","not","exactly","one","of","'binary_graph_path","'","or","'graph_config","'","arguments","is","provided",".","b",")","If","the","graph","validation","process","contains","error",".","c",")","If","the","registered","type","name","of","the","streams","and","side","packets","ca","n't","be","found",".","d",")","If","the","calculator","options","of","the","calculator","listed","in","calculator_params","is","not","allowed","to","be","modified",".","e",")","If","the","calculator","options","field","is","a","repeated","field","but","the","field","value","to","be","set","is","not","iterable",".","f",")","If","not","all","calculator","params","are","valid","."]
code: def __init__(
      self,
      binary_graph_path: Optional[str] = None,
      graph_config: Optional[
          calculator_pb2.CalculatorGraphConfig
      ] = None,
      calculator_params: Optional[Mapping[str, Any]] = None,
      graph_options: Optional[message.Message] = None,
      side_inputs: Optional[Mapping[str, Any]] = None,
      outputs: Optional[List[str]] = None,
      stream_type_hints: Optional[Mapping[str, PacketDataType]] = None,
  ):
      """Initializes the SolutionBase object.
  
      Args:
        binary_graph_path: The path to a binary mediapipe graph file (.binarypb).
        graph_config: A CalculatorGraphConfig proto message or its text proto
          format.
        calculator_params: A mapping from the
          {calculator_name}.{options_field_name} str to the field value.
        graph_options: The graph options protobuf for the mediapipe graph.
        side_inputs: A mapping from the side packet name to the packet raw data.
        outputs: A list of the graph output stream names to observe. If the list
          is empty, all the output streams listed in the graph config will be
          automatically observed by default.
        stream_type_hints: A mapping from the stream name to its packet type hint.
  
      Raises:
        FileNotFoundError: If the binary graph file can't be found.
        RuntimeError: If the underlying calculator graph can't be successfully
          initialized or started.
        ValueError: If any of the following:
          a) If not exactly one of 'binary_graph_path' or 'graph_config' arguments
          is provided.
          b) If the graph validation process contains error.
          c) If the registered type name of the streams and side packets can't be
          found.
          d) If the calculator options of the calculator listed in
          calculator_params is not allowed to be modified.
          e) If the calculator options field is a repeated field but the field
          value to be set is not iterable.
          f) If not all calculator params are valid.
      """
      if bool(binary_graph_path) == bool(graph_config):
          raise ValueError(
              "Must provide exactly one of 'binary_graph_path' or 'graph_config'."
          )
      # MediaPipe package root path
      root_path = os.sep.join(
          os.path.abspath(__file__).split(os.sep)[:-3]
      )
      resource_util.set_resource_dir(root_path)
      validated_graph = validated_graph_config.ValidatedGraphConfig()
      if binary_graph_path:
          validated_graph.initialize(
              binary_graph_path=os.path.join(
                  root_path, binary_graph_path
              )
          )
      else:
          validated_graph.initialize(graph_config=graph_config)
  
      canonical_graph_config_proto = self._initialize_graph_interface(
          validated_graph, side_inputs, outputs, stream_type_hints
      )
      if calculator_params:
          self._modify_calculator_options(
              canonical_graph_config_proto, calculator_params
          )
      if graph_options:
          self._set_extension(
              canonical_graph_config_proto.graph_options, graph_options
          )
  
      self._graph = calculator_graph.CalculatorGraph(
          graph_config=canonical_graph_config_proto
      )
      self._simulated_timestamp = 0
      self._graph_outputs = {}
  
      def callback(
          stream_name: str, output_packet: packet.Packet
      ) -> None:
          self._graph_outputs[stream_name] = output_packet
  
      for stream_name in self._output_stream_type_info.keys():
          self._graph.observe_output_stream(stream_name, callback, True)
  
      self._input_side_packets = {
          name: self._make_packet(
              self._side_input_type_info[name], data
          )
          for name, data in (side_inputs or {}).items()
      }
      self._graph.start_run(self._input_side_packets)
  
imports: import collections
  import enum
  import os
  from typing import Any, Iterable, List, Mapping, NamedTuple, Optional, Union
  import numpy
  from google.protobuf.internal import containers
  from google.protobuf import descriptor
  from google.protobuf import message
  from mediapipe.calculators.core import constant_side_packet_calculator_pb2
  from mediapipe.calculators.image import image_transformation_calculator_pb2
  from mediapipe.calculators.tensor import tensors_to_detections_calculator_pb2
  from mediapipe.calculators.util import landmarks_smoothing_calculator_pb2
  from mediapipe.calculators.util import logic_calculator_pb2
  from mediapipe.calculators.util import thresholding_calculator_pb2
  from mediapipe.framework import calculator_pb2
  from mediapipe.framework.formats import body_rig_pb2
  from mediapipe.framework.formats import classification_pb2
  from mediapipe.framework.formats import detection_pb2
  from mediapipe.framework.formats import landmark_pb2
  from mediapipe.framework.formats import rect_pb2
  from mediapipe.modules.objectron.calculators import annotation_data_pb2
  from mediapipe.modules.objectron.calculators import lift_2d_frame_annotation_to_3d_calculator_pb2
  from mediapipe.python import packet_creator
  from mediapipe.python import packet_getter
  from mediapipe.python._framework_bindings import calculator_graph
  from mediapipe.python._framework_bindings import image_frame
  from mediapipe.python._framework_bindings import packet
  from mediapipe.python._framework_bindings import resource_util
  from mediapipe.python._framework_bindings import validated_graph_config
label_desc: Use image node_id 1 to create a new SolutionBase object  with example: obj = SolutionBase(binary_graph_path, graph_config, calculator_params, graph_options, side_inputs, outputs, stream_type_hints)