@mediapipe/tasks-vision 0.10.6 → 0.10.8

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.10.6",
3
+ "version": "0.10.8",
4
4
  "description": "MediaPipe Vision Tasks",
5
5
  "main": "vision_bundle.cjs",
6
6
  "browser": "vision_bundle.mjs",
@@ -9,7 +9,7 @@
9
9
  "import": "./vision_bundle.mjs",
10
10
  "require": "./vision_bundle.cjs",
11
11
  "default": "./vision_bundle.mjs",
12
- "types": "./vision_.d.ts"
12
+ "types": "./vision.d.ts"
13
13
  },
14
14
  "author": "mediapipe@google.com",
15
15
  "license": "Apache-2.0",
package/vision.d.ts CHANGED
@@ -103,6 +103,12 @@ export declare interface Category {
103
103
  displayName: string;
104
104
  }
105
105
 
106
+ /**
107
+ * A category to color mapping that uses either a map or an array to assign
108
+ * category indexes to RGBA colors.
109
+ */
110
+ export declare type CategoryToColorMap = Map<number, RGBAColor> | RGBAColor[];
111
+
106
112
  /** Classification results for a given classifier head. */
107
113
  export declare interface Classifications {
108
114
  /**
@@ -171,6 +177,9 @@ declare interface Connection {
171
177
  end: number;
172
178
  }
173
179
 
180
+ /** A color map with 22 classes. Used in our demos. */
181
+ export declare const DEFAULT_CATEGORY_TO_COLOR_MAP: number[][];
182
+
174
183
  /** Represents one detection by a detection task. */
175
184
  export declare interface Detection {
176
185
  /** A list of `Category` objects. */
@@ -218,9 +227,23 @@ export declare class DrawingUtils {
218
227
  /**
219
228
  * Creates a new DrawingUtils class.
220
229
  *
221
- * @param ctx The canvas to render onto.
230
+ * @param gpuContext The WebGL canvas rendering context to render into. If
231
+ * your Task is using a GPU delegate, the context must be obtained from
232
+ * its canvas (provided via `setOptions({ canvas: .. })`).
233
+ */
234
+ constructor(gpuContext: WebGL2RenderingContext);
235
+ /**
236
+ * Creates a new DrawingUtils class.
237
+ *
238
+ * @param cpuContext The 2D canvas rendering context to render into. If
239
+ * you are rendering GPU data you must also provide `gpuContext` to allow
240
+ * for data conversion.
241
+ * @param gpuContext A WebGL canvas that is used for GPU rendering and for
242
+ * converting GPU to CPU data. If your Task is using a GPU delegate, the
243
+ * context must be obtained from its canvas (provided via
244
+ * `setOptions({ canvas: .. })`).
222
245
  */
223
- constructor(ctx: CanvasRenderingContext2D);
246
+ constructor(cpuContext: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, gpuContext?: WebGL2RenderingContext);
224
247
  /**
225
248
  * Restricts a number between two endpoints (order doesn't matter).
226
249
  *
@@ -247,6 +270,9 @@ export declare class DrawingUtils {
247
270
  /**
248
271
  * Draws circles onto the provided landmarks.
249
272
  *
273
+ * This method can only be used when `DrawingUtils` is initialized with a
274
+ * `CanvasRenderingContext2D`.
275
+ *
250
276
  * @export
251
277
  * @param landmarks The landmarks to draw.
252
278
  * @param style The style to visualize the landmarks.
@@ -255,6 +281,9 @@ export declare class DrawingUtils {
255
281
  /**
256
282
  * Draws lines between landmarks (given a connection graph).
257
283
  *
284
+ * This method can only be used when `DrawingUtils` is initialized with a
285
+ * `CanvasRenderingContext2D`.
286
+ *
258
287
  * @export
259
288
  * @param landmarks The landmarks to draw.
260
289
  * @param connections The connections array that contains the start and the
@@ -265,11 +294,42 @@ export declare class DrawingUtils {
265
294
  /**
266
295
  * Draws a bounding box.
267
296
  *
297
+ * This method can only be used when `DrawingUtils` is initialized with a
298
+ * `CanvasRenderingContext2D`.
299
+ *
268
300
  * @export
269
301
  * @param boundingBox The bounding box to draw.
270
302
  * @param style The style to visualize the boundin box.
271
303
  */
272
304
  drawBoundingBox(boundingBox: BoundingBox, style?: DrawingOptions): void;
305
+ /**
306
+ * Draws a category mask using the provided category-to-color mapping.
307
+ *
308
+ * @export
309
+ * @param mask A category mask that was returned from a segmentation task.
310
+ * @param categoryToColorMap A map that maps category indices to RGBA
311
+ * values. You must specify a map entry for each category.
312
+ * @param background A color or image to use as the background. Defaults to
313
+ * black.
314
+ */
315
+ drawCategoryMask(mask: MPMask, categoryToColorMap: Map<number, RGBAColor>, background?: RGBAColor | ImageSource): void;
316
+ /**
317
+ * Draws a category mask using the provided color array.
318
+ *
319
+ * @export
320
+ * @param mask A category mask that was returned from a segmentation task.
321
+ * @param categoryToColorMap An array that maps indices to RGBA values. The
322
+ * array's indices must correspond to the category indices of the model
323
+ * and an entry must be provided for each category.
324
+ * @param background A color or image to use as the background. Defaults to
325
+ * black.
326
+ */
327
+ drawCategoryMask(mask: MPMask, categoryToColorMap: RGBAColor[], background?: RGBAColor | ImageSource): void;
328
+ /**
329
+ * Frees all WebGL resources held by this class.
330
+ * @export
331
+ */
332
+ close(): void;
273
333
  }
274
334
 
275
335
  /**
@@ -401,6 +461,7 @@ export declare class FaceDetector extends VisionTaskRunner {
401
461
  * synchronously for the response. Only use this method when the
402
462
  * FaceDetector is created with running mode `image`.
403
463
  *
464
+ * @export
404
465
  * @param image An image to process.
405
466
  * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
406
467
  * to process the input image before running inference.
@@ -921,7 +982,7 @@ export declare interface GestureRecognizerOptions extends VisionTaskOptions {
921
982
  export declare interface GestureRecognizerResult {
922
983
  /** Hand landmarks of detected hands. */
923
984
  landmarks: NormalizedLandmark[][];
924
- /** Hand landmarks in world coordniates of detected hands. */
985
+ /** Hand landmarks in world coordinates of detected hands. */
925
986
  worldLandmarks: Landmark[][];
926
987
  /** Handedness of detected hands. */
927
988
  handedness: Category[][];
@@ -2324,6 +2385,17 @@ export declare interface RegionOfInterest {
2324
2385
  scribble?: NormalizedKeypoint[];
2325
2386
  }
2326
2387
 
2388
+ /**
2389
+ * A four channel color with values for red, green, blue and alpha
2390
+ * respectively.
2391
+ */
2392
+ export declare type RGBAColor = [
2393
+ number,
2394
+ number,
2395
+ number,
2396
+ number
2397
+ ] | number[];
2398
+
2327
2399
  /**
2328
2400
  * The two running modes of a vision task.
2329
2401
  * 1) The image mode for processing single image inputs.