@mediapipe/tasks-vision 0.1.0-alpha-5 → 0.1.0-alpha-7

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/README.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  This package contains the vision tasks for MediaPipe.
4
4
 
5
+ ## Face Landmark Detection
6
+
7
+ The MediaPipe Face Landmarker task lets you detect the landmarks of faces in
8
+ an image. You can use this Task to localize key points of a face and render
9
+ visual effects over the faces.
10
+
11
+ ```
12
+ const vision = await FilesetResolver.forVisionTasks(
13
+ "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
14
+ );
15
+ const faceLandmarker = await FaceLandmarker.createFromModelPath(vision,
16
+ "model.task"
17
+ );
18
+ const image = document.getElementById("image") as HTMLImageElement;
19
+ const landmarks = faceLandmarker.detect(image);
20
+ ```
21
+
5
22
  ## Face Stylizer
6
23
 
7
24
  The MediaPipe Face Stylizer lets you perform face stylization on images.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediapipe/tasks-vision",
3
- "version": "0.1.0-alpha-5",
3
+ "version": "0.1.0-alpha-7",
4
4
  "description": "MediaPipe Vision Tasks",
5
5
  "main": "vision_bundle.js",
6
6
  "author": "mediapipe@google.com",
package/vision.d.ts CHANGED
@@ -224,6 +224,122 @@ export declare interface Embedding {
224
224
  headName: string;
225
225
  }
226
226
 
227
+ /**
228
+ * Performs face landmarks detection on images.
229
+ *
230
+ * This API expects a pre-trained face landmarker model asset bundle.
231
+ */
232
+ export declare class FaceLandmarker extends VisionTaskRunner {
233
+ /**
234
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` from the
235
+ * provided options.
236
+ * @param wasmFileset A configuration object that provides the location of the
237
+ * Wasm binary and its loader.
238
+ * @param faceLandmarkerOptions The options for the FaceLandmarker.
239
+ * Note that either a path to the model asset or a model buffer needs to
240
+ * be provided (via `baseOptions`).
241
+ */
242
+ static createFromOptions(wasmFileset: WasmFileset, faceLandmarkerOptions: FaceLandmarkerOptions): Promise<FaceLandmarker>;
243
+ /**
244
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
245
+ * the provided model asset buffer.
246
+ * @param wasmFileset A configuration object that provides the location of the
247
+ * Wasm binary and its loader.
248
+ * @param modelAssetBuffer A binary representation of the model.
249
+ */
250
+ static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceLandmarker>;
251
+ /**
252
+ * Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
253
+ * the path to the model asset.
254
+ * @param wasmFileset A configuration object that provides the location of the
255
+ * Wasm binary and its loader.
256
+ * @param modelAssetPath The path to the model asset.
257
+ */
258
+ static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceLandmarker>;
259
+ private constructor();
260
+ /**
261
+ * Sets new options for this `FaceLandmarker`.
262
+ *
263
+ * Calling `setOptions()` with a subset of options only affects those options.
264
+ * You can reset an option back to its default value by explicitly setting it
265
+ * to `undefined`.
266
+ *
267
+ * @param options The options for the face landmarker.
268
+ */
269
+ setOptions(options: FaceLandmarkerOptions): Promise<void>;
270
+ /**
271
+ * Performs face landmarks detection on the provided single image and waits
272
+ * synchronously for the response. Only use this method when the
273
+ * FaceLandmarker is created with running mode `image`.
274
+ *
275
+ * @param image An image to process.
276
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
277
+ * to process the input image before running inference.
278
+ * @return The detected face landmarks.
279
+ */
280
+ detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
281
+ /**
282
+ * Performs face landmarks detection on the provided video frame and waits
283
+ * synchronously for the response. Only use this method when the
284
+ * FaceLandmarker is created with running mode `video`.
285
+ *
286
+ * @param videoFrame A video frame to process.
287
+ * @param timestamp The timestamp of the current frame, in ms.
288
+ * @param imageProcessingOptions the `ImageProcessingOptions` specifying how
289
+ * to process the input image before running inference.
290
+ * @return The detected face landmarks.
291
+ */
292
+ detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
293
+ }
294
+
295
+ /** Options to configure the MediaPipe FaceLandmarker Task */
296
+ export declare interface FaceLandmarkerOptions extends VisionTaskOptions {
297
+ /**
298
+ * The maximum number of faces can be detected by the FaceLandmarker.
299
+ * Defaults to 1.
300
+ */
301
+ numFaces?: number | undefined;
302
+ /**
303
+ * The minimum confidence score for the face detection to be considered
304
+ * successful. Defaults to 0.5.
305
+ */
306
+ minFaceDetectionConfidence?: number | undefined;
307
+ /**
308
+ * The minimum confidence score of face presence score in the face landmark
309
+ * detection. Defaults to 0.5.
310
+ */
311
+ minFacePresenceConfidence?: number | undefined;
312
+ /**
313
+ * The minimum confidence score for the face tracking to be considered
314
+ * successful. Defaults to 0.5.
315
+ */
316
+ minTrackingConfidence?: number | undefined;
317
+ /**
318
+ * Whether FaceLandmarker outputs face blendshapes classification. Face
319
+ * blendshapes are used for rendering the 3D face model.
320
+ */
321
+ outputFaceBlendshapes?: boolean | undefined;
322
+ /**
323
+ * Whether FaceLandmarker outputs facial transformation_matrix. Facial
324
+ * transformation matrix is used to transform the face landmarks in canonical
325
+ * face to the detected face, so that users can apply face effects on the
326
+ * detected landmarks.
327
+ */
328
+ outputFacialTransformationMatrixes?: boolean | undefined;
329
+ }
330
+
331
+ /**
332
+ * Represents the face landmarks deection results generated by `FaceLandmarker`.
333
+ */
334
+ export declare interface FaceLandmarkerResult {
335
+ /** Detected face landmarks in normalized image coordinates. */
336
+ faceLandmarks: NormalizedLandmark[][];
337
+ /** Optional face blendshapes results. */
338
+ faceBlendshapes?: Classifications[];
339
+ /** Optional facial transformation matrix. */
340
+ facialTransformationMatrixes?: Matrix[];
341
+ }
342
+
227
343
  /** Performs face stylization on images. */
228
344
  export declare class FaceStylizer extends VisionTaskRunner {
229
345
  /**
@@ -269,7 +385,7 @@ export declare class FaceStylizer extends VisionTaskRunner {
269
385
  * FaceStylizer is created with the image running mode.
270
386
  *
271
387
  * The input image can be of any size. To ensure that the output image has
272
- * reasonable quailty, the stylized output image size is determined by the
388
+ * reasonable quality, the stylized output image size is determined by the
273
389
  * model output size.
274
390
  *
275
391
  * @param image An image to process.
@@ -293,7 +409,7 @@ export declare class FaceStylizer extends VisionTaskRunner {
293
409
  * first, then the specified rotation is applied to the crop.
294
410
  *
295
411
  * The input image can be of any size. To ensure that the output image has
296
- * reasonable quailty, the stylized output image size is the smaller of the
412
+ * reasonable quality, the stylized output image size is the smaller of the
297
413
  * model output size and the size of the 'regionOfInterest' specified in
298
414
  * 'imageProcessingOptions'.
299
415
  *
@@ -340,7 +456,7 @@ export declare class FaceStylizer extends VisionTaskRunner {
340
456
  * frame's timestamp (in milliseconds). The input timestamps must be
341
457
  * monotonically increasing.
342
458
  *
343
- * To ensure that the output image has reasonable quailty, the stylized
459
+ * To ensure that the output image has reasonable quality, the stylized
344
460
  * output image size is the smaller of the model output size and the size of
345
461
  * the 'regionOfInterest' specified in 'imageProcessingOptions'.
346
462
  *
@@ -1123,6 +1239,31 @@ export declare interface Landmark {
1123
1239
  z: number;
1124
1240
  }
1125
1241
 
1242
+ /**
1243
+ * Copyright 2023 The MediaPipe Authors. All Rights Reserved.
1244
+ *
1245
+ * Licensed under the Apache License, Version 2.0 (the "License");
1246
+ * you may not use this file except in compliance with the License.
1247
+ * You may obtain a copy of the License at
1248
+ *
1249
+ * http://www.apache.org/licenses/LICENSE-2.0
1250
+ *
1251
+ * Unless required by applicable law or agreed to in writing, software
1252
+ * distributed under the License is distributed on an "AS IS" BASIS,
1253
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1254
+ * See the License for the specific language governing permissions and
1255
+ * limitations under the License.
1256
+ */
1257
+ /** A two-dimenionsal matrix. */
1258
+ declare interface Matrix {
1259
+ /** The number of rows. */
1260
+ rows: number;
1261
+ /** The number of columns. */
1262
+ columns: number;
1263
+ /** The values as a flattened one-dimensional array. */
1264
+ data: number[];
1265
+ }
1266
+
1126
1267
  /**
1127
1268
  * Copyright 2023 The MediaPipe Authors. All Rights Reserved.
1128
1269
  *