@mediapipe/tasks-vision 0.1.0-alpha-13 → 0.1.0-alpha-15
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/vision.d.ts
CHANGED
|
@@ -448,6 +448,33 @@ export declare class FaceLandmarker extends VisionTaskRunner {
|
|
|
448
448
|
* @param modelAssetPath The path to the model asset.
|
|
449
449
|
*/
|
|
450
450
|
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceLandmarker>;
|
|
451
|
+
/** Landmark connections to draw the connection between a face's lips. */
|
|
452
|
+
static FACE_LANDMARKS_LIPS: Connection[];
|
|
453
|
+
/** Landmark connections to draw the connection between a face's left eye. */
|
|
454
|
+
static FACE_LANDMARKS_LEFT_EYE: Connection[];
|
|
455
|
+
/**
|
|
456
|
+
* Landmark connections to draw the connection between a face's left eyebrow.
|
|
457
|
+
*/
|
|
458
|
+
static FACE_LANDMARKS_LEFT_EYEBROW: Connection[];
|
|
459
|
+
/** Landmark connections to draw the connection between a face's left iris. */
|
|
460
|
+
static FACE_LANDMARKS_LEFT_IRIS: Connection[];
|
|
461
|
+
/** Landmark connections to draw the connection between a face's right eye. */
|
|
462
|
+
static FACE_LANDMARKS_RIGHT_EYE: Connection[];
|
|
463
|
+
/**
|
|
464
|
+
* Landmark connections to draw the connection between a face's right
|
|
465
|
+
* eyebrow.
|
|
466
|
+
*/
|
|
467
|
+
static FACE_LANDMARKS_RIGHT_EYEBROW: Connection[];
|
|
468
|
+
/**
|
|
469
|
+
* Landmark connections to draw the connection between a face's right iris.
|
|
470
|
+
*/
|
|
471
|
+
static FACE_LANDMARKS_RIGHT_IRIS: Connection[];
|
|
472
|
+
/** Landmark connections to draw the face's oval. */
|
|
473
|
+
static FACE_LANDMARKS_FACE_OVAL: Connection[];
|
|
474
|
+
/** Landmark connections to draw the face's contour. */
|
|
475
|
+
static FACE_LANDMARKS_CONTOURS: Connection[];
|
|
476
|
+
/** Landmark connections to draw the face's tesselation. */
|
|
477
|
+
static FACE_LANDMARKS_TESSELATION: Connection[];
|
|
451
478
|
private constructor();
|
|
452
479
|
/**
|
|
453
480
|
* Sets new options for this `FaceLandmarker`.
|
|
@@ -532,23 +559,6 @@ export declare interface FaceLandmarkerResult {
|
|
|
532
559
|
facialTransformationMatrixes?: Matrix[];
|
|
533
560
|
}
|
|
534
561
|
|
|
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
|
-
|
|
552
562
|
/** Performs face stylization on images. */
|
|
553
563
|
export declare class FaceStylizer extends VisionTaskRunner {
|
|
554
564
|
/**
|
|
@@ -589,20 +599,22 @@ export declare class FaceStylizer extends VisionTaskRunner {
|
|
|
589
599
|
*/
|
|
590
600
|
setOptions(options: FaceStylizerOptions): Promise<void>;
|
|
591
601
|
/**
|
|
592
|
-
* Performs face stylization on the provided single image
|
|
593
|
-
*
|
|
594
|
-
* FaceStylizer is created with the
|
|
602
|
+
* Performs face stylization on the provided single image and invokes the
|
|
603
|
+
* callback with result. The method returns synchronously once the callback
|
|
604
|
+
* returns. Only use this method when the FaceStylizer is created with the
|
|
605
|
+
* image running mode.
|
|
595
606
|
*
|
|
596
607
|
* @param image An image to process.
|
|
597
|
-
* @param callback The callback that is invoked with the stylized image
|
|
598
|
-
*
|
|
599
|
-
*
|
|
608
|
+
* @param callback The callback that is invoked with the stylized image or
|
|
609
|
+
* `null` if no face was detected. The lifetime of the returned data is
|
|
610
|
+
* only guaranteed for the duration of the callback.
|
|
600
611
|
*/
|
|
601
612
|
stylize(image: ImageSource, callback: FaceStylizerCallback): void;
|
|
602
613
|
/**
|
|
603
|
-
* Performs face stylization on the provided single image
|
|
604
|
-
*
|
|
605
|
-
* FaceStylizer is created with the
|
|
614
|
+
* Performs face stylization on the provided single image and invokes the
|
|
615
|
+
* callback with result. The method returns synchronously once the callback
|
|
616
|
+
* returns. Only use this method when the FaceStylizer is created with the
|
|
617
|
+
* image running mode.
|
|
606
618
|
*
|
|
607
619
|
* The 'imageProcessingOptions' parameter can be used to specify one or all
|
|
608
620
|
* of:
|
|
@@ -616,14 +628,49 @@ export declare class FaceStylizer extends VisionTaskRunner {
|
|
|
616
628
|
* @param image An image to process.
|
|
617
629
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
618
630
|
* to process the input image before running inference.
|
|
619
|
-
* @param callback The callback that is invoked with the stylized image
|
|
620
|
-
*
|
|
621
|
-
* callback.
|
|
631
|
+
* @param callback The callback that is invoked with the stylized image or
|
|
632
|
+
* `null` if no face was detected. The lifetime of the returned data is
|
|
633
|
+
* only guaranteed for the duration of the callback.
|
|
622
634
|
*/
|
|
623
635
|
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
|
|
624
636
|
/**
|
|
625
|
-
* Performs face stylization on the provided
|
|
626
|
-
*
|
|
637
|
+
* Performs face stylization on the provided single image and returns the
|
|
638
|
+
* result. This method creates a copy of the resulting image and should not be
|
|
639
|
+
* used in high-throughput applictions. Only use this method when the
|
|
640
|
+
* FaceStylizer is created with the image running mode.
|
|
641
|
+
*
|
|
642
|
+
* @param image An image to process.
|
|
643
|
+
* @return A stylized face or `null` if no face was detected. The result is
|
|
644
|
+
* copied to avoid lifetime issues.
|
|
645
|
+
*/
|
|
646
|
+
stylize(image: ImageSource): MPImage | null;
|
|
647
|
+
/**
|
|
648
|
+
* Performs face stylization on the provided single image and returns the
|
|
649
|
+
* result. This method creates a copy of the resulting image and should not be
|
|
650
|
+
* used in high-throughput applictions. Only use this method when the
|
|
651
|
+
* FaceStylizer is created with the image running mode.
|
|
652
|
+
*
|
|
653
|
+
* The 'imageProcessingOptions' parameter can be used to specify one or all
|
|
654
|
+
* of:
|
|
655
|
+
* - the rotation to apply to the image before performing stylization, by
|
|
656
|
+
* setting its 'rotationDegrees' property.
|
|
657
|
+
* - the region-of-interest on which to perform stylization, by setting its
|
|
658
|
+
* 'regionOfInterest' property. If not specified, the full image is used.
|
|
659
|
+
* If both are specified, the crop around the region-of-interest is extracted
|
|
660
|
+
* first, then the specified rotation is applied to the crop.
|
|
661
|
+
*
|
|
662
|
+
* @param image An image to process.
|
|
663
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
664
|
+
* to process the input image before running inference.
|
|
665
|
+
* @return A stylized face or `null` if no face was detected. The result is
|
|
666
|
+
* copied to avoid lifetime issues.
|
|
667
|
+
*/
|
|
668
|
+
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
|
|
669
|
+
/**
|
|
670
|
+
* Performs face stylization on the provided video frame and invokes the
|
|
671
|
+
* callback with result. The method returns synchronously once the callback
|
|
672
|
+
* returns. Only use this method when the FaceStylizer is created with the
|
|
673
|
+
* video running mode.
|
|
627
674
|
*
|
|
628
675
|
* The input frame can be of any size. It's required to provide the video
|
|
629
676
|
* frame's timestamp (in milliseconds). The input timestamps must be
|
|
@@ -631,14 +678,16 @@ export declare class FaceStylizer extends VisionTaskRunner {
|
|
|
631
678
|
*
|
|
632
679
|
* @param videoFrame A video frame to process.
|
|
633
680
|
* @param timestamp The timestamp of the current frame, in ms.
|
|
634
|
-
* @param callback The callback that is invoked with the stylized image
|
|
635
|
-
*
|
|
636
|
-
* the callback.
|
|
681
|
+
* @param callback The callback that is invoked with the stylized image or
|
|
682
|
+
* `null` if no face was detected. The lifetime of the returned data is only
|
|
683
|
+
* guaranteed for the duration of the callback.
|
|
637
684
|
*/
|
|
638
685
|
stylizeForVideo(videoFrame: ImageSource, timestamp: number, callback: FaceStylizerCallback): void;
|
|
639
686
|
/**
|
|
640
|
-
* Performs face stylization on the provided video frame
|
|
641
|
-
*
|
|
687
|
+
* Performs face stylization on the provided video frame and invokes the
|
|
688
|
+
* callback with result. The method returns synchronously once the callback
|
|
689
|
+
* returns. Only use this method when the FaceStylizer is created with the
|
|
690
|
+
* video running mode.
|
|
642
691
|
*
|
|
643
692
|
* The 'imageProcessingOptions' parameter can be used to specify one or all
|
|
644
693
|
* of:
|
|
@@ -654,25 +703,67 @@ export declare class FaceStylizer extends VisionTaskRunner {
|
|
|
654
703
|
* monotonically increasing.
|
|
655
704
|
*
|
|
656
705
|
* @param videoFrame A video frame to process.
|
|
706
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
657
707
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
658
708
|
* to process the input image before running inference.
|
|
709
|
+
* @param callback The callback that is invoked with the stylized image or
|
|
710
|
+
* `null` if no face was detected. The lifetime of the returned data is only
|
|
711
|
+
* guaranteed for the duration of the callback.
|
|
712
|
+
*/
|
|
713
|
+
stylizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
|
|
714
|
+
/**
|
|
715
|
+
* Performs face stylization on the provided video frame. This method creates
|
|
716
|
+
* a copy of the resulting image and should not be used in high-throughput
|
|
717
|
+
* applictions. Only use this method when the FaceStylizer is created with the
|
|
718
|
+
* video running mode.
|
|
719
|
+
*
|
|
720
|
+
* The input frame can be of any size. It's required to provide the video
|
|
721
|
+
* frame's timestamp (in milliseconds). The input timestamps must be
|
|
722
|
+
* monotonically increasing.
|
|
723
|
+
*
|
|
724
|
+
* @param videoFrame A video frame to process.
|
|
725
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
726
|
+
* @return A stylized face or `null` if no face was detected. The result is
|
|
727
|
+
* copied to avoid lifetime issues.
|
|
728
|
+
*/
|
|
729
|
+
stylizeForVideo(videoFrame: ImageSource, timestamp: number): MPImage | null;
|
|
730
|
+
/**
|
|
731
|
+
* Performs face stylization on the provided video frame. This method creates
|
|
732
|
+
* a copy of the resulting image and should not be used in high-throughput
|
|
733
|
+
* applictions. Only use this method when the FaceStylizer is created with the
|
|
734
|
+
* video running mode.
|
|
735
|
+
*
|
|
736
|
+
* The 'imageProcessingOptions' parameter can be used to specify one or all
|
|
737
|
+
* of:
|
|
738
|
+
* - the rotation to apply to the image before performing stylization, by
|
|
739
|
+
* setting its 'rotationDegrees' property.
|
|
740
|
+
* - the region-of-interest on which to perform stylization, by setting its
|
|
741
|
+
* 'regionOfInterest' property. If not specified, the full image is used.
|
|
742
|
+
* If both are specified, the crop around the region-of-interest is
|
|
743
|
+
* extracted first, then the specified rotation is applied to the crop.
|
|
744
|
+
*
|
|
745
|
+
* The input frame can be of any size. It's required to provide the video
|
|
746
|
+
* frame's timestamp (in milliseconds). The input timestamps must be
|
|
747
|
+
* monotonically increasing.
|
|
748
|
+
*
|
|
749
|
+
* @param videoFrame A video frame to process.
|
|
659
750
|
* @param timestamp The timestamp of the current frame, in ms.
|
|
660
|
-
* @param
|
|
661
|
-
*
|
|
662
|
-
*
|
|
751
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
752
|
+
* to process the input image before running inference.
|
|
753
|
+
* @return A stylized face or `null` if no face was detected. The result is
|
|
754
|
+
* copied to avoid lifetime issues.
|
|
663
755
|
*/
|
|
664
|
-
stylizeForVideo(videoFrame: ImageSource,
|
|
756
|
+
stylizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
|
|
665
757
|
}
|
|
666
758
|
|
|
667
759
|
/**
|
|
668
|
-
* A callback that receives an
|
|
669
|
-
* face was detected. The lifetime of the underlying data is
|
|
670
|
-
* duration of the callback. If asynchronous processing is
|
|
671
|
-
* needs to be copied before the callback returns
|
|
672
|
-
*
|
|
673
|
-
* The `WebGLTexture` output type is reserved for future usage.
|
|
760
|
+
* A callback that receives an `MPImage` object from the face stylizer, or
|
|
761
|
+
* `null` if no face was detected. The lifetime of the underlying data is
|
|
762
|
+
* limited to the duration of the callback. If asynchronous processing is
|
|
763
|
+
* needed, all data needs to be copied before the callback returns (via
|
|
764
|
+
* `image.clone()`).
|
|
674
765
|
*/
|
|
675
|
-
export declare type FaceStylizerCallback = (image:
|
|
766
|
+
export declare type FaceStylizerCallback = (image: MPImage | null) => void;
|
|
676
767
|
|
|
677
768
|
/** Options to configure the MediaPipe Face Stylizer Task */
|
|
678
769
|
export declare interface FaceStylizerOptions extends VisionTaskOptions {
|
|
@@ -1228,6 +1319,30 @@ export declare class ImageSegmenter extends VisionTaskRunner {
|
|
|
1228
1319
|
* callback.
|
|
1229
1320
|
*/
|
|
1230
1321
|
segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
|
|
1322
|
+
/**
|
|
1323
|
+
* Performs image segmentation on the provided single image and returns the
|
|
1324
|
+
* segmentation result. This method creates a copy of the resulting masks and
|
|
1325
|
+
* should not be used in high-throughput applictions. Only use this method
|
|
1326
|
+
* when the ImageSegmenter is created with running mode `image`.
|
|
1327
|
+
*
|
|
1328
|
+
* @param image An image to process.
|
|
1329
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1330
|
+
* issues.
|
|
1331
|
+
*/
|
|
1332
|
+
segment(image: ImageSource): ImageSegmenterResult;
|
|
1333
|
+
/**
|
|
1334
|
+
* Performs image segmentation on the provided single image and returns the
|
|
1335
|
+
* segmentation result. This method creates a copy of the resulting masks and
|
|
1336
|
+
* should not be used in high-v applictions. Only use this method when
|
|
1337
|
+
* the ImageSegmenter is created with running mode `image`.
|
|
1338
|
+
*
|
|
1339
|
+
* @param image An image to process.
|
|
1340
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1341
|
+
* to process the input image before running inference.
|
|
1342
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1343
|
+
* issues.
|
|
1344
|
+
*/
|
|
1345
|
+
segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
|
|
1231
1346
|
/**
|
|
1232
1347
|
* Performs image segmentation on the provided video frame and invokes the
|
|
1233
1348
|
* callback with the response. The method returns synchronously once the
|
|
@@ -1248,14 +1363,39 @@ export declare class ImageSegmenter extends VisionTaskRunner {
|
|
|
1248
1363
|
* created with running mode `video`.
|
|
1249
1364
|
*
|
|
1250
1365
|
* @param videoFrame A video frame to process.
|
|
1251
|
-
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1252
|
-
* to process the input image before running inference.
|
|
1253
1366
|
* @param timestamp The timestamp of the current frame, in ms.
|
|
1367
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1368
|
+
* to process the input frame before running inference.
|
|
1254
1369
|
* @param callback The callback that is invoked with the segmented masks. The
|
|
1255
1370
|
* lifetime of the returned data is only guaranteed for the duration of the
|
|
1256
1371
|
* callback.
|
|
1257
1372
|
*/
|
|
1258
|
-
segmentForVideo(videoFrame: ImageSource,
|
|
1373
|
+
segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
|
|
1374
|
+
/**
|
|
1375
|
+
* Performs image segmentation on the provided video frame and returns the
|
|
1376
|
+
* segmentation result. This method creates a copy of the resulting masks and
|
|
1377
|
+
* should not be used in high-throughput applictions. Only use this method
|
|
1378
|
+
* when the ImageSegmenter is created with running mode `video`.
|
|
1379
|
+
*
|
|
1380
|
+
* @param videoFrame A video frame to process.
|
|
1381
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1382
|
+
* issues.
|
|
1383
|
+
*/
|
|
1384
|
+
segmentForVideo(videoFrame: ImageSource, timestamp: number): ImageSegmenterResult;
|
|
1385
|
+
/**
|
|
1386
|
+
* Performs image segmentation on the provided video frame and returns the
|
|
1387
|
+
* segmentation result. This method creates a copy of the resulting masks and
|
|
1388
|
+
* should not be used in high-v applictions. Only use this method when
|
|
1389
|
+
* the ImageSegmenter is created with running mode `video`.
|
|
1390
|
+
*
|
|
1391
|
+
* @param videoFrame A video frame to process.
|
|
1392
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
1393
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1394
|
+
* to process the input frame before running inference.
|
|
1395
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1396
|
+
* issues.
|
|
1397
|
+
*/
|
|
1398
|
+
segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
|
|
1259
1399
|
/**
|
|
1260
1400
|
* Get the category label list of the ImageSegmenter can recognize. For
|
|
1261
1401
|
* `CATEGORY_MASK` type, the index in the category mask corresponds to the
|
|
@@ -1291,38 +1431,20 @@ export declare interface ImageSegmenterOptions extends VisionTaskOptions {
|
|
|
1291
1431
|
outputCategoryMask?: boolean | undefined;
|
|
1292
1432
|
}
|
|
1293
1433
|
|
|
1294
|
-
/**
|
|
1295
|
-
* Copyright 2023 The MediaPipe Authors.
|
|
1296
|
-
*
|
|
1297
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1298
|
-
* you may not use this file except in compliance with the License.
|
|
1299
|
-
* You may obtain a copy of the License at
|
|
1300
|
-
*
|
|
1301
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1302
|
-
*
|
|
1303
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1304
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1305
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1306
|
-
* See the License for the specific language governing permissions and
|
|
1307
|
-
* limitations under the License.
|
|
1308
|
-
*/
|
|
1309
1434
|
/** The output result of ImageSegmenter. */
|
|
1310
1435
|
export declare interface ImageSegmenterResult {
|
|
1311
1436
|
/**
|
|
1312
|
-
* Multiple masks as
|
|
1313
|
-
*
|
|
1437
|
+
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
|
|
1438
|
+
* `MPImage`s where, for each mask, each pixel represents the prediction
|
|
1439
|
+
* confidence, usually in the [0, 1] range.
|
|
1314
1440
|
*/
|
|
1315
|
-
confidenceMasks?:
|
|
1441
|
+
confidenceMasks?: MPMask[];
|
|
1316
1442
|
/**
|
|
1317
|
-
* A category mask as a Uint8ClampedArray or
|
|
1318
|
-
*
|
|
1319
|
-
* predicted to belong to.
|
|
1443
|
+
* A category mask represented as a `Uint8ClampedArray` or
|
|
1444
|
+
* `WebGLTexture`-backed `MPImage` where each pixel represents the class which
|
|
1445
|
+
* the pixel in the original image was predicted to belong to.
|
|
1320
1446
|
*/
|
|
1321
|
-
categoryMask?:
|
|
1322
|
-
/** The width of the masks. */
|
|
1323
|
-
width: number;
|
|
1324
|
-
/** The height of the masks. */
|
|
1325
|
-
height: number;
|
|
1447
|
+
categoryMask?: MPMask;
|
|
1326
1448
|
}
|
|
1327
1449
|
|
|
1328
1450
|
/**
|
|
@@ -1398,14 +1520,9 @@ export declare class InteractiveSegmenter extends VisionTaskRunner {
|
|
|
1398
1520
|
setOptions(options: InteractiveSegmenterOptions): Promise<void>;
|
|
1399
1521
|
/**
|
|
1400
1522
|
* Performs interactive segmentation on the provided single image and invokes
|
|
1401
|
-
* the callback with the response.
|
|
1402
|
-
* user's region
|
|
1403
|
-
*
|
|
1404
|
-
* If the output_type is `CATEGORY_MASK`, the callback is invoked with vector
|
|
1405
|
-
* of images that represent per-category segmented image mask. If the
|
|
1406
|
-
* output_type is `CONFIDENCE_MASK`, the callback is invoked with a vector of
|
|
1407
|
-
* images that contains only one confidence image mask. The method returns
|
|
1408
|
-
* synchronously once the callback returns.
|
|
1523
|
+
* the callback with the response. The method returns synchronously once the
|
|
1524
|
+
* callback returns. The `roi` parameter is used to represent a user's region
|
|
1525
|
+
* of interest for segmentation.
|
|
1409
1526
|
*
|
|
1410
1527
|
* @param image An image to process.
|
|
1411
1528
|
* @param roi The region of interest for segmentation.
|
|
@@ -1416,8 +1533,9 @@ export declare class InteractiveSegmenter extends VisionTaskRunner {
|
|
|
1416
1533
|
segment(image: ImageSource, roi: RegionOfInterest, callback: InteractiveSegmenterCallback): void;
|
|
1417
1534
|
/**
|
|
1418
1535
|
* Performs interactive segmentation on the provided single image and invokes
|
|
1419
|
-
* the callback with the response. The
|
|
1420
|
-
* user's region
|
|
1536
|
+
* the callback with the response. The method returns synchronously once the
|
|
1537
|
+
* callback returns. The `roi` parameter is used to represent a user's region
|
|
1538
|
+
* of interest for segmentation.
|
|
1421
1539
|
*
|
|
1422
1540
|
* The 'image_processing_options' parameter can be used to specify the
|
|
1423
1541
|
* rotation to apply to the image before performing segmentation, by setting
|
|
@@ -1425,12 +1543,6 @@ export declare class InteractiveSegmenter extends VisionTaskRunner {
|
|
|
1425
1543
|
* using the 'regionOfInterest' field is NOT supported and will result in an
|
|
1426
1544
|
* error.
|
|
1427
1545
|
*
|
|
1428
|
-
* If the output_type is `CATEGORY_MASK`, the callback is invoked with vector
|
|
1429
|
-
* of images that represent per-category segmented image mask. If the
|
|
1430
|
-
* output_type is `CONFIDENCE_MASK`, the callback is invoked with a vector of
|
|
1431
|
-
* images that contains only one confidence image mask. The method returns
|
|
1432
|
-
* synchronously once the callback returns.
|
|
1433
|
-
*
|
|
1434
1546
|
* @param image An image to process.
|
|
1435
1547
|
* @param roi The region of interest for segmentation.
|
|
1436
1548
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
@@ -1440,6 +1552,38 @@ export declare class InteractiveSegmenter extends VisionTaskRunner {
|
|
|
1440
1552
|
* callback.
|
|
1441
1553
|
*/
|
|
1442
1554
|
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions, callback: InteractiveSegmenterCallback): void;
|
|
1555
|
+
/**
|
|
1556
|
+
* Performs interactive segmentation on the provided video frame and returns
|
|
1557
|
+
* the segmentation result. This method creates a copy of the resulting masks
|
|
1558
|
+
* and should not be used in high-throughput applictions. The `roi` parameter
|
|
1559
|
+
* is used to represent a user's region of interest for segmentation.
|
|
1560
|
+
*
|
|
1561
|
+
* @param image An image to process.
|
|
1562
|
+
* @param roi The region of interest for segmentation.
|
|
1563
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1564
|
+
* limits.
|
|
1565
|
+
*/
|
|
1566
|
+
segment(image: ImageSource, roi: RegionOfInterest): InteractiveSegmenterResult;
|
|
1567
|
+
/**
|
|
1568
|
+
* Performs interactive segmentation on the provided video frame and returns
|
|
1569
|
+
* the segmentation result. This method creates a copy of the resulting masks
|
|
1570
|
+
* and should not be used in high-throughput applictions. The `roi` parameter
|
|
1571
|
+
* is used to represent a user's region of interest for segmentation.
|
|
1572
|
+
*
|
|
1573
|
+
* The 'image_processing_options' parameter can be used to specify the
|
|
1574
|
+
* rotation to apply to the image before performing segmentation, by setting
|
|
1575
|
+
* its 'rotationDegrees' field. Note that specifying a region-of-interest
|
|
1576
|
+
* using the 'regionOfInterest' field is NOT supported and will result in an
|
|
1577
|
+
* error.
|
|
1578
|
+
*
|
|
1579
|
+
* @param image An image to process.
|
|
1580
|
+
* @param roi The region of interest for segmentation.
|
|
1581
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
1582
|
+
* to process the input image before running inference.
|
|
1583
|
+
* @return The segmentation result. The data is copied to avoid lifetime
|
|
1584
|
+
* limits.
|
|
1585
|
+
*/
|
|
1586
|
+
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions): InteractiveSegmenterResult;
|
|
1443
1587
|
}
|
|
1444
1588
|
|
|
1445
1589
|
/**
|
|
@@ -1458,38 +1602,20 @@ export declare interface InteractiveSegmenterOptions extends TaskRunnerOptions {
|
|
|
1458
1602
|
outputCategoryMask?: boolean | undefined;
|
|
1459
1603
|
}
|
|
1460
1604
|
|
|
1461
|
-
/**
|
|
1462
|
-
* Copyright 2023 The MediaPipe Authors.
|
|
1463
|
-
*
|
|
1464
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1465
|
-
* you may not use this file except in compliance with the License.
|
|
1466
|
-
* You may obtain a copy of the License at
|
|
1467
|
-
*
|
|
1468
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1469
|
-
*
|
|
1470
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1471
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1472
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1473
|
-
* See the License for the specific language governing permissions and
|
|
1474
|
-
* limitations under the License.
|
|
1475
|
-
*/
|
|
1476
1605
|
/** The output result of InteractiveSegmenter. */
|
|
1477
1606
|
export declare interface InteractiveSegmenterResult {
|
|
1478
1607
|
/**
|
|
1479
|
-
* Multiple masks as
|
|
1480
|
-
*
|
|
1608
|
+
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
|
|
1609
|
+
* `MPImage`s where, for each mask, each pixel represents the prediction
|
|
1610
|
+
* confidence, usually in the [0, 1] range.
|
|
1481
1611
|
*/
|
|
1482
|
-
confidenceMasks?:
|
|
1612
|
+
confidenceMasks?: MPMask[];
|
|
1483
1613
|
/**
|
|
1484
|
-
* A category mask as a Uint8ClampedArray or
|
|
1485
|
-
*
|
|
1486
|
-
* predicted to belong to.
|
|
1614
|
+
* A category mask represented as a `Uint8ClampedArray` or
|
|
1615
|
+
* `WebGLTexture`-backed `MPImage` where each pixel represents the class which
|
|
1616
|
+
* the pixel in the original image was predicted to belong to.
|
|
1487
1617
|
*/
|
|
1488
|
-
categoryMask?:
|
|
1489
|
-
/** The width of the masks. */
|
|
1490
|
-
width: number;
|
|
1491
|
-
/** The height of the masks. */
|
|
1492
|
-
height: number;
|
|
1618
|
+
categoryMask?: MPMask;
|
|
1493
1619
|
}
|
|
1494
1620
|
|
|
1495
1621
|
/**
|
|
@@ -1543,9 +1669,9 @@ declare interface Matrix {
|
|
|
1543
1669
|
*
|
|
1544
1670
|
* Images are stored as `ImageData`, `ImageBitmap` or `WebGLTexture` objects.
|
|
1545
1671
|
* You can convert the underlying type to any other type by passing the
|
|
1546
|
-
* desired type to `
|
|
1672
|
+
* desired type to `getAs...()`. As type conversions can be expensive, it is
|
|
1547
1673
|
* recommended to limit these conversions. You can verify what underlying
|
|
1548
|
-
* types are already available by invoking `
|
|
1674
|
+
* types are already available by invoking `has...()`.
|
|
1549
1675
|
*
|
|
1550
1676
|
* Images that are returned from a MediaPipe Tasks are owned by by the
|
|
1551
1677
|
* underlying C++ Task. If you need to extend the lifetime of these objects,
|
|
@@ -1557,14 +1683,6 @@ declare interface Matrix {
|
|
|
1557
1683
|
* initialized with an `OffscreenCanvas`. As we require WebGL2 support, this
|
|
1558
1684
|
* places some limitations on Browser support as outlined here:
|
|
1559
1685
|
* https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
|
|
1560
|
-
*
|
|
1561
|
-
* Some MediaPipe tasks return single channel masks. These masks are stored
|
|
1562
|
-
* using an underlying `Uint8ClampedArray` an `Float32Array` (represented as
|
|
1563
|
-
* single-channel arrays). To convert these type to other formats a conversion
|
|
1564
|
-
* function is invoked to convert pixel values between single channel and four
|
|
1565
|
-
* channel RGBA values. To customize this conversion, you can specify these
|
|
1566
|
-
* conversion functions when you invoke `getImage()`. If you use the default
|
|
1567
|
-
* conversion function a warning will be logged to the console.
|
|
1568
1686
|
*/
|
|
1569
1687
|
export declare class MPImage {
|
|
1570
1688
|
/** Returns the canvas element that the image is bound to. */
|
|
@@ -1574,82 +1692,42 @@ export declare class MPImage {
|
|
|
1574
1692
|
/** Returns the height of the image. */
|
|
1575
1693
|
readonly height: number;
|
|
1576
1694
|
private constructor();
|
|
1577
|
-
/**
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
/**
|
|
1584
|
-
* Returns the underlying image as a single channel `Uint8ClampedArray`. Note
|
|
1585
|
-
* that this involves an expensive GPU to CPU transfer if the current image is
|
|
1586
|
-
* only available as an `ImageBitmap` or `WebGLTexture`. If necessary, this
|
|
1587
|
-
* function converts RGBA data pixel-by-pixel to a single channel value by
|
|
1588
|
-
* invoking a conversion function (see class comment for detail).
|
|
1589
|
-
*
|
|
1590
|
-
* @param type The type of image to return.
|
|
1591
|
-
* @param converter A set of conversion functions that will be invoked to
|
|
1592
|
-
* convert the underlying pixel data if necessary. You may omit this
|
|
1593
|
-
* function if the requested conversion does not change the pixel format.
|
|
1594
|
-
* @return The current data as a Uint8ClampedArray.
|
|
1595
|
-
*/
|
|
1596
|
-
getImage(type: MPImageStorageType.UINT8_CLAMPED_ARRAY, converter?: MPImageChannelConverter): Uint8ClampedArray;
|
|
1597
|
-
/**
|
|
1598
|
-
* Returns the underlying image as a single channel `Float32Array`. Note
|
|
1599
|
-
* that this involves an expensive GPU to CPU transfer if the current image is
|
|
1600
|
-
* only available as an `ImageBitmap` or `WebGLTexture`. If necessary, this
|
|
1601
|
-
* function converts RGBA data pixel-by-pixel to a single channel value by
|
|
1602
|
-
* invoking a conversion function (see class comment for detail).
|
|
1603
|
-
*
|
|
1604
|
-
* @param type The type of image to return.
|
|
1605
|
-
* @param converter A set of conversion functions that will be invoked to
|
|
1606
|
-
* convert the underlying pixel data if necessary. You may omit this
|
|
1607
|
-
* function if the requested conversion does not change the pixel format.
|
|
1608
|
-
* @return The current image as a Float32Array.
|
|
1609
|
-
*/
|
|
1610
|
-
getImage(type: MPImageStorageType.FLOAT32_ARRAY, converter?: MPImageChannelConverter): Float32Array;
|
|
1695
|
+
/** Returns whether this `MPImage` contains a mask of type `ImageData`. */
|
|
1696
|
+
hasImageData(): boolean;
|
|
1697
|
+
/** Returns whether this `MPImage` contains a mask of type `ImageBitmap`. */
|
|
1698
|
+
hasImageBitmap(): boolean;
|
|
1699
|
+
/** Returns whether this `MPImage` contains a mask of type `WebGLTexture`. */
|
|
1700
|
+
hasWebGLTexture(): boolean;
|
|
1611
1701
|
/**
|
|
1612
1702
|
* Returns the underlying image as an `ImageData` object. Note that this
|
|
1613
1703
|
* involves an expensive GPU to CPU transfer if the current image is only
|
|
1614
|
-
* available as an `ImageBitmap` or `WebGLTexture`.
|
|
1615
|
-
* function converts single channel pixel values to RGBA by invoking a
|
|
1616
|
-
* conversion function (see class comment for detail).
|
|
1704
|
+
* available as an `ImageBitmap` or `WebGLTexture`.
|
|
1617
1705
|
*
|
|
1618
1706
|
* @return The current image as an ImageData object.
|
|
1619
1707
|
*/
|
|
1620
|
-
|
|
1708
|
+
getAsImageData(): ImageData;
|
|
1621
1709
|
/**
|
|
1622
1710
|
* Returns the underlying image as an `ImageBitmap`. Note that
|
|
1623
1711
|
* conversions to `ImageBitmap` are expensive, especially if the data
|
|
1624
|
-
* currently resides on CPU.
|
|
1625
|
-
* channel pixel values to RGBA by invoking a conversion function (see class
|
|
1626
|
-
* comment for detail).
|
|
1712
|
+
* currently resides on CPU.
|
|
1627
1713
|
*
|
|
1628
1714
|
* Processing with `ImageBitmap`s requires that the MediaPipe Task was
|
|
1629
1715
|
* initialized with an `OffscreenCanvas` with WebGL2 support. See
|
|
1630
1716
|
* https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
|
|
1631
1717
|
* for a list of supported platforms.
|
|
1632
1718
|
*
|
|
1633
|
-
* @param type The type of image to return.
|
|
1634
|
-
* @param converter A set of conversion functions that will be invoked to
|
|
1635
|
-
* convert the underlying pixel data if necessary. You may omit this
|
|
1636
|
-
* function if the requested conversion does not change the pixel format.
|
|
1637
1719
|
* @return The current image as an ImageBitmap object.
|
|
1638
1720
|
*/
|
|
1639
|
-
|
|
1721
|
+
getAsImageBitmap(): ImageBitmap;
|
|
1640
1722
|
/**
|
|
1641
1723
|
* Returns the underlying image as a `WebGLTexture` object. Note that this
|
|
1642
1724
|
* involves a CPU to GPU transfer if the current image is only available as
|
|
1643
1725
|
* an `ImageData` object. The returned texture is bound to the current
|
|
1644
1726
|
* canvas (see `.canvas`).
|
|
1645
1727
|
*
|
|
1646
|
-
* @param type The type of image to return.
|
|
1647
|
-
* @param converter A set of conversion functions that will be invoked to
|
|
1648
|
-
* convert the underlying pixel data if necessary. You may omit this
|
|
1649
|
-
* function if the requested conversion does not change the pixel format.
|
|
1650
1728
|
* @return The current image as a WebGLTexture.
|
|
1651
1729
|
*/
|
|
1652
|
-
|
|
1730
|
+
getAsWebGLTexture(): WebGLTexture;
|
|
1653
1731
|
/**
|
|
1654
1732
|
* Creates a copy of the resources stored in this `MPImage`. You can invoke
|
|
1655
1733
|
* this method to extend the lifetime of an image returned by a MediaPipe
|
|
@@ -1670,116 +1748,78 @@ export declare class MPImage {
|
|
|
1670
1748
|
}
|
|
1671
1749
|
|
|
1672
1750
|
/**
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1751
|
+
* The wrapper class for MediaPipe segmentation masks.
|
|
1752
|
+
*
|
|
1753
|
+
* Masks are stored as `Uint8Array`, `Float32Array` or `WebGLTexture` objects.
|
|
1754
|
+
* You can convert the underlying type to any other type by passing the desired
|
|
1755
|
+
* type to `getAs...()`. As type conversions can be expensive, it is recommended
|
|
1756
|
+
* to limit these conversions. You can verify what underlying types are already
|
|
1757
|
+
* available by invoking `has...()`.
|
|
1758
|
+
*
|
|
1759
|
+
* Masks that are returned from a MediaPipe Tasks are owned by by the
|
|
1760
|
+
* underlying C++ Task. If you need to extend the lifetime of these objects,
|
|
1761
|
+
* you can invoke the `clone()` method. To free up the resources obtained
|
|
1762
|
+
* during any clone or type conversion operation, it is important to invoke
|
|
1763
|
+
* `close()` on the `MPMask` instance.
|
|
1677
1764
|
*/
|
|
1678
|
-
export declare
|
|
1765
|
+
export declare class MPMask {
|
|
1766
|
+
/** Returns the canvas element that the mask is bound to. */
|
|
1767
|
+
readonly canvas: HTMLCanvasElement | OffscreenCanvas | undefined;
|
|
1768
|
+
/** Returns the width of the mask. */
|
|
1769
|
+
readonly width: number;
|
|
1770
|
+
/** Returns the height of the mask. */
|
|
1771
|
+
readonly height: number;
|
|
1772
|
+
private constructor();
|
|
1773
|
+
/** Returns whether this `MPMask` contains a mask of type `Uint8Array`. */
|
|
1774
|
+
hasUint8Array(): boolean;
|
|
1775
|
+
/** Returns whether this `MPMask` contains a mask of type `Float32Array`. */
|
|
1776
|
+
hasFloat32Array(): boolean;
|
|
1777
|
+
/** Returns whether this `MPMask` contains a mask of type `WebGLTexture`. */
|
|
1778
|
+
hasWebGLTexture(): boolean;
|
|
1679
1779
|
/**
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
*
|
|
1780
|
+
* Returns the underlying mask as a Uint8Array`. Note that this involves an
|
|
1781
|
+
* expensive GPU to CPU transfer if the current mask is only available as a
|
|
1782
|
+
* `WebGLTexture`.
|
|
1683
1783
|
*
|
|
1684
|
-
* The
|
|
1685
|
-
* and will log a warning if invoked.
|
|
1784
|
+
* @return The current data as a Uint8Array.
|
|
1686
1785
|
*/
|
|
1687
|
-
|
|
1688
|
-
number,
|
|
1689
|
-
number,
|
|
1690
|
-
number,
|
|
1691
|
-
number
|
|
1692
|
-
];
|
|
1693
|
-
uint8ToRGBAConverter?: (value: number) => [
|
|
1694
|
-
number,
|
|
1695
|
-
number,
|
|
1696
|
-
number,
|
|
1697
|
-
number
|
|
1698
|
-
];
|
|
1786
|
+
getAsUint8Array(): Uint8Array;
|
|
1699
1787
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
1788
|
+
* Returns the underlying mask as a single channel `Float32Array`. Note that
|
|
1789
|
+
* this involves an expensive GPU to CPU transfer if the current mask is only
|
|
1790
|
+
* available as a `WebGLTexture`.
|
|
1702
1791
|
*
|
|
1703
|
-
* The
|
|
1704
|
-
* log a warning if invoked.
|
|
1792
|
+
* @return The current mask as a Float32Array.
|
|
1705
1793
|
*/
|
|
1706
|
-
|
|
1794
|
+
getAsFloat32Array(): Float32Array;
|
|
1707
1795
|
/**
|
|
1708
|
-
*
|
|
1709
|
-
* a
|
|
1796
|
+
* Returns the underlying mask as a `WebGLTexture` object. Note that this
|
|
1797
|
+
* involves a CPU to GPU transfer if the current mask is only available as
|
|
1798
|
+
* a CPU array. The returned texture is bound to the current canvas (see
|
|
1799
|
+
* `.canvas`).
|
|
1710
1800
|
*
|
|
1711
|
-
* The
|
|
1712
|
-
* warning if invoked.
|
|
1801
|
+
* @return The current mask as a WebGLTexture.
|
|
1713
1802
|
*/
|
|
1714
|
-
|
|
1803
|
+
getAsWebGLTexture(): WebGLTexture;
|
|
1715
1804
|
/**
|
|
1716
|
-
*
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
1805
|
+
* Creates a copy of the resources stored in this `MPMask`. You can
|
|
1806
|
+
* invoke this method to extend the lifetime of a mask returned by a
|
|
1807
|
+
* MediaPipe Task. Note that performance critical applications should aim to
|
|
1808
|
+
* only use the `MPMask` within the MediaPipe Task callback so that
|
|
1809
|
+
* copies can be avoided.
|
|
1721
1810
|
*/
|
|
1722
|
-
|
|
1811
|
+
clone(): MPMask;
|
|
1723
1812
|
/**
|
|
1724
|
-
*
|
|
1725
|
-
* [0.0, 1.0] .
|
|
1813
|
+
* Frees up any resources owned by this `MPMask` instance.
|
|
1726
1814
|
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
/** The supported image formats. For internal usage. */
|
|
1734
|
-
export declare type MPImageNativeContainer = Uint8ClampedArray | Float32Array | ImageData | ImageBitmap | WebGLTexture;
|
|
1735
|
-
|
|
1736
|
-
/**
|
|
1737
|
-
* A class that encapsulates the shaders used by an MPImage. Can be re-used
|
|
1738
|
-
* across MPImages that use the same WebGL2Rendering context.
|
|
1739
|
-
*/
|
|
1740
|
-
export declare class MPImageShaderContext {
|
|
1741
|
-
/** Runs the callback using the shader. */
|
|
1742
|
-
run<T>(gl: WebGL2RenderingContext, flipVertically: boolean, callback: () => T): T;
|
|
1743
|
-
/**
|
|
1744
|
-
* Binds a framebuffer to the canvas. If the framebuffer does not yet exist,
|
|
1745
|
-
* creates it first. Binds the provided texture to the framebuffer.
|
|
1815
|
+
* Note that this method does not free masks that are owned by the C++
|
|
1816
|
+
* Task, as these are freed automatically once you leave the MediaPipe
|
|
1817
|
+
* callback. Additionally, some shared state is freed only once you invoke
|
|
1818
|
+
* the Task's `close()` method.
|
|
1746
1819
|
*/
|
|
1747
|
-
bindFramebuffer(gl: WebGL2RenderingContext, texture: WebGLTexture): void;
|
|
1748
|
-
unbindFramebuffer(): void;
|
|
1749
1820
|
close(): void;
|
|
1750
1821
|
}
|
|
1751
1822
|
|
|
1752
|
-
/**
|
|
1753
|
-
* Copyright 2023 The MediaPipe Authors.
|
|
1754
|
-
*
|
|
1755
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1756
|
-
* you may not use this file except in compliance with the License.
|
|
1757
|
-
* You may obtain a copy of the License at
|
|
1758
|
-
*
|
|
1759
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1760
|
-
*
|
|
1761
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1762
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1763
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1764
|
-
* See the License for the specific language governing permissions and
|
|
1765
|
-
* limitations under the License.
|
|
1766
|
-
*/
|
|
1767
|
-
/** The underlying type of the image. */
|
|
1768
|
-
export declare enum MPImageStorageType {
|
|
1769
|
-
/** Represents the native `UInt8ClampedArray` type. */
|
|
1770
|
-
UINT8_CLAMPED_ARRAY = 0,
|
|
1771
|
-
/**
|
|
1772
|
-
* Represents the native `Float32Array` type. Values range from [0.0, 1.0].
|
|
1773
|
-
*/
|
|
1774
|
-
FLOAT32_ARRAY = 1,
|
|
1775
|
-
/** Represents the native `ImageData` type. */
|
|
1776
|
-
IMAGE_DATA = 2,
|
|
1777
|
-
/** Represents the native `ImageBitmap` type. */
|
|
1778
|
-
IMAGE_BITMAP = 3,
|
|
1779
|
-
/** Represents the native `WebGLTexture` type. */
|
|
1780
|
-
WEBGL_TEXTURE = 4
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
1823
|
/**
|
|
1784
1824
|
* Copyright 2023 The MediaPipe Authors.
|
|
1785
1825
|
*
|
|
@@ -1954,21 +1994,22 @@ export declare class PoseLandmarker extends VisionTaskRunner {
|
|
|
1954
1994
|
*/
|
|
1955
1995
|
setOptions(options: PoseLandmarkerOptions): Promise<void>;
|
|
1956
1996
|
/**
|
|
1957
|
-
* Performs pose detection on the provided single image and
|
|
1958
|
-
*
|
|
1959
|
-
*
|
|
1997
|
+
* Performs pose detection on the provided single image and invokes the
|
|
1998
|
+
* callback with the response. The method returns synchronously once the
|
|
1999
|
+
* callback returns. Only use this method when the PoseLandmarker is created
|
|
2000
|
+
* with running mode `image`.
|
|
1960
2001
|
*
|
|
1961
2002
|
* @param image An image to process.
|
|
1962
2003
|
* @param callback The callback that is invoked with the result. The
|
|
1963
2004
|
* lifetime of the returned masks is only guaranteed for the duration of
|
|
1964
2005
|
* the callback.
|
|
1965
|
-
* @return The detected pose landmarks.
|
|
1966
2006
|
*/
|
|
1967
2007
|
detect(image: ImageSource, callback: PoseLandmarkerCallback): void;
|
|
1968
2008
|
/**
|
|
1969
|
-
* Performs pose detection on the provided single image and
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
2009
|
+
* Performs pose detection on the provided single image and invokes the
|
|
2010
|
+
* callback with the response. The method returns synchronously once the
|
|
2011
|
+
* callback returns. Only use this method when the PoseLandmarker is created
|
|
2012
|
+
* with running mode `image`.
|
|
1972
2013
|
*
|
|
1973
2014
|
* @param image An image to process.
|
|
1974
2015
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
@@ -1976,37 +2017,89 @@ export declare class PoseLandmarker extends VisionTaskRunner {
|
|
|
1976
2017
|
* @param callback The callback that is invoked with the result. The
|
|
1977
2018
|
* lifetime of the returned masks is only guaranteed for the duration of
|
|
1978
2019
|
* the callback.
|
|
1979
|
-
* @return The detected pose landmarks.
|
|
1980
2020
|
*/
|
|
1981
2021
|
detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
|
|
1982
2022
|
/**
|
|
1983
|
-
* Performs pose detection on the provided
|
|
1984
|
-
* synchronously for the response.
|
|
1985
|
-
*
|
|
2023
|
+
* Performs pose detection on the provided single image and waits
|
|
2024
|
+
* synchronously for the response. This method creates a copy of the resulting
|
|
2025
|
+
* masks and should not be used in high-throughput applictions. Only
|
|
2026
|
+
* use this method when the PoseLandmarker is created with running mode
|
|
2027
|
+
* `image`.
|
|
2028
|
+
*
|
|
2029
|
+
* @param image An image to process.
|
|
2030
|
+
* @return The landmarker result. Any masks are copied to avoid lifetime
|
|
2031
|
+
* limits.
|
|
2032
|
+
* @return The detected pose landmarks.
|
|
2033
|
+
*/
|
|
2034
|
+
detect(image: ImageSource): PoseLandmarkerResult;
|
|
2035
|
+
/**
|
|
2036
|
+
* Performs pose detection on the provided single image and waits
|
|
2037
|
+
* synchronously for the response. This method creates a copy of the resulting
|
|
2038
|
+
* masks and should not be used in high-throughput applictions. Only
|
|
2039
|
+
* use this method when the PoseLandmarker is created with running mode
|
|
2040
|
+
* `image`.
|
|
2041
|
+
*
|
|
2042
|
+
* @param image An image to process.
|
|
2043
|
+
* @return The landmarker result. Any masks are copied to avoid lifetime
|
|
2044
|
+
* limits.
|
|
2045
|
+
* @return The detected pose landmarks.
|
|
2046
|
+
*/
|
|
2047
|
+
detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
|
|
2048
|
+
/**
|
|
2049
|
+
* Performs pose detection on the provided video frame and invokes the
|
|
2050
|
+
* callback with the response. The method returns synchronously once the
|
|
2051
|
+
* callback returns. Only use this method when the PoseLandmarker is created
|
|
2052
|
+
* with running mode `video`.
|
|
1986
2053
|
*
|
|
1987
2054
|
* @param videoFrame A video frame to process.
|
|
1988
2055
|
* @param timestamp The timestamp of the current frame, in ms.
|
|
1989
2056
|
* @param callback The callback that is invoked with the result. The
|
|
1990
2057
|
* lifetime of the returned masks is only guaranteed for the duration of
|
|
1991
2058
|
* the callback.
|
|
1992
|
-
* @return The detected pose landmarks.
|
|
1993
2059
|
*/
|
|
1994
2060
|
detectForVideo(videoFrame: ImageSource, timestamp: number, callback: PoseLandmarkerCallback): void;
|
|
1995
2061
|
/**
|
|
1996
|
-
* Performs pose detection on the provided video frame and
|
|
1997
|
-
*
|
|
1998
|
-
*
|
|
2062
|
+
* Performs pose detection on the provided video frame and invokes the
|
|
2063
|
+
* callback with the response. The method returns synchronously once the
|
|
2064
|
+
* callback returns. Only use this method when the PoseLandmarker is created
|
|
2065
|
+
* with running mode `video`.
|
|
1999
2066
|
*
|
|
2000
2067
|
* @param videoFrame A video frame to process.
|
|
2068
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
2001
2069
|
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
2002
2070
|
* to process the input image before running inference.
|
|
2003
|
-
* @param timestamp The timestamp of the current frame, in ms.
|
|
2004
2071
|
* @param callback The callback that is invoked with the result. The
|
|
2005
2072
|
* lifetime of the returned masks is only guaranteed for the duration of
|
|
2006
2073
|
* the callback.
|
|
2007
|
-
* @return The detected pose landmarks.
|
|
2008
2074
|
*/
|
|
2009
|
-
detectForVideo(videoFrame: ImageSource,
|
|
2075
|
+
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
|
|
2076
|
+
/**
|
|
2077
|
+
* Performs pose detection on the provided video frame and returns the result.
|
|
2078
|
+
* This method creates a copy of the resulting masks and should not be used
|
|
2079
|
+
* in high-throughput applictions. Only use this method when the
|
|
2080
|
+
* PoseLandmarker is created with running mode `video`.
|
|
2081
|
+
*
|
|
2082
|
+
* @param videoFrame A video frame to process.
|
|
2083
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
2084
|
+
* @return The landmarker result. Any masks are copied to extend the
|
|
2085
|
+
* lifetime of the returned data.
|
|
2086
|
+
*/
|
|
2087
|
+
detectForVideo(videoFrame: ImageSource, timestamp: number): PoseLandmarkerResult;
|
|
2088
|
+
/**
|
|
2089
|
+
* Performs pose detection on the provided video frame and returns the result.
|
|
2090
|
+
* This method creates a copy of the resulting masks and should not be used
|
|
2091
|
+
* in high-throughput applictions. The method returns synchronously once the
|
|
2092
|
+
* callback returns. Only use this method when the PoseLandmarker is created
|
|
2093
|
+
* with running mode `video`.
|
|
2094
|
+
*
|
|
2095
|
+
* @param videoFrame A video frame to process.
|
|
2096
|
+
* @param timestamp The timestamp of the current frame, in ms.
|
|
2097
|
+
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
|
|
2098
|
+
* to process the input image before running inference.
|
|
2099
|
+
* @return The landmarker result. Any masks are copied to extend the lifetime
|
|
2100
|
+
* of the returned data.
|
|
2101
|
+
*/
|
|
2102
|
+
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
|
|
2010
2103
|
}
|
|
2011
2104
|
|
|
2012
2105
|
/**
|
|
@@ -2049,13 +2142,11 @@ export declare interface PoseLandmarkerOptions extends VisionTaskOptions {
|
|
|
2049
2142
|
*/
|
|
2050
2143
|
export declare interface PoseLandmarkerResult {
|
|
2051
2144
|
/** Pose landmarks of detected poses. */
|
|
2052
|
-
landmarks: NormalizedLandmark[];
|
|
2145
|
+
landmarks: NormalizedLandmark[][];
|
|
2053
2146
|
/** Pose landmarks in world coordinates of detected poses. */
|
|
2054
|
-
worldLandmarks: Landmark[];
|
|
2055
|
-
/** Detected auxiliary landmarks, used for deriving ROI for next frame. */
|
|
2056
|
-
auxilaryLandmarks: NormalizedLandmark[];
|
|
2147
|
+
worldLandmarks: Landmark[][];
|
|
2057
2148
|
/** Segmentation mask for the detected pose. */
|
|
2058
|
-
segmentationMasks?:
|
|
2149
|
+
segmentationMasks?: MPMask[];
|
|
2059
2150
|
}
|
|
2060
2151
|
|
|
2061
2152
|
/**
|
|
@@ -2076,7 +2167,9 @@ declare interface RectF {
|
|
|
2076
2167
|
/** A Region-Of-Interest (ROI) to represent a region within an image. */
|
|
2077
2168
|
export declare interface RegionOfInterest {
|
|
2078
2169
|
/** The ROI in keypoint format. */
|
|
2079
|
-
keypoint
|
|
2170
|
+
keypoint?: NormalizedKeypoint;
|
|
2171
|
+
/** The ROI as scribbles over the object that the user wants to segment. */
|
|
2172
|
+
scribble?: NormalizedKeypoint[];
|
|
2080
2173
|
}
|
|
2081
2174
|
|
|
2082
2175
|
/**
|
|
@@ -2086,20 +2179,13 @@ export declare interface RegionOfInterest {
|
|
|
2086
2179
|
*/
|
|
2087
2180
|
declare type RunningMode = "IMAGE" | "VIDEO";
|
|
2088
2181
|
|
|
2089
|
-
/**
|
|
2090
|
-
* The segmentation tasks return the segmentation either as a WebGLTexture (when
|
|
2091
|
-
* the output is on GPU) or as a typed JavaScript arrays for CPU-based
|
|
2092
|
-
* category or confidence masks. `Uint8ClampedArray`s are used to represent
|
|
2093
|
-
* CPU-based category masks and `Float32Array`s are used for CPU-based
|
|
2094
|
-
* confidence masks.
|
|
2095
|
-
*/
|
|
2096
|
-
export declare type SegmentationMask = Uint8ClampedArray | Float32Array | WebGLTexture;
|
|
2097
|
-
|
|
2098
2182
|
/** Base class for all MediaPipe Tasks. */
|
|
2099
2183
|
declare abstract class TaskRunner {
|
|
2100
2184
|
protected constructor();
|
|
2101
2185
|
/** Configures the task with custom options. */
|
|
2102
2186
|
abstract setOptions(options: TaskRunnerOptions): Promise<void>;
|
|
2187
|
+
/** Closes and cleans up the resources held by this task. */
|
|
2188
|
+
close(): void;
|
|
2103
2189
|
}
|
|
2104
2190
|
|
|
2105
2191
|
/** Options to configure MediaPipe Tasks in general. */
|
|
@@ -2131,6 +2217,8 @@ declare abstract class VisionTaskRunner extends TaskRunner {
|
|
|
2131
2217
|
protected constructor();
|
|
2132
2218
|
/** Configures the shared options of a vision task. */
|
|
2133
2219
|
applyOptions(options: VisionTaskOptions): Promise<void>;
|
|
2220
|
+
/** Closes and cleans up the resources held by this task. */
|
|
2221
|
+
close(): void;
|
|
2134
2222
|
}
|
|
2135
2223
|
|
|
2136
2224
|
/**
|