class_docstr: Represents one detected object in the object detector's results.
  
  Attributes:
    bounding_box: A BoundingBox object.
    categories: A list of Category objects.
    keypoints: A list of NormalizedKeypoint objects.
class_docstr_tok: ["Represents","one","detected","object","in","the","object","detector","'s","results",".","Attributes",":","bounding_box",":","A","BoundingBox","object",".","categories",":","A","list","of","Category","objects",".","keypoints",":","A","list","of","NormalizedKeypoint","objects","."]
docstr: Creates a `Detection` object from the given protobuf object.
docstr_tok: ["Creates","a","`","Detection","`","object","from","the","given","protobuf","object","."]
code: def create_from_pb2(cls, pb2_obj: _DetectionProto) -> "Detection":
      """Creates a `Detection` object from the given protobuf object."""
      categories = []
      keypoints = []
  
      for idx, score in enumerate(pb2_obj.score):
          categories.append(
              category_module.Category(
                  score=score,
                  index=pb2_obj.label_id[idx]
                  if idx < len(pb2_obj.label_id)
                  else None,
                  category_name=pb2_obj.label[idx]
                  if idx < len(pb2_obj.label)
                  else None,
                  display_name=pb2_obj.display_name[idx]
                  if idx < len(pb2_obj.display_name)
                  else None,
              )
          )
  
      if pb2_obj.location_data.relative_keypoints:
          for idx, elem in enumerate(
              pb2_obj.location_data.relative_keypoints
          ):
              keypoints.append(
                  keypoint_module.NormalizedKeypoint(
                      x=elem.x,
                      y=elem.y,
                      label=elem.keypoint_label,
                      score=elem.score,
                  )
              )
  
      return Detection(
          bounding_box=bounding_box_module.BoundingBox.create_from_pb2(
              pb2_obj.location_data.bounding_box
          ),
          categories=categories,
          keypoints=keypoints,
      )
  
file_path: mediapipe/mediapipe/tasks/python/components/containers/detections.py
imports: import dataclasses
  from typing import Any, List, Optional
  from mediapipe.framework.formats import detection_pb2
  from mediapipe.framework.formats import location_data_pb2
  from mediapipe.tasks.python.components.containers import bounding_box
  from mediapipe.tasks.python.components.containers import category
  from mediapipe.tasks.python.components.containers import keypoint
  from mediapipe.tasks.python.core.optional_dependencies import doc_controls
label_desc: Use image node_id 2 for calling the Detection obj's underlying member method code with example usage: obj.create_from_pb2(cls, pb2_obj) and returns: Detection