AnimalDetectorCore class

On-device animal detection using a multi-stage TensorFlow Lite pipeline.

Runs SSD body detection, species classification, and optionally body pose estimation. Returns a list of Animal objects with bounding boxes, species labels, and pose keypoints.

Usage:

final detector = AnimalDetectorCore();
await detector.initializeFromBuffers(...);
final animals = await detector.detect(imageBytes);
await detector.dispose();

Constructors

AnimalDetectorCore({AnimalPoseModel poseModel = AnimalPoseModel.rtmpose, bool enablePose = true, double cropMargin = 0.20, double detThreshold = 0.5, PerformanceConfig performanceConfig = const PerformanceConfig(), PerformanceConfig? posePerformanceConfig})
Creates an animal detector with the specified configuration.

Properties

cropMargin double
Margin fraction added to each side of the body bounding box before cropping.
final
detThreshold double
SSD detection score threshold.
final
effectivePoseConfig PerformanceConfig
The config the pose stage actually runs with.
no setter
enablePose bool
Whether to run pose estimation.
final
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Returns true if the detector has been initialized and is ready to use.
no setter
performanceConfig PerformanceConfig
Performance configuration for TensorFlow Lite inference.
final
poseModel AnimalPoseModel
Body pose model variant.
final
posePerformanceConfig PerformanceConfig?
Optional override of performanceConfig for the body pose stage alone.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

detect(Uint8List imageBytes) Future<List<Animal>>
Detects animals in an image from raw bytes.
detectFromMat(Mat image, {required int imageWidth, required int imageHeight}) Future<List<Animal>>
Detects animals in an OpenCV Mat image.
dispose() Future<void>
Releases all resources used by the detector.
initialize({void onDownloadProgress(String model, int received, int total)?, bool useIsolateInterpreter = true}) Future<void>
Initializes the detector by loading TensorFlow Lite models.
initializeFromBuffers({required Uint8List bodyDetectorBytes, required Uint8List classifierBytes, required String speciesMappingJson, Uint8List? poseModelBytes, bool useIsolateInterpreter = true, bool useCompiledModel = false, bool compiledForceCpu = false, Set<Accelerator> accelerators = const {Accelerator.gpu, Accelerator.cpu}, Precision precision = Precision.fp32}) Future<void>
Initializes the 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

Static Methods

isHrnetCached() Future<bool>
Returns true if the HRNet model is already cached locally.