detection-lib
Advanced tools
Comparing version
{ | ||
"name": "detection-lib", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "src/DetectorFactory.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -45,2 +45,29 @@ | ||
} | ||
``` | ||
## API | ||
#### createDetector(options) | ||
- **options.type: 'face' | 'qr' | string** — The type of detector to create. | ||
- Returns a detector instance with an async detect(input) method | ||
### Detector Interface | ||
All detectors implement: | ||
``` | ||
async detect(input: HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): Promise<DetectionResult> | ||
``` | ||
### DetectionResult | ||
- **type**: string — The detector type ('face', 'qr', etc.) | ||
- **boxes**: Array of { x, y, w, h, score? } (for face, etc.) | ||
- **data**: Any extra data (for QR, etc.) | ||
### Extending | ||
To add a new detector: | ||
``` | ||
1. Create a new file in src/detectors/ (e.g., myDetector.js). | ||
2. Implement a class with a detect() method. | ||
3. Register it in the factory in src/DetectorFactory.js. | ||
``` |
4771
19.22%72
60%