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-11-14 17:22:52 +01:00
|
|
|
import type { AnyCanvas } from './exports';
|
2021-05-22 18:33:19 +02:00
|
|
|
|
2021-10-25 19:09:00 +02:00
|
|
|
/** generic box as [x, y, width, height] */
|
2021-09-27 15:19:43 +02:00
|
|
|
export 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 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 18:33:19 +02:00
|
|
|
id: number
|
2021-10-25 19:09:00 +02:00
|
|
|
/** overall face score */
|
2021-06-01 13:37:17 +02:00
|
|
|
score: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** detection score */
|
2021-06-01 13:37:17 +02:00
|
|
|
boxScore: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** mesh score */
|
2021-06-01 13:37:17 +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 13:37:17 +02:00
|
|
|
age?: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** detected gender */
|
2021-06-01 13:37:17 +02:00
|
|
|
gender?: string,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** gender detection score */
|
2021-06-01 13:37:17 +02:00
|
|
|
genderScore?: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** detected emotions */
|
2021-06-01 13:37:17 +02:00
|
|
|
emotion?: Array<{ score: number, emotion: string }>,
|
2021-11-13 18:23:32 +01:00
|
|
|
/** detected race */
|
|
|
|
race?: Array<{ score: number, race: string }>,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** face descriptor */
|
2021-06-01 13:37:17 +02:00
|
|
|
embedding?: Array<number>,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** face iris distance from camera */
|
2021-06-01 13:37:17 +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-11-09 20:37:50 +01:00
|
|
|
/** face liveness result confidence */
|
|
|
|
live?: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** face rotation details */
|
2021-06-01 13:37:17 +02:00
|
|
|
rotation?: {
|
2021-05-22 18:33:19 +02:00
|
|
|
angle: { roll: number, yaw: number, pitch: number },
|
|
|
|
matrix: [number, number, number, number, number, number, number, number, number],
|
2021-05-31 05:21:48 +02:00
|
|
|
gaze: { bearing: number, strength: number },
|
2021-11-12 21:07:23 +01:00
|
|
|
} | null,
|
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-11-17 21:45:49 +01:00
|
|
|
/** Body Result keypoints */
|
2021-10-25 19:09:00 +02:00
|
|
|
export interface BodyKeypoint {
|
|
|
|
/** body part name */
|
2021-10-04 22:29:15 +02:00
|
|
|
part: string,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** body part position */
|
2021-10-04 22:29:15 +02:00
|
|
|
position: Point,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** body part position normalized to 0..1 */
|
2021-10-04 22:29:15 +02:00
|
|
|
positionRaw: Point,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** body part detection score */
|
2021-10-04 22:29:15 +02:00
|
|
|
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 */
|
2021-10-04 22:29:15 +02:00
|
|
|
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 18:33:19 +02:00
|
|
|
id: number,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** hand overal score */
|
2021-06-01 13:37:17 +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-08-21 02:43:03 +02:00
|
|
|
annotations: Record<
|
|
|
|
'index' | 'middle' | 'pinky' | 'ring' | 'thumb' | 'palm',
|
2021-09-27 15:19:43 +02:00
|
|
|
Array<Point>
|
2021-08-21 02:43:03 +02:00
|
|
|
>,
|
2021-10-25 19:09:00 +02:00
|
|
|
/** detected hand parts annotated with part gestures */
|
2021-08-21 02:43:03 +02:00
|
|
|
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
|
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 type GestureResult =
|
2021-07-29 17:01:50 +02:00
|
|
|
{ 'face': number, gesture: FaceGesture }
|
|
|
|
| { 'iris': number, gesture: IrisGesture }
|
|
|
|
| { 'body': number, gesture: BodyGesture }
|
|
|
|
| { 'hand': number, gesture: HandGesture }
|
2021-05-22 18:33:19 +02:00
|
|
|
|
2021-05-24 17:10:13 +02:00
|
|
|
/** Person getter
|
2021-10-25 19:09:00 +02:00
|
|
|
* - Triggers combining all individual results into a virtual person object
|
2021-05-24 17:10:13 +02:00
|
|
|
*/
|
2021-09-12 05:54:35 +02:00
|
|
|
export interface PersonResult {
|
2021-10-25 19:09:00 +02:00
|
|
|
/** person id */
|
2021-05-24 17:10:13 +02:00
|
|
|
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 */
|
2021-09-12 05:54:35 +02:00
|
|
|
hands: { 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 17:10:13 +02:00
|
|
|
}
|
|
|
|
|
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>,
|
2021-09-19 01:09:02 +02:00
|
|
|
/** {@link ObjectResult}: detection & analysis results */
|
2021-09-12 05:54:35 +02:00
|
|
|
object: Array<ObjectResult>
|
2021-05-24 17:10:13 +02:00
|
|
|
/** global performance object with timing values for each operation */
|
2021-10-23 15:38:52 +02:00
|
|
|
performance: Record<string, number>,
|
2021-05-24 17:10:13 +02:00
|
|
|
/** optional processed canvas that can be used to draw input on screen */
|
2021-11-14 17:22:52 +01:00
|
|
|
canvas?: AnyCanvas | null,
|
2021-05-24 17:10:13 +02:00
|
|
|
/** 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-11-17 21:45:49 +01:00
|
|
|
/** Last known error message */
|
2021-11-14 17:22:52 +01:00
|
|
|
error: string | null;
|
2021-03-17 23:23:19 +01:00
|
|
|
}
|