rtmlib-ts 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -0
- package/README.md +202 -0
- package/dist/core/base.d.ts +20 -0
- package/dist/core/base.d.ts.map +1 -0
- package/dist/core/base.js +40 -0
- package/dist/core/file.d.ts +11 -0
- package/dist/core/file.d.ts.map +1 -0
- package/dist/core/file.js +111 -0
- package/dist/core/modelCache.d.ts +35 -0
- package/dist/core/modelCache.d.ts.map +1 -0
- package/dist/core/modelCache.js +161 -0
- package/dist/core/posePostprocessing.d.ts +12 -0
- package/dist/core/posePostprocessing.d.ts.map +1 -0
- package/dist/core/posePostprocessing.js +76 -0
- package/dist/core/postprocessing.d.ts +10 -0
- package/dist/core/postprocessing.d.ts.map +1 -0
- package/dist/core/postprocessing.js +70 -0
- package/dist/core/preprocessing.d.ts +14 -0
- package/dist/core/preprocessing.d.ts.map +1 -0
- package/dist/core/preprocessing.js +79 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/models/rtmpose.d.ts +25 -0
- package/dist/models/rtmpose.d.ts.map +1 -0
- package/dist/models/rtmpose.js +185 -0
- package/dist/models/rtmpose3d.d.ts +28 -0
- package/dist/models/rtmpose3d.d.ts.map +1 -0
- package/dist/models/rtmpose3d.js +184 -0
- package/dist/models/yolo12.d.ts +23 -0
- package/dist/models/yolo12.d.ts.map +1 -0
- package/dist/models/yolo12.js +165 -0
- package/dist/models/yolox.d.ts +18 -0
- package/dist/models/yolox.d.ts.map +1 -0
- package/dist/models/yolox.js +167 -0
- package/dist/solution/animalDetector.d.ts +229 -0
- package/dist/solution/animalDetector.d.ts.map +1 -0
- package/dist/solution/animalDetector.js +663 -0
- package/dist/solution/body.d.ts +16 -0
- package/dist/solution/body.d.ts.map +1 -0
- package/dist/solution/body.js +52 -0
- package/dist/solution/bodyWithFeet.d.ts +16 -0
- package/dist/solution/bodyWithFeet.d.ts.map +1 -0
- package/dist/solution/bodyWithFeet.js +52 -0
- package/dist/solution/customDetector.d.ts +137 -0
- package/dist/solution/customDetector.d.ts.map +1 -0
- package/dist/solution/customDetector.js +342 -0
- package/dist/solution/hand.d.ts +14 -0
- package/dist/solution/hand.d.ts.map +1 -0
- package/dist/solution/hand.js +20 -0
- package/dist/solution/index.d.ts +10 -0
- package/dist/solution/index.d.ts.map +1 -0
- package/dist/solution/index.js +9 -0
- package/dist/solution/objectDetector.d.ts +172 -0
- package/dist/solution/objectDetector.d.ts.map +1 -0
- package/dist/solution/objectDetector.js +606 -0
- package/dist/solution/pose3dDetector.d.ts +145 -0
- package/dist/solution/pose3dDetector.d.ts.map +1 -0
- package/dist/solution/pose3dDetector.js +611 -0
- package/dist/solution/poseDetector.d.ts +198 -0
- package/dist/solution/poseDetector.d.ts.map +1 -0
- package/dist/solution/poseDetector.js +622 -0
- package/dist/solution/poseTracker.d.ts +22 -0
- package/dist/solution/poseTracker.d.ts.map +1 -0
- package/dist/solution/poseTracker.js +106 -0
- package/dist/solution/wholebody.d.ts +19 -0
- package/dist/solution/wholebody.d.ts.map +1 -0
- package/dist/solution/wholebody.js +82 -0
- package/dist/solution/wholebody3d.d.ts +22 -0
- package/dist/solution/wholebody3d.d.ts.map +1 -0
- package/dist/solution/wholebody3d.js +75 -0
- package/dist/types/index.d.ts +52 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/visualization/draw.d.ts +57 -0
- package/dist/visualization/draw.d.ts.map +1 -0
- package/dist/visualization/draw.js +400 -0
- package/dist/visualization/skeleton/coco133.d.ts +350 -0
- package/dist/visualization/skeleton/coco133.d.ts.map +1 -0
- package/dist/visualization/skeleton/coco133.js +120 -0
- package/dist/visualization/skeleton/coco17.d.ts +180 -0
- package/dist/visualization/skeleton/coco17.d.ts.map +1 -0
- package/dist/visualization/skeleton/coco17.js +48 -0
- package/dist/visualization/skeleton/halpe26.d.ts +278 -0
- package/dist/visualization/skeleton/halpe26.d.ts.map +1 -0
- package/dist/visualization/skeleton/halpe26.js +70 -0
- package/dist/visualization/skeleton/hand21.d.ts +196 -0
- package/dist/visualization/skeleton/hand21.d.ts.map +1 -0
- package/dist/visualization/skeleton/hand21.js +51 -0
- package/dist/visualization/skeleton/index.d.ts +10 -0
- package/dist/visualization/skeleton/index.d.ts.map +1 -0
- package/dist/visualization/skeleton/index.js +9 -0
- package/dist/visualization/skeleton/openpose134.d.ts +357 -0
- package/dist/visualization/skeleton/openpose134.d.ts.map +1 -0
- package/dist/visualization/skeleton/openpose134.js +116 -0
- package/dist/visualization/skeleton/openpose18.d.ts +177 -0
- package/dist/visualization/skeleton/openpose18.d.ts.map +1 -0
- package/dist/visualization/skeleton/openpose18.js +47 -0
- package/docs/ANIMAL_DETECTOR.md +450 -0
- package/docs/CUSTOM_DETECTOR.md +568 -0
- package/docs/OBJECT_DETECTOR.md +373 -0
- package/docs/POSE3D_DETECTOR.md +458 -0
- package/docs/POSE_DETECTOR.md +442 -0
- package/examples/README.md +119 -0
- package/examples/index.html +746 -0
- package/package.json +51 -0
- package/playground/README.md +114 -0
- package/playground/app/favicon.ico +0 -0
- package/playground/app/globals.css +17 -0
- package/playground/app/layout.tsx +19 -0
- package/playground/app/page.tsx +1338 -0
- package/playground/eslint.config.mjs +18 -0
- package/playground/next.config.ts +34 -0
- package/playground/package-lock.json +6723 -0
- package/playground/package.json +27 -0
- package/playground/postcss.config.mjs +7 -0
- package/playground/tsconfig.json +34 -0
- package/src/core/base.ts +66 -0
- package/src/core/file.ts +141 -0
- package/src/core/modelCache.ts +189 -0
- package/src/core/posePostprocessing.ts +91 -0
- package/src/core/postprocessing.ts +93 -0
- package/src/core/preprocessing.ts +127 -0
- package/src/index.ts +69 -0
- package/src/models/rtmpose.ts +265 -0
- package/src/models/rtmpose3d.ts +289 -0
- package/src/models/yolo12.ts +220 -0
- package/src/models/yolox.ts +214 -0
- package/src/solution/animalDetector.ts +955 -0
- package/src/solution/body.ts +89 -0
- package/src/solution/bodyWithFeet.ts +89 -0
- package/src/solution/customDetector.ts +474 -0
- package/src/solution/hand.ts +52 -0
- package/src/solution/index.ts +10 -0
- package/src/solution/objectDetector.ts +816 -0
- package/src/solution/pose3dDetector.ts +890 -0
- package/src/solution/poseDetector.ts +892 -0
- package/src/solution/poseTracker.ts +172 -0
- package/src/solution/wholebody.ts +130 -0
- package/src/solution/wholebody3d.ts +125 -0
- package/src/types/index.ts +62 -0
- package/src/visualization/draw.ts +543 -0
- package/src/visualization/skeleton/coco133.ts +131 -0
- package/src/visualization/skeleton/coco17.ts +49 -0
- package/src/visualization/skeleton/halpe26.ts +71 -0
- package/src/visualization/skeleton/hand21.ts +52 -0
- package/src/visualization/skeleton/index.ts +10 -0
- package/src/visualization/skeleton/openpose134.ts +125 -0
- package/src/visualization/skeleton/openpose18.ts +48 -0
- package/tsconfig.json +32 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rtmlib-ts",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "High-performance browser-based AI library for real-time object detection (YOLO12) and pose estimation (RTMW) using ONNX Runtime Web",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"playground": "npm i && cd playground && npm run build"
|
|
12
|
+
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"pose-estimation",
|
|
16
|
+
"rtmpose",
|
|
17
|
+
"dwpose",
|
|
18
|
+
"rtmo",
|
|
19
|
+
"rtmw",
|
|
20
|
+
"yolo",
|
|
21
|
+
"yolo12",
|
|
22
|
+
"object-detection",
|
|
23
|
+
"computer-vision",
|
|
24
|
+
"onnx",
|
|
25
|
+
"webassembly"
|
|
26
|
+
],
|
|
27
|
+
"author": "Based on rtmlib by Tao Jiang",
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/GOH23/rtmlib-ts"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/GOH23/rtmlib-ts/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/GOH23/rtmlib-ts#readme",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"jszip": "^3.10.1",
|
|
39
|
+
"onnxruntime-web": "^1.24.3",
|
|
40
|
+
"opencv-bindings": "^4.5.5",
|
|
41
|
+
"sharp": "^0.34.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.19.15",
|
|
45
|
+
"next": "^16.1.6",
|
|
46
|
+
"react": "^19.2.3",
|
|
47
|
+
"react-dom": "^19.2.3",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"typescript": "^5.7.3"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# rtmlib-ts Playground
|
|
2
|
+
|
|
3
|
+
Interactive Next.js app for testing rtmlib-ts library features.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
npm install
|
|
10
|
+
|
|
11
|
+
# Run development server
|
|
12
|
+
npm run dev
|
|
13
|
+
|
|
14
|
+
# Open in browser
|
|
15
|
+
http://localhost:3000
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
### Object Detection
|
|
21
|
+
- Detect any of 80 COCO classes
|
|
22
|
+
- Filter by specific classes (person, car, dog, etc.)
|
|
23
|
+
- Real-time camera support
|
|
24
|
+
- Image upload
|
|
25
|
+
|
|
26
|
+
### Pose Estimation
|
|
27
|
+
- 17 keypoints per person
|
|
28
|
+
- Skeleton visualization
|
|
29
|
+
- Real-time camera support
|
|
30
|
+
- Image upload
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
1. **Select Mode**: Choose between Object Detection or Pose Estimation
|
|
35
|
+
2. **Choose Input**:
|
|
36
|
+
- Click "Use Camera" for live detection
|
|
37
|
+
- Click "Upload Image" to process a file
|
|
38
|
+
3. **Select Classes** (Object Detection only):
|
|
39
|
+
- Check specific classes to detect
|
|
40
|
+
- Uncheck all to detect all 80 classes
|
|
41
|
+
4. **Click Detect**: Run inference and see results
|
|
42
|
+
|
|
43
|
+
## Models
|
|
44
|
+
|
|
45
|
+
Models are served from `/public/models/`:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
public/models/
|
|
49
|
+
├── yolo/
|
|
50
|
+
│ ├── yolov12n.onnx # Object detection
|
|
51
|
+
│ └── yolov26n.onnx
|
|
52
|
+
└── rtmpose/
|
|
53
|
+
└── end2end.onnx # Pose estimation
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Tech Stack
|
|
57
|
+
|
|
58
|
+
- **Framework**: Next.js 15 (App Router)
|
|
59
|
+
- **Library**: rtmlib-ts (local import)
|
|
60
|
+
- **Backend**: ONNX Runtime Web (WASM)
|
|
61
|
+
- **Styling**: Inline CSS (no dependencies)
|
|
62
|
+
|
|
63
|
+
## Code Example
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { ObjectDetector, PoseDetector } from 'rtmlib-ts';
|
|
67
|
+
|
|
68
|
+
// Object Detection
|
|
69
|
+
const detector = new ObjectDetector({
|
|
70
|
+
model: '/models/yolo/yolov12n.onnx',
|
|
71
|
+
classes: ['person', 'car'],
|
|
72
|
+
});
|
|
73
|
+
await detector.init();
|
|
74
|
+
const objects = await detector.detectFromCanvas(canvas);
|
|
75
|
+
|
|
76
|
+
// Pose Estimation
|
|
77
|
+
const poseDetector = new PoseDetector({
|
|
78
|
+
detModel: '/models/yolo/yolov12n.onnx',
|
|
79
|
+
poseModel: '/models/rtmpose/end2end.onnx',
|
|
80
|
+
});
|
|
81
|
+
await poseDetector.init();
|
|
82
|
+
const people = await poseDetector.detectFromCanvas(canvas);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Performance
|
|
86
|
+
|
|
87
|
+
Expected inference times (varies by device):
|
|
88
|
+
|
|
89
|
+
| Mode | Input | Time |
|
|
90
|
+
|------|-------|------|
|
|
91
|
+
| Object (WASM) | 640×640 | ~80ms |
|
|
92
|
+
| Object (WebGPU) | 640×640 | ~30ms |
|
|
93
|
+
| Pose (WASM) | 640×640 | ~150ms |
|
|
94
|
+
| Pose (WebGPU) | 640×640 | ~60ms |
|
|
95
|
+
|
|
96
|
+
## Troubleshooting
|
|
97
|
+
|
|
98
|
+
### "Models not found"
|
|
99
|
+
- Ensure models are in `public/models/`
|
|
100
|
+
- Check browser console for 404 errors
|
|
101
|
+
|
|
102
|
+
### "Camera not working"
|
|
103
|
+
- Grant camera permissions
|
|
104
|
+
- Use HTTPS or localhost
|
|
105
|
+
- Check browser compatibility
|
|
106
|
+
|
|
107
|
+
### "Slow inference"
|
|
108
|
+
- Switch to WebGPU backend in code
|
|
109
|
+
- Reduce input size
|
|
110
|
+
- Use fewer classes
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
Apache 2.0
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
9
|
+
color: #fff;
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
11
|
+
min-height: 100vh;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@keyframes pulse {
|
|
15
|
+
0%, 100% { opacity: 1; }
|
|
16
|
+
50% { opacity: 0.7; }
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import "./globals.css";
|
|
3
|
+
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
title: "rtmlib-ts Playground",
|
|
6
|
+
description: "Test Object Detection and Pose Estimation",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function RootLayout({
|
|
10
|
+
children,
|
|
11
|
+
}: Readonly<{
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}>) {
|
|
14
|
+
return (
|
|
15
|
+
<html lang="en">
|
|
16
|
+
<body>{children}</body>
|
|
17
|
+
</html>
|
|
18
|
+
);
|
|
19
|
+
}
|