@mediapipe/tasks-vision 0.1.0-alpha-8 → 0.1.0-alpha-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediapipe/tasks-vision",
3
- "version": "0.1.0-alpha-8",
3
+ "version": "0.1.0-alpha-10",
4
4
  "description": "MediaPipe Vision Tasks",
5
5
  "main": "vision_bundle.js",
6
6
  "author": "mediapipe@google.com",
package/vision.d.ts CHANGED
@@ -56,6 +56,12 @@ export declare interface BoundingBox {
56
56
  height: number;
57
57
  }
58
58
 
59
+ /**
60
+ * A user-defined callback to take input data and map it to a custom output
61
+ * value.
62
+ */
63
+ export declare type Callback<I, O> = (input: I) => O;
64
+
59
65
  /**
60
66
  * Copyright 2022 The MediaPipe Authors. All Rights Reserved.
61
67
  *
@@ -153,6 +159,12 @@ declare interface ClassifierOptions {
153
159
  categoryDenylist?: string[] | undefined;
154
160
  }
155
161
 
162
+ /** A connection between two landmarks. */
163
+ declare interface Connection {
164
+ start: number;
165
+ end: number;
166
+ }
167
+
156
168
  /** Represents one detection by a detection task. */
157
169
  export declare interface Detection {
158
170
  /** A list of `Category` objects. */
@@ -177,6 +189,77 @@ declare interface DetectionResult {
177
189
  export { DetectionResult as FaceDetectorResult }
178
190
  export { DetectionResult as ObjectDetectorResult }
179
191
 
192
+ /**
193
+ * Options for customizing the drawing routines
194
+ */
195
+ export declare interface DrawingOptions {
196
+ /** The color that is used to draw the shape. Defaults to white. */
197
+ color?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
198
+ /**
199
+ * The color that is used to fill the shape. Defaults to `.color` (or black
200
+ * if color is not set).
201
+ */
202
+ fillColor?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
203
+ /** The width of the line boundary of the shape. Defaults to 4. */
204
+ lineWidth?: number | Callback<LandmarkData, number>;
205
+ /** The radius of location marker. Defaults to 6. */
206
+ radius?: number | Callback<LandmarkData, number>;
207
+ }
208
+
209
+ /** Helper class to visualize the result of a MediaPipe Vision task. */
210
+ export declare class DrawingUtils {
211
+ /**
212
+ * Creates a new DrawingUtils class.
213
+ *
214
+ * @param ctx The canvas to render onto.
215
+ */
216
+ constructor(ctx: CanvasRenderingContext2D);
217
+ /**
218
+ * Restricts a number between two endpoints (order doesn't matter).
219
+ *
220
+ * @param x The number to clamp.
221
+ * @param x0 The first boundary.
222
+ * @param x1 The second boundary.
223
+ * @return The clamped value.
224
+ */
225
+ static clamp(x: number, x0: number, x1: number): number;
226
+ /**
227
+ * Linearly interpolates a value between two points, clamping that value to
228
+ * the endpoints.
229
+ *
230
+ * @param x The number to interpolate.
231
+ * @param x0 The x coordinate of the start value.
232
+ * @param x1 The x coordinate of the end value.
233
+ * @param y0 The y coordinate of the start value.
234
+ * @param y1 The y coordinate of the end value.
235
+ * @return The interpolated value.
236
+ */
237
+ static lerp(x: number, x0: number, x1: number, y0: number, y1: number): number;
238
+ /**
239
+ * Draws circles onto the provided landmarks.
240
+ *
241
+ * @param landmarks The landmarks to draw.
242
+ * @param style The style to visualize the landmarks.
243
+ */
244
+ drawLandmarks(landmarks?: NormalizedLandmark[], style?: DrawingOptions): void;
245
+ /**
246
+ * Draws lines between landmarks (given a connection graph).
247
+ *
248
+ * @param landmarks The landmarks to draw.
249
+ * @param connections The connections array that contains the start and the
250
+ * end indices for the connections to draw.
251
+ * @param style The style to visualize the landmarks.
252
+ */
253
+ drawConnectors(landmarks?: NormalizedLandmark[], connections?: Connection[], style?: DrawingOptions): void;
254
+ /**
255
+ * Draws a bounding box.
256
+ *
257
+ * @param boundingBox The bounding box to draw.
258
+ * @param style The style to visualize the boundin box.
259
+ */
260
+ drawBoundingBox(boundingBox: BoundingBox, style?: DrawingOptions): void;
261
+ }
262
+
180
263
  /**
181
264
  * Copyright 2022 The MediaPipe Authors. All Rights Reserved.
182
265
  *
@@ -449,6 +532,23 @@ export declare interface FaceLandmarkerResult {
449
532
  facialTransformationMatrixes?: Matrix[];
450
533
  }
451
534
 
535
+ /**
536
+ * A class containing the Pairs of landmark indices to be rendered with
537
+ * connections.
538
+ */
539
+ export declare class FaceLandmarksConnections {
540
+ static FACE_LANDMARKS_LIPS: Connection[];
541
+ static FACE_LANDMARKS_LEFT_EYE: Connection[];
542
+ static FACE_LANDMARKS_LEFT_EYEBROW: Connection[];
543
+ static FACE_LANDMARKS_LEFT_IRIS: Connection[];
544
+ static FACE_LANDMARKS_RIGHT_EYE: Connection[];
545
+ static FACE_LANDMARKS_RIGHT_EYEBROW: Connection[];
546
+ static FACE_LANDMARKS_RIGHT_IRIS: Connection[];
547
+ static FACE_LANDMARKS_FACE_OVAL: Connection[];
548
+ static FACE_LANDMARKS_CONTOURS: Connection[];
549
+ static FACE_LANDMARKS_TESSELATION: Connection[];
550
+ }
551
+
452
552
  /** Performs face stylization on images. */
453
553
  export declare class FaceStylizer extends VisionTaskRunner {
454
554
  /**
@@ -1348,6 +1448,13 @@ export declare interface Landmark {
1348
1448
  z: number;
1349
1449
  }
1350
1450
 
1451
+ /** Data that a user can use to specialize drawing options. */
1452
+ export declare interface LandmarkData {
1453
+ index?: number;
1454
+ from?: NormalizedLandmark;
1455
+ to?: NormalizedLandmark;
1456
+ }
1457
+
1351
1458
  /**
1352
1459
  * Copyright 2023 The MediaPipe Authors. All Rights Reserved.
1353
1460
  *