Rename GestureRecognitionResult to GestureRecognizerResult.
PiperOrigin-RevId: 487306292
This commit is contained in:
		
							parent
							
								
									4e568a1c3d
								
							
						
					
					
						commit
						6f66a7fde4
					
				| 
						 | 
					@ -23,6 +23,7 @@ import mediapipe.tasks.python.vision.object_detector
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GestureRecognizer = gesture_recognizer.GestureRecognizer
 | 
					GestureRecognizer = gesture_recognizer.GestureRecognizer
 | 
				
			||||||
GestureRecognizerOptions = gesture_recognizer.GestureRecognizerOptions
 | 
					GestureRecognizerOptions = gesture_recognizer.GestureRecognizerOptions
 | 
				
			||||||
 | 
					GestureRecognizerResult = gesture_recognizer.GestureRecognizerResult
 | 
				
			||||||
HandLandmarker = hand_landmarker.HandLandmarker
 | 
					HandLandmarker = hand_landmarker.HandLandmarker
 | 
				
			||||||
HandLandmarkerOptions = hand_landmarker.HandLandmarkerOptions
 | 
					HandLandmarkerOptions = hand_landmarker.HandLandmarkerOptions
 | 
				
			||||||
HandLandmarkerResult = hand_landmarker.HandLandmarkerResult
 | 
					HandLandmarkerResult = hand_landmarker.HandLandmarkerResult
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,7 @@ _GESTURE_DEFAULT_INDEX = -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@dataclasses.dataclass
 | 
					@dataclasses.dataclass
 | 
				
			||||||
class GestureRecognitionResult:
 | 
					class GestureRecognizerResult:
 | 
				
			||||||
  """The gesture recognition result from GestureRecognizer, where each vector element represents a single hand detected in the image.
 | 
					  """The gesture recognition result from GestureRecognizer, where each vector element represents a single hand detected in the image.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Attributes:
 | 
					  Attributes:
 | 
				
			||||||
| 
						 | 
					@ -79,8 +79,8 @@ class GestureRecognitionResult:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _build_recognition_result(
 | 
					def _build_recognition_result(
 | 
				
			||||||
    output_packets: Mapping[str,
 | 
					    output_packets: Mapping[str,
 | 
				
			||||||
                            packet_module.Packet]) -> GestureRecognitionResult:
 | 
					                            packet_module.Packet]) -> GestureRecognizerResult:
 | 
				
			||||||
  """Consturcts a `GestureRecognitionResult` from output packets."""
 | 
					  """Consturcts a `GestureRecognizerResult` from output packets."""
 | 
				
			||||||
  gestures_proto_list = packet_getter.get_proto_list(
 | 
					  gestures_proto_list = packet_getter.get_proto_list(
 | 
				
			||||||
      output_packets[_HAND_GESTURE_STREAM_NAME])
 | 
					      output_packets[_HAND_GESTURE_STREAM_NAME])
 | 
				
			||||||
  handedness_proto_list = packet_getter.get_proto_list(
 | 
					  handedness_proto_list = packet_getter.get_proto_list(
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ def _build_recognition_result(
 | 
				
			||||||
          landmark_module.Landmark.create_from_pb2(hand_world_landmark))
 | 
					          landmark_module.Landmark.create_from_pb2(hand_world_landmark))
 | 
				
			||||||
    hand_world_landmarks_results.append(hand_world_landmarks_list)
 | 
					    hand_world_landmarks_results.append(hand_world_landmarks_list)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return GestureRecognitionResult(gesture_results, handedness_results,
 | 
					  return GestureRecognizerResult(gesture_results, handedness_results,
 | 
				
			||||||
                                 hand_landmarks_results,
 | 
					                                 hand_landmarks_results,
 | 
				
			||||||
                                 hand_world_landmarks_results)
 | 
					                                 hand_world_landmarks_results)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -185,7 +185,7 @@ class GestureRecognizerOptions:
 | 
				
			||||||
  custom_gesture_classifier_options: Optional[
 | 
					  custom_gesture_classifier_options: Optional[
 | 
				
			||||||
      _ClassifierOptions] = _ClassifierOptions()
 | 
					      _ClassifierOptions] = _ClassifierOptions()
 | 
				
			||||||
  result_callback: Optional[Callable[
 | 
					  result_callback: Optional[Callable[
 | 
				
			||||||
      [GestureRecognitionResult, image_module.Image, int], None]] = None
 | 
					      [GestureRecognizerResult, image_module.Image, int], None]] = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @doc_controls.do_not_generate_docs
 | 
					  @doc_controls.do_not_generate_docs
 | 
				
			||||||
  def to_pb2(self) -> _GestureRecognizerGraphOptionsProto:
 | 
					  def to_pb2(self) -> _GestureRecognizerGraphOptionsProto:
 | 
				
			||||||
| 
						 | 
					@ -266,7 +266,7 @@ class GestureRecognizer(base_vision_task_api.BaseVisionTaskApi):
 | 
				
			||||||
      if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
					      if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
				
			||||||
        empty_packet = output_packets[_HAND_GESTURE_STREAM_NAME]
 | 
					        empty_packet = output_packets[_HAND_GESTURE_STREAM_NAME]
 | 
				
			||||||
        options.result_callback(
 | 
					        options.result_callback(
 | 
				
			||||||
            GestureRecognitionResult([], [], [], []), image,
 | 
					            GestureRecognizerResult([], [], [], []), image,
 | 
				
			||||||
            empty_packet.timestamp.value // _MICRO_SECONDS_PER_MILLISECOND)
 | 
					            empty_packet.timestamp.value // _MICRO_SECONDS_PER_MILLISECOND)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -301,7 +301,7 @@ class GestureRecognizer(base_vision_task_api.BaseVisionTaskApi):
 | 
				
			||||||
      self,
 | 
					      self,
 | 
				
			||||||
      image: image_module.Image,
 | 
					      image: image_module.Image,
 | 
				
			||||||
      image_processing_options: Optional[_ImageProcessingOptions] = None
 | 
					      image_processing_options: Optional[_ImageProcessingOptions] = None
 | 
				
			||||||
  ) -> GestureRecognitionResult:
 | 
					  ) -> GestureRecognizerResult:
 | 
				
			||||||
    """Performs hand gesture recognition on the given image.
 | 
					    """Performs hand gesture recognition on the given image.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Only use this method when the GestureRecognizer is created with the image
 | 
					    Only use this method when the GestureRecognizer is created with the image
 | 
				
			||||||
| 
						 | 
					@ -332,7 +332,7 @@ class GestureRecognizer(base_vision_task_api.BaseVisionTaskApi):
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
					    if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
				
			||||||
      return GestureRecognitionResult([], [], [], [])
 | 
					      return GestureRecognizerResult([], [], [], [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return _build_recognition_result(output_packets)
 | 
					    return _build_recognition_result(output_packets)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -341,7 +341,7 @@ class GestureRecognizer(base_vision_task_api.BaseVisionTaskApi):
 | 
				
			||||||
      image: image_module.Image,
 | 
					      image: image_module.Image,
 | 
				
			||||||
      timestamp_ms: int,
 | 
					      timestamp_ms: int,
 | 
				
			||||||
      image_processing_options: Optional[_ImageProcessingOptions] = None
 | 
					      image_processing_options: Optional[_ImageProcessingOptions] = None
 | 
				
			||||||
  ) -> GestureRecognitionResult:
 | 
					  ) -> GestureRecognizerResult:
 | 
				
			||||||
    """Performs gesture recognition on the provided video frame.
 | 
					    """Performs gesture recognition on the provided video frame.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Only use this method when the GestureRecognizer is created with the video
 | 
					    Only use this method when the GestureRecognizer is created with the video
 | 
				
			||||||
| 
						 | 
					@ -376,7 +376,7 @@ class GestureRecognizer(base_vision_task_api.BaseVisionTaskApi):
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
					    if output_packets[_HAND_GESTURE_STREAM_NAME].is_empty():
 | 
				
			||||||
      return GestureRecognitionResult([], [], [], [])
 | 
					      return GestureRecognizerResult([], [], [], [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return _build_recognition_result(output_packets)
 | 
					    return _build_recognition_result(output_packets)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user