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.
Files changed (150) hide show
  1. package/.gitattributes +1 -0
  2. package/README.md +202 -0
  3. package/dist/core/base.d.ts +20 -0
  4. package/dist/core/base.d.ts.map +1 -0
  5. package/dist/core/base.js +40 -0
  6. package/dist/core/file.d.ts +11 -0
  7. package/dist/core/file.d.ts.map +1 -0
  8. package/dist/core/file.js +111 -0
  9. package/dist/core/modelCache.d.ts +35 -0
  10. package/dist/core/modelCache.d.ts.map +1 -0
  11. package/dist/core/modelCache.js +161 -0
  12. package/dist/core/posePostprocessing.d.ts +12 -0
  13. package/dist/core/posePostprocessing.d.ts.map +1 -0
  14. package/dist/core/posePostprocessing.js +76 -0
  15. package/dist/core/postprocessing.d.ts +10 -0
  16. package/dist/core/postprocessing.d.ts.map +1 -0
  17. package/dist/core/postprocessing.js +70 -0
  18. package/dist/core/preprocessing.d.ts +14 -0
  19. package/dist/core/preprocessing.d.ts.map +1 -0
  20. package/dist/core/preprocessing.js +79 -0
  21. package/dist/index.d.ts +27 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +31 -0
  24. package/dist/models/rtmpose.d.ts +25 -0
  25. package/dist/models/rtmpose.d.ts.map +1 -0
  26. package/dist/models/rtmpose.js +185 -0
  27. package/dist/models/rtmpose3d.d.ts +28 -0
  28. package/dist/models/rtmpose3d.d.ts.map +1 -0
  29. package/dist/models/rtmpose3d.js +184 -0
  30. package/dist/models/yolo12.d.ts +23 -0
  31. package/dist/models/yolo12.d.ts.map +1 -0
  32. package/dist/models/yolo12.js +165 -0
  33. package/dist/models/yolox.d.ts +18 -0
  34. package/dist/models/yolox.d.ts.map +1 -0
  35. package/dist/models/yolox.js +167 -0
  36. package/dist/solution/animalDetector.d.ts +229 -0
  37. package/dist/solution/animalDetector.d.ts.map +1 -0
  38. package/dist/solution/animalDetector.js +663 -0
  39. package/dist/solution/body.d.ts +16 -0
  40. package/dist/solution/body.d.ts.map +1 -0
  41. package/dist/solution/body.js +52 -0
  42. package/dist/solution/bodyWithFeet.d.ts +16 -0
  43. package/dist/solution/bodyWithFeet.d.ts.map +1 -0
  44. package/dist/solution/bodyWithFeet.js +52 -0
  45. package/dist/solution/customDetector.d.ts +137 -0
  46. package/dist/solution/customDetector.d.ts.map +1 -0
  47. package/dist/solution/customDetector.js +342 -0
  48. package/dist/solution/hand.d.ts +14 -0
  49. package/dist/solution/hand.d.ts.map +1 -0
  50. package/dist/solution/hand.js +20 -0
  51. package/dist/solution/index.d.ts +10 -0
  52. package/dist/solution/index.d.ts.map +1 -0
  53. package/dist/solution/index.js +9 -0
  54. package/dist/solution/objectDetector.d.ts +172 -0
  55. package/dist/solution/objectDetector.d.ts.map +1 -0
  56. package/dist/solution/objectDetector.js +606 -0
  57. package/dist/solution/pose3dDetector.d.ts +145 -0
  58. package/dist/solution/pose3dDetector.d.ts.map +1 -0
  59. package/dist/solution/pose3dDetector.js +611 -0
  60. package/dist/solution/poseDetector.d.ts +198 -0
  61. package/dist/solution/poseDetector.d.ts.map +1 -0
  62. package/dist/solution/poseDetector.js +622 -0
  63. package/dist/solution/poseTracker.d.ts +22 -0
  64. package/dist/solution/poseTracker.d.ts.map +1 -0
  65. package/dist/solution/poseTracker.js +106 -0
  66. package/dist/solution/wholebody.d.ts +19 -0
  67. package/dist/solution/wholebody.d.ts.map +1 -0
  68. package/dist/solution/wholebody.js +82 -0
  69. package/dist/solution/wholebody3d.d.ts +22 -0
  70. package/dist/solution/wholebody3d.d.ts.map +1 -0
  71. package/dist/solution/wholebody3d.js +75 -0
  72. package/dist/types/index.d.ts +52 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/dist/types/index.js +5 -0
  75. package/dist/visualization/draw.d.ts +57 -0
  76. package/dist/visualization/draw.d.ts.map +1 -0
  77. package/dist/visualization/draw.js +400 -0
  78. package/dist/visualization/skeleton/coco133.d.ts +350 -0
  79. package/dist/visualization/skeleton/coco133.d.ts.map +1 -0
  80. package/dist/visualization/skeleton/coco133.js +120 -0
  81. package/dist/visualization/skeleton/coco17.d.ts +180 -0
  82. package/dist/visualization/skeleton/coco17.d.ts.map +1 -0
  83. package/dist/visualization/skeleton/coco17.js +48 -0
  84. package/dist/visualization/skeleton/halpe26.d.ts +278 -0
  85. package/dist/visualization/skeleton/halpe26.d.ts.map +1 -0
  86. package/dist/visualization/skeleton/halpe26.js +70 -0
  87. package/dist/visualization/skeleton/hand21.d.ts +196 -0
  88. package/dist/visualization/skeleton/hand21.d.ts.map +1 -0
  89. package/dist/visualization/skeleton/hand21.js +51 -0
  90. package/dist/visualization/skeleton/index.d.ts +10 -0
  91. package/dist/visualization/skeleton/index.d.ts.map +1 -0
  92. package/dist/visualization/skeleton/index.js +9 -0
  93. package/dist/visualization/skeleton/openpose134.d.ts +357 -0
  94. package/dist/visualization/skeleton/openpose134.d.ts.map +1 -0
  95. package/dist/visualization/skeleton/openpose134.js +116 -0
  96. package/dist/visualization/skeleton/openpose18.d.ts +177 -0
  97. package/dist/visualization/skeleton/openpose18.d.ts.map +1 -0
  98. package/dist/visualization/skeleton/openpose18.js +47 -0
  99. package/docs/ANIMAL_DETECTOR.md +450 -0
  100. package/docs/CUSTOM_DETECTOR.md +568 -0
  101. package/docs/OBJECT_DETECTOR.md +373 -0
  102. package/docs/POSE3D_DETECTOR.md +458 -0
  103. package/docs/POSE_DETECTOR.md +442 -0
  104. package/examples/README.md +119 -0
  105. package/examples/index.html +746 -0
  106. package/package.json +51 -0
  107. package/playground/README.md +114 -0
  108. package/playground/app/favicon.ico +0 -0
  109. package/playground/app/globals.css +17 -0
  110. package/playground/app/layout.tsx +19 -0
  111. package/playground/app/page.tsx +1338 -0
  112. package/playground/eslint.config.mjs +18 -0
  113. package/playground/next.config.ts +34 -0
  114. package/playground/package-lock.json +6723 -0
  115. package/playground/package.json +27 -0
  116. package/playground/postcss.config.mjs +7 -0
  117. package/playground/tsconfig.json +34 -0
  118. package/src/core/base.ts +66 -0
  119. package/src/core/file.ts +141 -0
  120. package/src/core/modelCache.ts +189 -0
  121. package/src/core/posePostprocessing.ts +91 -0
  122. package/src/core/postprocessing.ts +93 -0
  123. package/src/core/preprocessing.ts +127 -0
  124. package/src/index.ts +69 -0
  125. package/src/models/rtmpose.ts +265 -0
  126. package/src/models/rtmpose3d.ts +289 -0
  127. package/src/models/yolo12.ts +220 -0
  128. package/src/models/yolox.ts +214 -0
  129. package/src/solution/animalDetector.ts +955 -0
  130. package/src/solution/body.ts +89 -0
  131. package/src/solution/bodyWithFeet.ts +89 -0
  132. package/src/solution/customDetector.ts +474 -0
  133. package/src/solution/hand.ts +52 -0
  134. package/src/solution/index.ts +10 -0
  135. package/src/solution/objectDetector.ts +816 -0
  136. package/src/solution/pose3dDetector.ts +890 -0
  137. package/src/solution/poseDetector.ts +892 -0
  138. package/src/solution/poseTracker.ts +172 -0
  139. package/src/solution/wholebody.ts +130 -0
  140. package/src/solution/wholebody3d.ts +125 -0
  141. package/src/types/index.ts +62 -0
  142. package/src/visualization/draw.ts +543 -0
  143. package/src/visualization/skeleton/coco133.ts +131 -0
  144. package/src/visualization/skeleton/coco17.ts +49 -0
  145. package/src/visualization/skeleton/halpe26.ts +71 -0
  146. package/src/visualization/skeleton/hand21.ts +52 -0
  147. package/src/visualization/skeleton/index.ts +10 -0
  148. package/src/visualization/skeleton/openpose134.ts +125 -0
  149. package/src/visualization/skeleton/openpose18.ts +48 -0
  150. 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
+ }