UNPKG

@nodify_at/hailo.js

Version:

High-performance Node.js bindings for Hailo AI acceleration processors (NPU). Run neural network inference with hardware acceleration on Hailo-8 devices.

62 lines (61 loc) 2.97 kB
/** * Detection utilities for object detection models * Provides high-level functions for parsing and filtering detections */ import type { Detection, NMSOptions, BoundingBox } from './types.js'; /** * Parse NMS output from YOLO-style models * * @example * ```typescript * const detections = parseNMS(outputBuffer, 80, { * threshold: 0.5, * frameWidth: 1920, * frameHeight: 1080 * }); * ``` */ export declare function parseNMS(buffer: Uint8Array | Float32Array, numClasses: number, options?: NMSOptions): Detection[]; /** * Get human-readable class name from ID */ export declare function getClassName(classId: number): string; /** * Filter detections by class names * * @example * ```typescript * const people = filterByClasses(detections, ['person']); * const vehicles = filterByClasses(detections, ['car', 'truck', 'bus']); * ``` */ export declare function filterByClasses(detections: Detection[], classNames: string[]): Detection[]; /** * Filter detections by confidence threshold */ export declare function filterByConfidence(detections: Detection[], threshold: number): Detection[]; /** * Filter detections by area (in pixels) */ export declare function filterByArea(detections: Detection[], minArea: number, maxArea?: number): Detection[]; /** * Convert detection to normalized bounding box (0-1 range) */ export declare function toNormalizedBox(detection: Detection, frameWidth: number, frameHeight: number): BoundingBox; /** * Calculate IoU (Intersection over Union) between two detections */ export declare function calculateIoU(det1: Detection, det2: Detection): number; /** * Group detections by class */ export declare function groupByClass(detections: Detection[]): Map<string, Detection[]>; /** * Find detections within a specific region */ export declare function findInRegion(detections: Detection[], region: BoundingBox, frameWidth: number, frameHeight: number, overlap?: number): Detection[]; /** * Common COCO class names for reference */ export declare const COCO_CLASSES: readonly ["person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch", "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"]; export type COCOClassName = (typeof COCO_CLASSES)[number];