Spaces:
Paused
Paused
File size: 2,272 Bytes
e123fec 8378233 e123fec 8378233 e123fec 8378233 e123fec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import * as vision from '@mediapipe/tasks-vision';
/**
* Represents the parameters for image modification.
*/
export interface ImageModificationParams {
eyes: number;
eyebrow: number;
wink: number;
pupil_x: number;
pupil_y: number;
aaa: number;
eee: number;
woo: number;
smile: number;
rotate_pitch: number;
rotate_yaw: number;
rotate_roll: number;
}
export interface Metadata {
center: number[] //center - 2x1
size: number // size - scalar
bbox: number[][] // bbox - 4x2
angle: number //angle - rad, counterclockwise
}
/**
* Represents a message to modify an image.
*/
export interface ModifyImageMessage {
image?: string;
uuid?: string;
params: Partial<ImageModificationParams>;
}
export type OnServerResponseParams = {
image?: Blob
error?: string
loaded?: {
i: string
} & {
c: number[] //center - 2x1
s: number // size - scalar
b: number[][] // bbox - 4x2
a: number // angle - rad, counterclockwise
}
}
/**
* Callback type for handling modified images.
*/
export type OnServerResponse = (params: OnServerResponseParams) => Promise<void>;
/**
* Enum representing the different states of a WebSocket connection.
*/
export enum WebSocketState {
CONNECTING = 0,
OPEN = 1,
CLOSING = 2,
CLOSED = 3
}
export type ActionMode = 'HOVERING' | 'PRIMARY' | 'SECONDARY'
export type LandmarkGroup = 'lips' | 'leftEye' | 'leftEyebrow' | 'rightEye' | 'rightEyebrow' | 'faceOval' | 'background';
export type LandmarkCenter = { x: number; y: number; z: number };
export type ClosestLandmark = { group: LandmarkGroup; distance: number; vector: { x: number; y: number; z: number } };
export type MediaPipeResources = {
faceLandmarker: vision.FaceLandmarker | null;
drawingUtils: vision.DrawingUtils | null;
};
export interface ImageStateValues {
status: string
error: string
imageFile: File | null
isFollowingCursor: boolean
isGazingAtCursor: boolean
originalImage: string
previewImage: string
originalImageUuid: string
minLatency: number
averageLatency: number
maxLatency: number
activeLandmark?: ClosestLandmark
metadata: Metadata
params: Partial<ImageModificationParams>
faceLandmarks: vision.NormalizedLandmark[][]
blendShapes: vision.Classifications[]
}
|