Inline constants for FaceLandmarksConnections
PiperOrigin-RevId: 530384171
This commit is contained in:
parent
e3c2f31ddf
commit
ae8bedd352
|
@ -33,10 +33,10 @@ import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner
|
|||
|
||||
import {FaceLandmarkerOptions} from './face_landmarker_options';
|
||||
import {FaceLandmarkerResult} from './face_landmarker_result';
|
||||
import {FACE_LANDMARKS_CONTOURS, FACE_LANDMARKS_FACE_OVAL, FACE_LANDMARKS_LEFT_EYE, FACE_LANDMARKS_LEFT_EYEBROW, FACE_LANDMARKS_LEFT_IRIS, FACE_LANDMARKS_LIPS, FACE_LANDMARKS_RIGHT_EYE, FACE_LANDMARKS_RIGHT_EYEBROW, FACE_LANDMARKS_RIGHT_IRIS, FACE_LANDMARKS_TESSELATION} from './face_landmarks_connections';
|
||||
|
||||
export * from './face_landmarker_options';
|
||||
export * from './face_landmarker_result';
|
||||
export * from './face_landmarks_connections';
|
||||
export {ImageSource};
|
||||
|
||||
// The OSS JS API does not support the builder pattern.
|
||||
|
@ -112,6 +112,43 @@ export class FaceLandmarker extends VisionTaskRunner {
|
|||
FaceLandmarker, wasmFileset, {baseOptions: {modelAssetPath}});
|
||||
}
|
||||
|
||||
/** Landmark connections to draw the connection between a face's lips. */
|
||||
static FACE_LANDMARKS_LIPS = FACE_LANDMARKS_LIPS;
|
||||
|
||||
/** Landmark connections to draw the connection between a face's left eye. */
|
||||
static FACE_LANDMARKS_LEFT_EYE = FACE_LANDMARKS_LEFT_EYE;
|
||||
|
||||
/**
|
||||
* Landmark connections to draw the connection between a face's left eyebrow.
|
||||
*/
|
||||
static FACE_LANDMARKS_LEFT_EYEBROW = FACE_LANDMARKS_LEFT_EYEBROW;
|
||||
|
||||
/** Landmark connections to draw the connection between a face's left iris. */
|
||||
static FACE_LANDMARKS_LEFT_IRIS = FACE_LANDMARKS_LEFT_IRIS;
|
||||
|
||||
/** Landmark connections to draw the connection between a face's right eye. */
|
||||
static FACE_LANDMARKS_RIGHT_EYE = FACE_LANDMARKS_RIGHT_EYE;
|
||||
|
||||
/**
|
||||
* Landmark connections to draw the connection between a face's right
|
||||
* eyebrow.
|
||||
*/
|
||||
static FACE_LANDMARKS_RIGHT_EYEBROW = FACE_LANDMARKS_RIGHT_EYEBROW;
|
||||
|
||||
/**
|
||||
* Landmark connections to draw the connection between a face's right iris.
|
||||
*/
|
||||
static FACE_LANDMARKS_RIGHT_IRIS = FACE_LANDMARKS_RIGHT_IRIS;
|
||||
|
||||
/** Landmark connections to draw the face's oval. */
|
||||
static FACE_LANDMARKS_FACE_OVAL = FACE_LANDMARKS_FACE_OVAL;
|
||||
|
||||
/** Landmark connections to draw the face's contour. */
|
||||
static FACE_LANDMARKS_CONTOURS = FACE_LANDMARKS_CONTOURS;
|
||||
|
||||
/** Landmark connections to draw the face's tesselation. */
|
||||
static FACE_LANDMARKS_TESSELATION = FACE_LANDMARKS_TESSELATION;
|
||||
|
||||
/** @hideconstructor */
|
||||
constructor(
|
||||
wasmModule: WasmModule,
|
||||
|
|
|
@ -16,14 +16,8 @@
|
|||
|
||||
import {Connection} from '../../../../tasks/web/vision/core/types';
|
||||
|
||||
// tslint:disable:class-as-namespace Using for easier import by 3P users
|
||||
|
||||
/**
|
||||
* A class containing the pairs of landmark indices to be rendered with
|
||||
* connections.
|
||||
*/
|
||||
export class FaceLandmarksConnections {
|
||||
static FACE_LANDMARKS_LIPS: Connection[] = [
|
||||
/** Landmarks for lips */
|
||||
export const FACE_LANDMARKS_LIPS: Connection[] = [
|
||||
{start: 61, end: 146}, {start: 146, end: 91}, {start: 91, end: 181},
|
||||
{start: 181, end: 84}, {start: 84, end: 17}, {start: 17, end: 314},
|
||||
{start: 314, end: 405}, {start: 405, end: 321}, {start: 321, end: 375},
|
||||
|
@ -38,49 +32,56 @@ export class FaceLandmarksConnections {
|
|||
{start: 81, end: 82}, {start: 82, end: 13}, {start: 13, end: 312},
|
||||
{start: 312, end: 311}, {start: 311, end: 310}, {start: 310, end: 415},
|
||||
{start: 415, end: 308}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_LEFT_EYE: Connection[] = [
|
||||
/** Landmarks for left eye */
|
||||
export const FACE_LANDMARKS_LEFT_EYE: Connection[] = [
|
||||
{start: 263, end: 249}, {start: 249, end: 390}, {start: 390, end: 373},
|
||||
{start: 373, end: 374}, {start: 374, end: 380}, {start: 380, end: 381},
|
||||
{start: 381, end: 382}, {start: 382, end: 362}, {start: 263, end: 466},
|
||||
{start: 466, end: 388}, {start: 388, end: 387}, {start: 387, end: 386},
|
||||
{start: 386, end: 385}, {start: 385, end: 384}, {start: 384, end: 398},
|
||||
{start: 398, end: 362}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_LEFT_EYEBROW: Connection[] = [
|
||||
/** Landmarks for left eyebrow */
|
||||
export const FACE_LANDMARKS_LEFT_EYEBROW: Connection[] = [
|
||||
{start: 276, end: 283}, {start: 283, end: 282}, {start: 282, end: 295},
|
||||
{start: 295, end: 285}, {start: 300, end: 293}, {start: 293, end: 334},
|
||||
{start: 334, end: 296}, {start: 296, end: 336}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_LEFT_IRIS: Connection[] = [
|
||||
/** Landmarks for left iris */
|
||||
export const FACE_LANDMARKS_LEFT_IRIS: Connection[] = [
|
||||
{start: 474, end: 475}, {start: 475, end: 476}, {start: 476, end: 477},
|
||||
{start: 477, end: 474}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_RIGHT_EYE: Connection[] = [
|
||||
/** Landmarks for right eye */
|
||||
export const FACE_LANDMARKS_RIGHT_EYE: Connection[] = [
|
||||
{start: 33, end: 7}, {start: 7, end: 163}, {start: 163, end: 144},
|
||||
{start: 144, end: 145}, {start: 145, end: 153}, {start: 153, end: 154},
|
||||
{start: 154, end: 155}, {start: 155, end: 133}, {start: 33, end: 246},
|
||||
{start: 246, end: 161}, {start: 161, end: 160}, {start: 160, end: 159},
|
||||
{start: 159, end: 158}, {start: 158, end: 157}, {start: 157, end: 173},
|
||||
{start: 173, end: 133}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_RIGHT_EYEBROW: Connection[] = [
|
||||
/** Landmarks for right eeyebrow */
|
||||
export const FACE_LANDMARKS_RIGHT_EYEBROW: Connection[] = [
|
||||
{start: 46, end: 53}, {start: 53, end: 52}, {start: 52, end: 65},
|
||||
{start: 65, end: 55}, {start: 70, end: 63}, {start: 63, end: 105},
|
||||
{start: 105, end: 66}, {start: 66, end: 107}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_RIGHT_IRIS: Connection[] = [
|
||||
/** Landmarks for right iris */
|
||||
export const FACE_LANDMARKS_RIGHT_IRIS: Connection[] = [
|
||||
{start: 469, end: 470}, {start: 470, end: 471}, {start: 471, end: 472},
|
||||
{start: 472, end: 469}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_FACE_OVAL: Connection[] = [
|
||||
/** Landmarks for face oval */
|
||||
export const FACE_LANDMARKS_FACE_OVAL: Connection[] = [
|
||||
{start: 10, end: 338}, {start: 338, end: 297}, {start: 297, end: 332},
|
||||
{start: 332, end: 284}, {start: 284, end: 251}, {start: 251, end: 389},
|
||||
{start: 389, end: 356}, {start: 356, end: 454}, {start: 454, end: 323},
|
||||
|
@ -93,18 +94,17 @@ export class FaceLandmarksConnections {
|
|||
{start: 93, end: 234}, {start: 234, end: 127}, {start: 127, end: 162},
|
||||
{start: 162, end: 21}, {start: 21, end: 54}, {start: 54, end: 103},
|
||||
{start: 103, end: 67}, {start: 67, end: 109}, {start: 109, end: 10}
|
||||
];
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_CONTOURS: Connection[] = [
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_LIPS,
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYE,
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYEBROW,
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYE,
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYEBROW,
|
||||
...FaceLandmarksConnections.FACE_LANDMARKS_FACE_OVAL
|
||||
];
|
||||
/** Landmarks for contours */
|
||||
export const FACE_LANDMARKS_CONTOURS: Connection[] = [
|
||||
...FACE_LANDMARKS_LIPS, ...FACE_LANDMARKS_LEFT_EYE,
|
||||
...FACE_LANDMARKS_LEFT_EYEBROW, ...FACE_LANDMARKS_RIGHT_EYE,
|
||||
...FACE_LANDMARKS_RIGHT_EYEBROW, ...FACE_LANDMARKS_FACE_OVAL
|
||||
];
|
||||
|
||||
static FACE_LANDMARKS_TESSELATION: Connection[] = [
|
||||
/** Landmarks for face tesselation */
|
||||
export const FACE_LANDMARKS_TESSELATION: Connection[] = [
|
||||
{start: 127, end: 34}, {start: 34, end: 139}, {start: 139, end: 127},
|
||||
{start: 11, end: 0}, {start: 0, end: 37}, {start: 37, end: 11},
|
||||
{start: 232, end: 231}, {start: 231, end: 120}, {start: 120, end: 232},
|
||||
|
@ -957,5 +957,4 @@ export class FaceLandmarksConnections {
|
|||
{start: 265, end: 372}, {start: 372, end: 353}, {start: 353, end: 265},
|
||||
{start: 390, end: 339}, {start: 339, end: 249}, {start: 249, end: 390},
|
||||
{start: 339, end: 448}, {start: 448, end: 255}, {start: 255, end: 339}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
|
|
@ -19,7 +19,7 @@ import {DrawingUtils as DrawingUtilsImpl} from '../../../tasks/web/vision/core/d
|
|||
import {MPImage as MPImageImpl} from '../../../tasks/web/vision/core/image';
|
||||
import {MPMask as MPMaskImpl} from '../../../tasks/web/vision/core/mask';
|
||||
import {FaceDetector as FaceDetectorImpl} from '../../../tasks/web/vision/face_detector/face_detector';
|
||||
import {FaceLandmarker as FaceLandmarkerImpl, FaceLandmarksConnections as FaceLandmarksConnectionsImpl} from '../../../tasks/web/vision/face_landmarker/face_landmarker';
|
||||
import {FaceLandmarker as FaceLandmarkerImpl} from '../../../tasks/web/vision/face_landmarker/face_landmarker';
|
||||
import {FaceStylizer as FaceStylizerImpl} from '../../../tasks/web/vision/face_stylizer/face_stylizer';
|
||||
import {GestureRecognizer as GestureRecognizerImpl} from '../../../tasks/web/vision/gesture_recognizer/gesture_recognizer';
|
||||
import {HandLandmarker as HandLandmarkerImpl} from '../../../tasks/web/vision/hand_landmarker/hand_landmarker';
|
||||
|
@ -38,7 +38,6 @@ const MPImage = MPImageImpl;
|
|||
const MPMask = MPMaskImpl;
|
||||
const FaceDetector = FaceDetectorImpl;
|
||||
const FaceLandmarker = FaceLandmarkerImpl;
|
||||
const FaceLandmarksConnections = FaceLandmarksConnectionsImpl;
|
||||
const FaceStylizer = FaceStylizerImpl;
|
||||
const GestureRecognizer = GestureRecognizerImpl;
|
||||
const HandLandmarker = HandLandmarkerImpl;
|
||||
|
@ -56,7 +55,6 @@ export {
|
|||
MPMask,
|
||||
FaceDetector,
|
||||
FaceLandmarker,
|
||||
FaceLandmarksConnections,
|
||||
FaceStylizer,
|
||||
GestureRecognizer,
|
||||
HandLandmarker,
|
||||
|
|
Loading…
Reference in New Issue
Block a user