dog_detection library

On-device dog detection and landmark estimation using TensorFlow Lite.

This library provides a Flutter plugin for dog detection using a unified multi-stage TFLite pipeline: SSD body detection, species classification, body pose estimation, face localization, and face landmark extraction.

Quick Start:

import 'package:dog_detection/dog_detection.dart';

final detector = DogDetector(mode: DogDetectionMode.full);
await detector.initialize();

final dogs = await detector.detect(imageBytes);
for (final dog in dogs) {
  print('Dog at ${dog.boundingBox} score=${dog.score}');
  if (dog.pose != null) {
    final tail = dog.pose!.getLandmark(AnimalPoseLandmarkType.tailEnd);
    print('Tail: (${tail?.x}, ${tail?.y})');
  }
  if (dog.face != null && dog.face!.hasLandmarks) {
    final nose = dog.face!.getLandmark(DogLandmarkType.noseBridgeBottom);
    print('Nose: (${nose?.x}, ${nose?.y})');
  }
}

await detector.dispose();

Main Classes:

  • DogDetectorIsolate: Background isolate wrapper for dog detection
  • DogDetector: Main API for dog detection
  • Dog: Top-level detection result with body, pose and face info
  • DogFace: Detected dog face with bounding box and landmarks
  • DogLandmark: Single face keypoint with 2D coordinates
  • BoundingBox: Axis-aligned rectangle in pixel coordinates

Detection Modes:

Pose Model Variants:

Face Landmark Model Variants:

  • DogLandmarkModel.full: Single model at 384px input resolution (bundled)
  • DogLandmarkModel.ensemble: 3-model ensemble (256+320+384px) with multi-scale
    • flip TTA (18 passes). Extra models downloaded on-demand from GitHub Releases (~110MB)

Skeleton Connections:

Classes

Animal
Top-level result for a single detected animal.
AnimalDetector
On-device animal detection using a multi-stage TensorFlow Lite pipeline.
AnimalPose
Full-body pose result for a single detected animal.
AnimalPoseLandmark
A single body pose keypoint with 2D coordinates and a confidence score.
BoundingBox
An axis-aligned or rotated bounding box defined by four corner points.
CropMetadata
Metadata for mapping landmark coordinates from crop space back to original image space.
Dog
Top-level result for a single detected dog.
DogDetectionDart
Dart plugin registration for dog_detection.
DogDetector
On-device dog detection using a unified multi-stage TensorFlow Lite pipeline.
DogDetectorIsolate
A wrapper that runs the entire dog detection pipeline in a background isolate.
DogFace
Detected dog face with bounding box and optional landmarks.
DogLandmark
A single dog face keypoint with 2D coordinates.
Mat
ModelDownloader
Downloads and caches models from GitHub Releases.
PerformanceConfig
Point
A point with x, y, and optional z coordinates.

Enums

AnimalPoseLandmarkType
SuperAnimal body keypoint types (indices 15–38 in the full SuperAnimal topology).
AnimalPoseModel
Body pose model variant for SuperAnimal keypoint extraction.
DogDetectionMode
Detection mode controlling the full pipeline behavior.
DogLandmarkModel
Dog landmark model variant for landmark extraction.
DogLandmarkType
Dog face landmark types based on the DogFLW dataset topology.
PerformanceMode

Constants

animalPoseConnections → const List<List<AnimalPoseLandmarkType>>
Defines the standard skeleton connections between SuperAnimal body keypoints.
dogLandmarkConnections → const List<List<DogLandmarkType>>
Defines the standard skeleton connections between dog face landmarks.
dogLandmarkFlipIndex → const List<int>
Landmark index permutation for horizontal flip (DogFLW convention).
IMREAD_COLOR → const int
numDogLandmarks → const int
Number of dog face landmarks (46 for the DogFLW model).

Functions

imdecode(Uint8List buf, int flags, {Mat? dst}) Mat
imdecode reads an image from a buffer in memory. The function imdecode reads an image from the specified buffer in memory. If the buffer is too short or contains invalid data, the function returns an empty matrix. @param buf Input array or vector of bytes. @param flags The same flags as in cv::imread, see cv::ImreadModes.