Real-time Multi-Person Pose Estimation & Object Detection Library
TypeScript port of rtmlib with YOLO12 and MediaPipe support for browser-based AI inference.
- ๐ฏ Object Detection - 80 COCO classes with YOLO12n or MediaPipe EfficientDet
- ๐ง Pose Estimation (2D) - 17 keypoints (COCO) with RTMW or 33 keypoints with MediaPipe BlazePose
- ๐ฏ Pose Estimation (3D) - Full 3D pose with Z-coordinates in meters using RTMW3D-X
- ๐พ Animal Detection - 30 animal species with ViTPose++ pose estimation
- ๐ฎ MediaPipe Integration - TFLite backend for faster inference
- โก Fastest Combo - MediaPipe + RTMW3D for 2-3x faster 3D pose estimation
- ๐น Video Support - Real-time camera & video file processing
- ๐ Browser-based - Pure WebAssembly/WebGL/WebGPU, no backend required
- โก Fast - Optimized for ~200ms inference (416ร416)
- ๐จ Beautiful UI - Modern gradient design in playground
npm install rtmlib-tscd rtmlib-playground-main
npm install
npm run dev
# Open http://localhost:3000import { ObjectDetector, drawResultsOnCanvas } from 'rtmlib-ts';
const detector = new ObjectDetector({
model: 'https://huggingface.co/demon2233/rtmlib-ts/resolve/main/yolo/yolov12n.onnx',
classes: ['person', 'car', 'dog'],
confidence: 0.5,
inputSize: [416, 416],
backend: 'webgl',
});
await detector.init();
const results = await detector.detectFromCanvas(canvas);
drawResultsOnCanvas(ctx, results, 'object');import { ObjectDetector } from 'rtmlib-ts';
const detector = new ObjectDetector({
detectorType: 'mediapipe',
mediaPipeModelPath: 'https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/int8/latest/efficientdet_lite0.tflite',
mediaPipeScoreThreshold: 0.5,
classes: ['person', 'car'],
});
await detector.init();
const results = await detector.detectFromCanvas(canvas);import { PoseDetector, drawResultsOnCanvas } from 'rtmlib-ts';
const detector = new PoseDetector({
detModel: 'https://huggingface.co/demon2233/rtmlib-ts/resolve/main/yolo/yolov12n.onnx',
poseModel: 'https://huggingface.co/demon2233/rtmlib-ts/resolve/main/rtmpose/end2end.onnx',
detInputSize: [416, 416],
poseInputSize: [384, 288],
detConfidence: 0.5,
poseConfidence: 0.3,
backend: 'webgl',
});
await detector.init();
const poses = await detector.detectFromCanvas(canvas);
drawResultsOnCanvas(ctx, poses, 'pose');import { MediaPipeObject3DPoseDetector } from 'rtmlib-ts';
// MediaPipe + RTMW3D = 2-3x faster than YOLO+3D!
const detector = new MediaPipeObject3DPoseDetector({
mpScoreThreshold: 0.5,
poseConfidence: 0.3,
backend: 'webgpu',
personsOnly: true,
});
await detector.init();
const result = await detector.detectFromCanvas(canvas);
console.log(result.keypoints[0][0]); // [x, y, z] in metersimport { AnimalDetector } from 'rtmlib-ts';
const detector = new AnimalDetector({
poseModelType: 'vitpose-b',
classes: ['dog', 'cat', 'horse'],
detConfidence: 0.5,
poseConfidence: 0.3,
backend: 'webgl',
});
await detector.init();
const animals = await detector.detectFromCanvas(canvas);| Model | Input | Time | Use Case |
|---|---|---|---|
| YOLO12n | 416ร416 | ~200ms | Real-time video |
| YOLO12n | 640ร640 | ~500ms | High accuracy |
| MediaPipe EfficientDet | 320ร320 | ~100ms | Fast detection |
| RTMW Pose | 384ร288 | ~100ms | Per person |
| MediaPipe + RTMW3D | 320ร320 + 384ร288 | ~150ms | Fastest 3D pose! |
Optimization Tips:
- Use
416ร416for video/real-time - Use
640ร640for static images - MediaPipe + RTMW3D for fastest 3D pose estimation
- First run is slower (WASM compilation)
- Filter classes to reduce processing
- Use
backend: 'webgpu'for GPU acceleration
Common: person, car, dog, cat, bicycle, bus, truck
Objects: bottle, chair, couch, potted plant
Animals: bird, horse, sheep, cow, elephant
Full list: See COCO_CLASSES export or use class selector in playground
Supported: dog, cat, horse, zebra, elephant, tiger, lion, panda, cow, sheep, bird, and more!
import {
drawDetectionsOnCanvas,
drawPoseOnCanvas,
drawResultsOnCanvas
} from 'rtmlib-ts';
drawResultsOnCanvas(ctx, results, 'object'); // or 'pose', 'pose3d'rtmlib-ts/
โโโ src/
โ โโโ core/ # Base utilities
โ โ โโโ base.ts # BaseTool class
โ โ โโโ modelCache.ts # Model caching
โ โ โโโ preprocessing.ts # Image preprocessing
โ โโโ models/ # Model implementations
โ โ โโโ yolo12.ts # YOLO12 detector
โ โ โโโ rtmpose.ts # RTMPose model
โ โ โโโ rtmpose3d.ts # 3D Pose model
โ โโโ solution/ # High-level APIs
โ โ โโโ objectDetector.ts # ObjectDetector (80 COCO)
โ โ โโโ poseDetector.ts # PoseDetector (YOLO + RTMW)
โ โ โโโ pose3dDetector.ts # Pose3DDetector
โ โ โโโ animalDetector.ts # AnimalDetector (ViTPose)
โ โ โโโ mediaPipeObjectDetector.ts # MediaPipe Object Detection
โ โ โโโ mediaPipePoseDetector.ts # MediaPipe Pose Landmarker
โ โ โโโ mediaPipeObject3DPoseDetector.ts # MediaPipe + RTMW3D
โ โโโ types/ # TypeScript types
โ โโโ visualization/ # Canvas drawing
โโโ docs/ # API documentation
โโโ rtmlib-playground-main/ # Next.js demo app
โโโ README.md
- YOLO - YOLO12n ONNX model (accurate)
- MediaPipe - EfficientDet TFLite model (fast)
- YOLO + RTMW - YOLO12 + RTMWpose (accurate 2D)
- MediaPipe - BlazePose with 33 keypoints (fast 2D)
- YOLO + RTMW3D - YOLO12 + RTMW3D-X (accurate 3D)
- MediaPipe + RTMW3D - EfficientDet + RTMW3D-X (โก fastest 3D!)
- ViTPose-S/B/L - Small/Base/Large models for 30 animal species
- YOLOv26n: Requires model re-export (format mismatch)
- First run: Slow due to WASM compilation
- Mobile: Performance varies by device
- WebGPU: Requires browser support (Chrome 113+)
Apache 2.0
Based on rtmlib by Tao Jiang
YOLO12 by Ultralytics
RTMW by OpenMMLab
MediaPipe by Google