HandDetector class
On-device hand detection and landmark estimation using TensorFlow Lite.
Implements a two-stage pipeline based on MediaPipe:
- Palm detection using SSD-based detector with rotation rectangle output
- Hand landmark model to extract 21 keypoints per detected hand
Uses the same models and algorithms as MediaPipe for anchor generation, box decoding, and rotation handling.
Usage:
final detector = HandDetector(
mode: HandMode.boxesAndLandmarks,
landmarkModel: HandLandmarkModel.full,
);
await detector.initialize();
final hands = await detector.detect(imageBytes);
await detector.dispose();
Constructors
- HandDetector({HandMode mode = HandMode.boxesAndLandmarks, HandLandmarkModel landmarkModel = HandLandmarkModel.full, double detectorConf = 0.45, int maxDetections = 10, double minLandmarkScore = 0.5, int interpreterPoolSize = 1, PerformanceConfig performanceConfig = const PerformanceConfig(), bool enableGestures = false, double gestureMinConfidence = 0.5})
- Creates a hand detector with the specified configuration.
Properties
- detectorConf → double
-
Confidence threshold for palm detection (0.0 to 1.0).
final
- enableGestures → bool
-
Whether to run gesture recognition on detected hands.
When enabled, each detected hand will include a GestureResult.
final
- gestureMinConfidence → double
-
Minimum confidence threshold for gesture recognition (0.0 to 1.0).
Gestures with confidence below this threshold will be reported as GestureType.unknown.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- interpreterPoolSize → int
-
Number of TensorFlow Lite interpreter instances in the landmark model pool.
final
- isInitialized → bool
-
Returns true if the detector has been initialized and is ready to use.
no setter
- landmarkModel → HandLandmarkModel
-
Hand landmark model variant to use for landmark extraction.
final
- maxDetections → int
-
Maximum number of hands to detect per image.
final
- minLandmarkScore → double
-
Minimum confidence score for landmark predictions (0.0 to 1.0).
final
- mode → HandMode
-
Detection mode controlling pipeline behavior.
final
- performanceConfig → PerformanceConfig
-
Performance configuration for TensorFlow Lite inference.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
detect(
List< int> imageBytes) → Future<List< Hand> > - Detects hands in an image from raw bytes.
-
detectOnMat(
Mat image) → Future< List< Hand> > - Detects hands in an OpenCV Mat image.
-
dispose(
) → Future< void> - Releases all resources used by the detector.
-
initialize(
) → Future< void> - Initializes the hand detector by loading TensorFlow Lite models.
-
initializeFromBuffers(
{required Uint8List palmDetectionBytes, required Uint8List handLandmarkBytes, Uint8List? gestureEmbedderBytes, Uint8List? gestureClassifierBytes}) → Future< void> - Initializes the hand detector from pre-loaded model bytes.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited