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 {FaceLandmarkerOptions} from './face_landmarker_options';
|
||||||
import {FaceLandmarkerResult} from './face_landmarker_result';
|
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_options';
|
||||||
export * from './face_landmarker_result';
|
export * from './face_landmarker_result';
|
||||||
export * from './face_landmarks_connections';
|
|
||||||
export {ImageSource};
|
export {ImageSource};
|
||||||
|
|
||||||
// The OSS JS API does not support the builder pattern.
|
// The OSS JS API does not support the builder pattern.
|
||||||
|
@ -112,6 +112,43 @@ export class FaceLandmarker extends VisionTaskRunner {
|
||||||
FaceLandmarker, wasmFileset, {baseOptions: {modelAssetPath}});
|
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 */
|
/** @hideconstructor */
|
||||||
constructor(
|
constructor(
|
||||||
wasmModule: WasmModule,
|
wasmModule: WasmModule,
|
||||||
|
|
|
@ -16,14 +16,8 @@
|
||||||
|
|
||||||
import {Connection} from '../../../../tasks/web/vision/core/types';
|
import {Connection} from '../../../../tasks/web/vision/core/types';
|
||||||
|
|
||||||
// tslint:disable:class-as-namespace Using for easier import by 3P users
|
/** Landmarks for lips */
|
||||||
|
export const FACE_LANDMARKS_LIPS: Connection[] = [
|
||||||
/**
|
|
||||||
* A class containing the pairs of landmark indices to be rendered with
|
|
||||||
* connections.
|
|
||||||
*/
|
|
||||||
export class FaceLandmarksConnections {
|
|
||||||
static FACE_LANDMARKS_LIPS: Connection[] = [
|
|
||||||
{start: 61, end: 146}, {start: 146, end: 91}, {start: 91, end: 181},
|
{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: 181, end: 84}, {start: 84, end: 17}, {start: 17, end: 314},
|
||||||
{start: 314, end: 405}, {start: 405, end: 321}, {start: 321, end: 375},
|
{start: 314, end: 405}, {start: 405, end: 321}, {start: 321, end: 375},
|
||||||
|
@ -40,7 +34,8 @@ export class FaceLandmarksConnections {
|
||||||
{start: 415, end: 308}
|
{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: 263, end: 249}, {start: 249, end: 390}, {start: 390, end: 373},
|
||||||
{start: 373, end: 374}, {start: 374, end: 380}, {start: 380, end: 381},
|
{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: 381, end: 382}, {start: 382, end: 362}, {start: 263, end: 466},
|
||||||
|
@ -49,18 +44,21 @@ export class FaceLandmarksConnections {
|
||||||
{start: 398, end: 362}
|
{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: 276, end: 283}, {start: 283, end: 282}, {start: 282, end: 295},
|
||||||
{start: 295, end: 285}, {start: 300, end: 293}, {start: 293, end: 334},
|
{start: 295, end: 285}, {start: 300, end: 293}, {start: 293, end: 334},
|
||||||
{start: 334, end: 296}, {start: 296, end: 336}
|
{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: 474, end: 475}, {start: 475, end: 476}, {start: 476, end: 477},
|
||||||
{start: 477, end: 474}
|
{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: 33, end: 7}, {start: 7, end: 163}, {start: 163, end: 144},
|
||||||
{start: 144, end: 145}, {start: 145, end: 153}, {start: 153, end: 154},
|
{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: 154, end: 155}, {start: 155, end: 133}, {start: 33, end: 246},
|
||||||
|
@ -69,18 +67,21 @@ export class FaceLandmarksConnections {
|
||||||
{start: 173, end: 133}
|
{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: 46, end: 53}, {start: 53, end: 52}, {start: 52, end: 65},
|
||||||
{start: 65, end: 55}, {start: 70, end: 63}, {start: 63, end: 105},
|
{start: 65, end: 55}, {start: 70, end: 63}, {start: 63, end: 105},
|
||||||
{start: 105, end: 66}, {start: 66, end: 107}
|
{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: 469, end: 470}, {start: 470, end: 471}, {start: 471, end: 472},
|
||||||
{start: 472, end: 469}
|
{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: 10, end: 338}, {start: 338, end: 297}, {start: 297, end: 332},
|
||||||
{start: 332, end: 284}, {start: 284, end: 251}, {start: 251, end: 389},
|
{start: 332, end: 284}, {start: 284, end: 251}, {start: 251, end: 389},
|
||||||
{start: 389, end: 356}, {start: 356, end: 454}, {start: 454, end: 323},
|
{start: 389, end: 356}, {start: 356, end: 454}, {start: 454, end: 323},
|
||||||
|
@ -95,16 +96,15 @@ export class FaceLandmarksConnections {
|
||||||
{start: 103, end: 67}, {start: 67, end: 109}, {start: 109, end: 10}
|
{start: 103, end: 67}, {start: 67, end: 109}, {start: 109, end: 10}
|
||||||
];
|
];
|
||||||
|
|
||||||
static FACE_LANDMARKS_CONTOURS: Connection[] = [
|
/** Landmarks for contours */
|
||||||
...FaceLandmarksConnections.FACE_LANDMARKS_LIPS,
|
export const FACE_LANDMARKS_CONTOURS: Connection[] = [
|
||||||
...FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYE,
|
...FACE_LANDMARKS_LIPS, ...FACE_LANDMARKS_LEFT_EYE,
|
||||||
...FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYEBROW,
|
...FACE_LANDMARKS_LEFT_EYEBROW, ...FACE_LANDMARKS_RIGHT_EYE,
|
||||||
...FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYE,
|
...FACE_LANDMARKS_RIGHT_EYEBROW, ...FACE_LANDMARKS_FACE_OVAL
|
||||||
...FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYEBROW,
|
|
||||||
...FaceLandmarksConnections.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: 127, end: 34}, {start: 34, end: 139}, {start: 139, end: 127},
|
||||||
{start: 11, end: 0}, {start: 0, end: 37}, {start: 37, end: 11},
|
{start: 11, end: 0}, {start: 0, end: 37}, {start: 37, end: 11},
|
||||||
{start: 232, end: 231}, {start: 231, end: 120}, {start: 120, end: 232},
|
{start: 232, end: 231}, {start: 231, end: 120}, {start: 120, end: 232},
|
||||||
|
@ -958,4 +958,3 @@ export class FaceLandmarksConnections {
|
||||||
{start: 390, end: 339}, {start: 339, end: 249}, {start: 249, end: 390},
|
{start: 390, end: 339}, {start: 339, end: 249}, {start: 249, end: 390},
|
||||||
{start: 339, end: 448}, {start: 448, end: 255}, {start: 255, end: 339}
|
{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 {MPImage as MPImageImpl} from '../../../tasks/web/vision/core/image';
|
||||||
import {MPMask as MPMaskImpl} from '../../../tasks/web/vision/core/mask';
|
import {MPMask as MPMaskImpl} from '../../../tasks/web/vision/core/mask';
|
||||||
import {FaceDetector as FaceDetectorImpl} from '../../../tasks/web/vision/face_detector/face_detector';
|
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 {FaceStylizer as FaceStylizerImpl} from '../../../tasks/web/vision/face_stylizer/face_stylizer';
|
||||||
import {GestureRecognizer as GestureRecognizerImpl} from '../../../tasks/web/vision/gesture_recognizer/gesture_recognizer';
|
import {GestureRecognizer as GestureRecognizerImpl} from '../../../tasks/web/vision/gesture_recognizer/gesture_recognizer';
|
||||||
import {HandLandmarker as HandLandmarkerImpl} from '../../../tasks/web/vision/hand_landmarker/hand_landmarker';
|
import {HandLandmarker as HandLandmarkerImpl} from '../../../tasks/web/vision/hand_landmarker/hand_landmarker';
|
||||||
|
@ -38,7 +38,6 @@ const MPImage = MPImageImpl;
|
||||||
const MPMask = MPMaskImpl;
|
const MPMask = MPMaskImpl;
|
||||||
const FaceDetector = FaceDetectorImpl;
|
const FaceDetector = FaceDetectorImpl;
|
||||||
const FaceLandmarker = FaceLandmarkerImpl;
|
const FaceLandmarker = FaceLandmarkerImpl;
|
||||||
const FaceLandmarksConnections = FaceLandmarksConnectionsImpl;
|
|
||||||
const FaceStylizer = FaceStylizerImpl;
|
const FaceStylizer = FaceStylizerImpl;
|
||||||
const GestureRecognizer = GestureRecognizerImpl;
|
const GestureRecognizer = GestureRecognizerImpl;
|
||||||
const HandLandmarker = HandLandmarkerImpl;
|
const HandLandmarker = HandLandmarkerImpl;
|
||||||
|
@ -56,7 +55,6 @@ export {
|
||||||
MPMask,
|
MPMask,
|
||||||
FaceDetector,
|
FaceDetector,
|
||||||
FaceLandmarker,
|
FaceLandmarker,
|
||||||
FaceLandmarksConnections,
|
|
||||||
FaceStylizer,
|
FaceStylizer,
|
||||||
GestureRecognizer,
|
GestureRecognizer,
|
||||||
HandLandmarker,
|
HandLandmarker,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user