human/types/src/result.d.ts

198 lines
6.1 KiB
TypeScript
Raw Normal View History

2021-05-25 14:58:20 +02:00
/**
2021-05-31 00:45:39 +02:00
* Type definitions for Human result object
2021-05-25 14:58:20 +02:00
*/
2021-09-13 19:28:35 +02:00
import type { Tensor } from './tfjs/types';
import type { FaceGesture, BodyGesture, HandGesture, IrisGesture } from './gesture/gesture';
2021-10-25 19:09:00 +02:00
/** generic box as [x, y, width, height] */
2021-09-27 15:19:43 +02:00
export declare type Box = [number, number, number, number];
2021-10-25 19:09:00 +02:00
/** generic point as [x, y, z?] */
2021-09-27 15:19:43 +02:00
export declare type Point = [number, number, number?];
2021-05-22 18:33:19 +02:00
/** Face results
2021-10-25 19:09:00 +02:00
* - Combined results of face detector, face mesh, age, gender, emotion, embedding, iris models
* - Some values may be null if specific model is not enabled
2021-05-22 18:33:19 +02:00
*/
2021-09-12 05:54:35 +02:00
export interface FaceResult {
2021-10-25 19:09:00 +02:00
/** face id */
2021-05-22 19:17:07 +02:00
id: number;
2021-10-25 19:09:00 +02:00
/** overall face score */
2021-06-01 14:59:09 +02:00
score: number;
2021-10-25 19:09:00 +02:00
/** detection score */
2021-06-01 14:59:09 +02:00
boxScore: number;
2021-10-25 19:09:00 +02:00
/** mesh score */
2021-06-01 14:59:09 +02:00
faceScore: number;
2021-10-25 19:09:00 +02:00
/** detected face box */
2021-09-27 15:19:43 +02:00
box: Box;
2021-10-25 19:09:00 +02:00
/** detected face box normalized to 0..1 */
2021-09-27 15:19:43 +02:00
boxRaw: Box;
2021-10-25 19:09:00 +02:00
/** detected face mesh */
2021-09-27 15:19:43 +02:00
mesh: Array<Point>;
2021-10-25 19:09:00 +02:00
/** detected face mesh normalized to 0..1 */
2021-09-27 15:19:43 +02:00
meshRaw: Array<Point>;
2021-10-25 19:09:00 +02:00
/** mesh keypoints combined into annotated results */
2021-09-27 15:19:43 +02:00
annotations: Record<string, Point[]>;
2021-10-25 19:09:00 +02:00
/** detected age */
2021-06-01 14:59:09 +02:00
age?: number;
2021-10-25 19:09:00 +02:00
/** detected gender */
2021-06-01 14:59:09 +02:00
gender?: string;
2021-10-25 19:09:00 +02:00
/** gender detection score */
2021-06-01 14:59:09 +02:00
genderScore?: number;
2021-10-25 19:09:00 +02:00
/** detected emotions */
2021-06-01 14:59:09 +02:00
emotion?: Array<{
2021-05-22 18:33:19 +02:00
score: number;
emotion: string;
2021-03-17 23:57:00 +01:00
}>;
2021-10-25 19:09:00 +02:00
/** face descriptor */
2021-06-01 14:59:09 +02:00
embedding?: Array<number>;
2021-10-25 19:09:00 +02:00
/** face iris distance from camera */
2021-06-01 14:59:09 +02:00
iris?: number;
2021-10-25 19:09:00 +02:00
/** face anti-spoofing result confidence */
2021-10-13 16:56:56 +02:00
real?: number;
2021-10-25 19:09:00 +02:00
/** face rotation details */
2021-06-01 14:59:09 +02:00
rotation?: {
2021-05-22 18:33:19 +02:00
angle: {
roll: number;
yaw: number;
pitch: number;
};
2021-05-22 19:17:07 +02:00
matrix: [number, number, number, number, number, number, number, number, number];
2021-05-28 21:53:51 +02:00
gaze: {
bearing: number;
2021-05-28 21:53:51 +02:00
strength: number;
};
2021-05-22 18:33:19 +02:00
};
2021-10-25 19:09:00 +02:00
/** detected face as tensor that can be used in further pipelines */
2021-08-12 00:59:02 +02:00
tensor?: Tensor;
2021-05-22 18:33:19 +02:00
}
2021-10-25 19:09:00 +02:00
export interface BodyKeypoint {
/** body part name */
part: string;
2021-10-25 19:09:00 +02:00
/** body part position */
position: Point;
2021-10-25 19:09:00 +02:00
/** body part position normalized to 0..1 */
positionRaw: Point;
2021-10-25 19:09:00 +02:00
/** body part detection score */
score: number;
2021-10-25 19:09:00 +02:00
}
/** Body results */
2021-09-12 05:54:35 +02:00
export interface BodyResult {
2021-10-25 19:09:00 +02:00
/** body id */
2021-05-22 18:33:19 +02:00
id: number;
2021-10-25 19:09:00 +02:00
/** body detection score */
2021-05-22 18:33:19 +02:00
score: number;
2021-10-25 19:09:00 +02:00
/** detected body box */
2021-09-27 15:19:43 +02:00
box: Box;
2021-10-25 19:09:00 +02:00
/** detected body box normalized to 0..1 */
2021-09-27 15:19:43 +02:00
boxRaw: Box;
2021-10-25 19:09:00 +02:00
/** detected body keypoints */
keypoints: Array<BodyKeypoint>;
2021-10-25 19:09:00 +02:00
/** detected body keypoints combined into annotated parts */
annotations: Record<string, Array<Point[]>>;
2021-05-22 18:33:19 +02:00
}
2021-10-25 19:09:00 +02:00
/** Hand results */
2021-09-12 05:54:35 +02:00
export interface HandResult {
2021-10-25 19:09:00 +02:00
/** hand id */
2021-05-22 19:17:07 +02:00
id: number;
2021-10-25 19:09:00 +02:00
/** hand overal score */
2021-06-01 14:59:09 +02:00
score: number;
2021-10-25 19:09:00 +02:00
/** hand detection score */
2021-09-21 22:48:16 +02:00
boxScore: number;
2021-10-25 19:09:00 +02:00
/** hand skelton score */
2021-09-21 22:48:16 +02:00
fingerScore: number;
2021-10-25 19:09:00 +02:00
/** detected hand box */
2021-09-27 15:19:43 +02:00
box: Box;
2021-10-25 19:09:00 +02:00
/** detected hand box normalized to 0..1 */
2021-09-27 15:19:43 +02:00
boxRaw: Box;
2021-10-25 19:09:00 +02:00
/** detected hand keypoints */
2021-09-27 15:19:43 +02:00
keypoints: Array<Point>;
2021-10-25 19:09:00 +02:00
/** detected hand class */
2021-09-21 22:48:16 +02:00
label: string;
2021-10-25 19:09:00 +02:00
/** detected hand keypoints combined into annotated parts */
2021-09-27 15:19:43 +02:00
annotations: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm', Array<Point>>;
2021-10-25 19:09:00 +02:00
/** detected hand parts annotated with part gestures */
landmarks: Record<'index' | 'middle' | 'pinky' | 'ring' | 'thumb', {
curl: 'none' | 'half' | 'full';
direction: 'verticalUp' | 'verticalDown' | 'horizontalLeft' | 'horizontalRight' | 'diagonalUpRight' | 'diagonalUpLeft' | 'diagonalDownRight' | 'diagonalDownLeft';
}>;
2021-05-22 18:33:19 +02:00
}
2021-10-25 19:09:00 +02:00
/** Object results */
2021-09-12 05:54:35 +02:00
export interface ObjectResult {
2021-10-25 19:09:00 +02:00
/** object id */
2021-05-24 13:16:38 +02:00
id: number;
2021-10-25 19:09:00 +02:00
/** object detection score */
2021-05-22 18:33:19 +02:00
score: number;
2021-10-25 19:09:00 +02:00
/** detected object class id */
2021-05-22 18:33:19 +02:00
class: number;
2021-10-25 19:09:00 +02:00
/** detected object class name */
2021-05-22 18:33:19 +02:00
label: string;
2021-10-25 19:09:00 +02:00
/** detected object box */
2021-09-27 15:19:43 +02:00
box: Box;
2021-10-25 19:09:00 +02:00
/** detected object box normalized to 0..1 */
2021-09-27 15:19:43 +02:00
boxRaw: Box;
2021-05-22 18:33:19 +02:00
}
2021-10-25 19:09:00 +02:00
/** Gesture combined results
* @typedef Gesture Type
2021-05-22 18:33:19 +02:00
* Each result has:
2021-10-25 19:09:00 +02:00
* - part: part name and number where gesture was detected: `face`, `iris`, `body`, `hand`
2021-05-22 18:33:19 +02:00
* - gesture: gesture detected
*/
2021-09-12 05:54:35 +02:00
export declare type GestureResult = {
2021-05-22 18:33:19 +02:00
'face': number;
2021-07-29 17:01:50 +02:00
gesture: FaceGesture;
2021-05-22 18:33:19 +02:00
} | {
'iris': number;
2021-07-29 17:01:50 +02:00
gesture: IrisGesture;
2021-05-22 18:33:19 +02:00
} | {
'body': number;
2021-07-29 17:01:50 +02:00
gesture: BodyGesture;
2021-05-22 18:33:19 +02:00
} | {
'hand': number;
2021-07-29 17:01:50 +02:00
gesture: HandGesture;
2021-05-22 18:33:19 +02:00
};
/** Person getter
2021-10-25 19:09:00 +02:00
* - Triggers combining all individual results into a virtual person object
*/
2021-09-12 05:54:35 +02:00
export interface PersonResult {
2021-10-25 19:09:00 +02:00
/** person id */
id: number;
2021-10-25 19:09:00 +02:00
/** face result that belongs to this person */
2021-09-12 05:54:35 +02:00
face: FaceResult;
2021-10-25 19:09:00 +02:00
/** body result that belongs to this person */
2021-09-12 05:54:35 +02:00
body: BodyResult | null;
2021-10-25 19:09:00 +02:00
/** left and right hand results that belong to this person */
hands: {
2021-09-12 05:54:35 +02:00
left: HandResult | null;
right: HandResult | null;
};
2021-10-25 19:09:00 +02:00
/** detected gestures specific to this person */
2021-09-12 05:54:35 +02:00
gestures: Array<GestureResult>;
2021-10-25 19:09:00 +02:00
/** box that defines the person */
2021-09-27 15:19:43 +02:00
box: Box;
2021-10-25 19:09:00 +02:00
/** box that defines the person normalized to 0..1 */
2021-09-27 15:19:43 +02:00
boxRaw?: Box;
}
2021-05-24 13:16:38 +02:00
/**
* Result interface definition for **Human** library
*
* Contains all possible detection results
*/
2021-05-22 18:33:19 +02:00
export interface Result {
2021-09-12 05:54:35 +02:00
/** {@link FaceResult}: detection & analysis results */
face: Array<FaceResult>;
/** {@link BodyResult}: detection & analysis results */
body: Array<BodyResult>;
/** {@link HandResult}: detection & analysis results */
hand: Array<HandResult>;
/** {@link GestureResult}: detection & analysis results */
gesture: Array<GestureResult>;
/** {@link ObjectResult}: detection & analysis results */
2021-09-12 05:54:35 +02:00
object: Array<ObjectResult>;
/** global performance object with timing values for each operation */
2021-10-23 15:38:52 +02:00
performance: Record<string, number>;
/** optional processed canvas that can be used to draw input on screen */
2021-09-13 19:28:35 +02:00
canvas?: OffscreenCanvas | HTMLCanvasElement | null | undefined;
/** timestamp of detection representing the milliseconds elapsed since the UNIX epoch */
readonly timestamp: number;
/** getter property that returns unified persons object */
2021-09-12 05:54:35 +02:00
persons: Array<PersonResult>;
2021-03-17 23:57:00 +01:00
}