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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497
|
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Options to configure MediaPipe model loading and processing. */
declare interface BaseOptions_2 {
/**
* The model path to the model asset file. Only one of `modelAssetPath` or
* `modelAssetBuffer` can be set.
*/
modelAssetPath?: string | undefined;
/**
* A buffer containing the model aaset. Only one of `modelAssetPath` or
* `modelAssetBuffer` can be set.
*/
modelAssetBuffer?: Uint8Array | undefined;
/** Overrides the default backend to use for the provided model. */
delegate?: "CPU" | "GPU" | undefined;
}
/**
* Copyright 2023 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** An integer bounding box, axis aligned. */
export declare interface BoundingBox {
/** The X coordinate of the top-left corner, in pixels. */
originX: number;
/** The Y coordinate of the top-left corner, in pixels. */
originY: number;
/** The width of the bounding box, in pixels. */
width: number;
/** The height of the bounding box, in pixels. */
height: number;
/**
* Angle of rotation of the original non-rotated box around the top left
* corner of the original non-rotated box, in clockwise degrees from the
* horizontal.
*/
angle: number;
}
/**
* A user-defined callback to take input data and map it to a custom output
* value.
*/
export declare type Callback<I, O> = (input: I) => O;
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** A classification category. */
export declare interface Category {
/** The probability score of this label category. */
score: number;
/** The index of the category in the corresponding label file. */
index: number;
/**
* The label of this category object. Defaults to an empty string if there is
* no category.
*/
categoryName: string;
/**
* The display name of the label, which may be translated for different
* locales. For example, a label, "apple", may be translated into Spanish for
* display purpose, so that the `display_name` is "manzana". Defaults to an
* empty string if there is no display name.
*/
displayName: string;
}
/**
* A category to color mapping that uses either a map or an array to assign
* category indexes to RGBA colors.
*/
export declare type CategoryToColorMap = Map<number, RGBAColor> | RGBAColor[];
/** Classification results for a given classifier head. */
export declare interface Classifications {
/**
* The array of predicted categories, usually sorted by descending scores,
* e.g., from high to low probability.
*/
categories: Category[];
/**
* The index of the classifier head these categories refer to. This is
* useful for multi-head models.
*/
headIndex: number;
/**
* The name of the classifier head, which is the corresponding tensor
* metadata name. Defaults to an empty string if there is no such metadata.
*/
headName: string;
}
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Options to configure a MediaPipe Classifier Task. */
declare interface ClassifierOptions {
/**
* The locale to use for display names specified through the TFLite Model
* Metadata, if any. Defaults to English.
*/
displayNamesLocale?: string | undefined;
/** The maximum number of top-scored detection results to return. */
maxResults?: number | undefined;
/**
* Overrides the value provided in the model metadata. Results below this
* value are rejected.
*/
scoreThreshold?: number | undefined;
/**
* Allowlist of category names. If non-empty, detection results whose category
* name is not in this set will be filtered out. Duplicate or unknown category
* names are ignored. Mutually exclusive with `categoryDenylist`.
*/
categoryAllowlist?: string[] | undefined;
/**
* Denylist of category names. If non-empty, detection results whose category
* name is in this set will be filtered out. Duplicate or unknown category
* names are ignored. Mutually exclusive with `categoryAllowlist`.
*/
categoryDenylist?: string[] | undefined;
}
/** A connection between two landmarks. */
declare interface Connection {
start: number;
end: number;
}
/** A color map with 22 classes. Used in our demos. */
export declare const DEFAULT_CATEGORY_TO_COLOR_MAP: number[][];
/** Represents one detection by a detection task. */
export declare interface Detection {
/** A list of `Category` objects. */
categories: Category[];
/** The bounding box of the detected objects. */
boundingBox?: BoundingBox;
/**
* List of keypoints associated with the detection. Keypoints represent
* interesting points related to the detection. For example, the keypoints
* represent the eye, ear and mouth from face detection model. Or in the
* template matching detection, e.g. KNIFT, they can represent the feature
* points for template matching. Contains an empty list if no keypoints are
* detected.
*/
keypoints: NormalizedKeypoint[];
}
/** Detection results of a model. */
declare interface DetectionResult {
/** A list of Detections. */
detections: Detection[];
}
export { DetectionResult as FaceDetectorResult }
export { DetectionResult as ObjectDetectorResult }
/**
* Options for customizing the drawing routines
*/
export declare interface DrawingOptions {
/** The color that is used to draw the shape. Defaults to white. */
color?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
/**
* The color that is used to fill the shape. Defaults to `.color` (or black
* if color is not set).
*/
fillColor?: string | CanvasGradient | CanvasPattern | Callback<LandmarkData, string | CanvasGradient | CanvasPattern>;
/** The width of the line boundary of the shape. Defaults to 4. */
lineWidth?: number | Callback<LandmarkData, number>;
/** The radius of location marker. Defaults to 6. */
radius?: number | Callback<LandmarkData, number>;
}
/** Helper class to visualize the result of a MediaPipe Vision task. */
export declare class DrawingUtils {
/**
* Creates a new DrawingUtils class.
*
* @param gpuContext The WebGL canvas rendering context to render into. If
* your Task is using a GPU delegate, the context must be obtained from
* its canvas (provided via `setOptions({ canvas: .. })`).
*/
constructor(gpuContext: WebGL2RenderingContext);
/**
* Creates a new DrawingUtils class.
*
* @param cpuContext The 2D canvas rendering context to render into. If
* you are rendering GPU data you must also provide `gpuContext` to allow
* for data conversion.
* @param gpuContext A WebGL canvas that is used for GPU rendering and for
* converting GPU to CPU data. If your Task is using a GPU delegate, the
* context must be obtained from its canvas (provided via
* `setOptions({ canvas: .. })`).
*/
constructor(cpuContext: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, gpuContext?: WebGL2RenderingContext);
/**
* Restricts a number between two endpoints (order doesn't matter).
*
* @export
* @param x The number to clamp.
* @param x0 The first boundary.
* @param x1 The second boundary.
* @return The clamped value.
*/
static clamp(x: number, x0: number, x1: number): number;
/**
* Linearly interpolates a value between two points, clamping that value to
* the endpoints.
*
* @export
* @param x The number to interpolate.
* @param x0 The x coordinate of the start value.
* @param x1 The x coordinate of the end value.
* @param y0 The y coordinate of the start value.
* @param y1 The y coordinate of the end value.
* @return The interpolated value.
*/
static lerp(x: number, x0: number, x1: number, y0: number, y1: number): number;
/**
* Draws circles onto the provided landmarks.
*
* This method can only be used when `DrawingUtils` is initialized with a
* `CanvasRenderingContext2D`.
*
* @export
* @param landmarks The landmarks to draw.
* @param style The style to visualize the landmarks.
*/
drawLandmarks(landmarks?: NormalizedLandmark[], style?: DrawingOptions): void;
/**
* Draws lines between landmarks (given a connection graph).
*
* This method can only be used when `DrawingUtils` is initialized with a
* `CanvasRenderingContext2D`.
*
* @export
* @param landmarks The landmarks to draw.
* @param connections The connections array that contains the start and the
* end indices for the connections to draw.
* @param style The style to visualize the landmarks.
*/
drawConnectors(landmarks?: NormalizedLandmark[], connections?: Connection[], style?: DrawingOptions): void;
/**
* Draws a bounding box.
*
* This method can only be used when `DrawingUtils` is initialized with a
* `CanvasRenderingContext2D`.
*
* @export
* @param boundingBox The bounding box to draw.
* @param style The style to visualize the boundin box.
*/
drawBoundingBox(boundingBox: BoundingBox, style?: DrawingOptions): void;
/**
* Draws a category mask using the provided category-to-color mapping.
*
* @export
* @param mask A category mask that was returned from a segmentation task.
* @param categoryToColorMap A map that maps category indices to RGBA
* values. You must specify a map entry for each category.
* @param background A color or image to use as the background. Defaults to
* black.
*/
drawCategoryMask(mask: MPMask, categoryToColorMap: Map<number, RGBAColor>, background?: RGBAColor | ImageSource): void;
/**
* Draws a category mask using the provided color array.
*
* @export
* @param mask A category mask that was returned from a segmentation task.
* @param categoryToColorMap An array that maps indices to RGBA values. The
* array's indices must correspond to the category indices of the model
* and an entry must be provided for each category.
* @param background A color or image to use as the background. Defaults to
* black.
*/
drawCategoryMask(mask: MPMask, categoryToColorMap: RGBAColor[], background?: RGBAColor | ImageSource): void;
/**
* Blends two images using the provided confidence mask.
*
* If you are using an `ImageData` or `HTMLImageElement` as your data source
* and drawing the result onto a `WebGL2RenderingContext`, this method uploads
* the image data to the GPU. For still image input that gets re-used every
* frame, you can reduce the cost of re-uploading these images by passing a
* `HTMLCanvasElement` instead.
*
* @export
* @param mask A confidence mask that was returned from a segmentation task.
* @param defaultTexture An image or a four-channel color that will be used
* when confidence values are low.
* @param overlayTexture An image or four-channel color that will be used when
* confidence values are high.
*/
drawConfidenceMask(mask: MPMask, defaultTexture: RGBAColor | ImageSource, overlayTexture: RGBAColor | ImageSource): void;
/**
* Frees all WebGL resources held by this class.
* @export
*/
close(): void;
}
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Options to configure a MediaPipe Embedder Task */
declare interface EmbedderOptions {
/**
* Whether to normalize the returned feature vector with L2 norm. Use this
* option only if the model does not already contain a native L2_NORMALIZATION
* TF Lite Op. In most cases, this is already the case and L2 norm is thus
* achieved through TF Lite inference.
*/
l2Normalize?: boolean | undefined;
/**
* Whether the returned embedding should be quantized to bytes via scalar
* quantization. Embeddings are implicitly assumed to be unit-norm and
* therefore any dimension is guaranteed to have a value in [-1.0, 1.0]. Use
* the l2_normalize option if this is not the case.
*/
quantize?: boolean | undefined;
}
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* List of embeddings with an optional timestamp.
*
* One and only one of the two 'floatEmbedding' and 'quantizedEmbedding' will
* contain data, based on whether or not the embedder was configured to perform
* scalar quantization.
*/
export declare interface Embedding {
/**
* Floating-point embedding. Empty if the embedder was configured to perform
* scalar-quantization.
*/
floatEmbedding?: number[];
/**
* Scalar-quantized embedding. Empty if the embedder was not configured to
* perform scalar quantization.
*/
quantizedEmbedding?: Uint8Array;
/**
* The index of the classifier head these categories refer to. This is
* useful for multi-head models.
*/
headIndex: number;
/**
* The name of the classifier head, which is the corresponding tensor
* metadata name.
*/
headName: string;
}
/** Performs face detection on images. */
export declare class FaceDetector extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new face detector from the
* provided options.
*
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param faceDetectorOptions The options for the FaceDetector. Note that
* either a path to the model asset or a model buffer needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, faceDetectorOptions: FaceDetectorOptions): Promise<FaceDetector>;
/**
* Initializes the Wasm runtime and creates a new face detector based on the
* provided model asset buffer.
*
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceDetector>;
/**
* Initializes the Wasm runtime and creates a new face detector based on the
* path to the model asset.
*
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceDetector>;
private constructor();
/**
* Sets new options for the FaceDetector.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the FaceDetector.
*/
setOptions(options: FaceDetectorOptions): Promise<void>;
/**
* Performs face detection on the provided single image and waits
* synchronously for the response. Only use this method when the
* FaceDetector is created with running mode `image`.
*
* @export
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return A result containing the list of detected faces.
*/
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
/**
* Performs face detection on the provided video frame and waits
* synchronously for the response. Only use this method when the
* FaceDetector is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return A result containing the list of detected faces.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
}
/** Options to configure the MediaPipe Face Detector Task */
export declare interface FaceDetectorOptions extends VisionTaskOptions {
/**
* The minimum confidence score for the face detection to be considered
* successful. Defaults to 0.5.
*/
minDetectionConfidence?: number | undefined;
/**
* The minimum non-maximum-suppression threshold for face detection to be
* considered overlapped. Defaults to 0.3.
*/
minSuppressionThreshold?: number | undefined;
}
/**
* Performs face landmarks detection on images.
*
* This API expects a pre-trained face landmarker model asset bundle.
*/
export declare class FaceLandmarker extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new `FaceLandmarker` from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param faceLandmarkerOptions The options for the FaceLandmarker.
* Note that either a path to the model asset or a model buffer needs to
* be provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, faceLandmarkerOptions: FaceLandmarkerOptions): Promise<FaceLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `FaceLandmarker` based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceLandmarker>;
/**
* Landmark connections to draw the connection between a face's lips.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_LIPS: Connection[];
/**
* Landmark connections to draw the connection between a face's left eye.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_LEFT_EYE: Connection[];
/**
* Landmark connections to draw the connection between a face's left eyebrow.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_LEFT_EYEBROW: Connection[];
/**
* Landmark connections to draw the connection between a face's left iris.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_LEFT_IRIS: Connection[];
/**
* Landmark connections to draw the connection between a face's right eye.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_RIGHT_EYE: Connection[];
/**
* Landmark connections to draw the connection between a face's right
* eyebrow.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_RIGHT_EYEBROW: Connection[];
/**
* Landmark connections to draw the connection between a face's right iris.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_RIGHT_IRIS: Connection[];
/**
* Landmark connections to draw the face's oval.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_FACE_OVAL: Connection[];
/**
* Landmark connections to draw the face's contour.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_CONTOURS: Connection[];
/**
* Landmark connections to draw the face's tesselation.
* @export
* @nocollapse
*/
static FACE_LANDMARKS_TESSELATION: Connection[];
private constructor();
/**
* Sets new options for this `FaceLandmarker`.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the face landmarker.
*/
setOptions(options: FaceLandmarkerOptions): Promise<void>;
/**
* Performs face landmarks detection on the provided single image and waits
* synchronously for the response. Only use this method when the
* FaceLandmarker is created with running mode `image`.
*
* @export
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected face landmarks.
*/
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
/**
* Performs face landmarks detection on the provided video frame and waits
* synchronously for the response. Only use this method when the
* FaceLandmarker is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected face landmarks.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): FaceLandmarkerResult;
}
/** Options to configure the MediaPipe FaceLandmarker Task */
export declare interface FaceLandmarkerOptions extends VisionTaskOptions {
/**
* The maximum number of faces can be detected by the FaceLandmarker.
* Defaults to 1.
*/
numFaces?: number | undefined;
/**
* The minimum confidence score for the face detection to be considered
* successful. Defaults to 0.5.
*/
minFaceDetectionConfidence?: number | undefined;
/**
* The minimum confidence score of face presence score in the face landmark
* detection. Defaults to 0.5.
*/
minFacePresenceConfidence?: number | undefined;
/**
* The minimum confidence score for the face tracking to be considered
* successful. Defaults to 0.5.
*/
minTrackingConfidence?: number | undefined;
/**
* Whether FaceLandmarker outputs face blendshapes classification. Face
* blendshapes are used for rendering the 3D face model.
*/
outputFaceBlendshapes?: boolean | undefined;
/**
* Whether FaceLandmarker outputs facial transformation_matrix. Facial
* transformation matrix is used to transform the face landmarks in canonical
* face to the detected face, so that users can apply face effects on the
* detected landmarks.
*/
outputFacialTransformationMatrixes?: boolean | undefined;
}
/**
* Represents the face landmarks deection results generated by `FaceLandmarker`.
*/
export declare interface FaceLandmarkerResult {
/** Detected face landmarks in normalized image coordinates. */
faceLandmarks: NormalizedLandmark[][];
/** Optional face blendshapes results. */
faceBlendshapes: Classifications[];
/** Optional facial transformation matrix. */
facialTransformationMatrixes: Matrix[];
}
/** Performs face stylization on images. */
export declare class FaceStylizer extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new Face Stylizer from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param faceStylizerOptions The options for the Face Stylizer. Note
* that either a path to the model asset or a model buffer needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, faceStylizerOptions: FaceStylizerOptions): Promise<FaceStylizer>;
/**
* Initializes the Wasm runtime and creates a new Face Stylizer based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceStylizer>;
/**
* Initializes the Wasm runtime and creates a new Face Stylizer based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceStylizer>;
private constructor();
/**
* Sets new options for the Face Stylizer.
*
* Calling `setOptions()` with a subset of options only affects those
* options. You can reset an option back to its default value by
* explicitly setting it to `undefined`.
*
* @export
* @param options The options for the Face Stylizer.
*/
setOptions(options: FaceStylizerOptions): Promise<void>;
/**
* Performs face stylization on the provided single image and invokes the
* callback with result. The method returns synchronously once the callback
* returns. Only use this method when the FaceStylizer is created with the
* image running mode.
*
* @param image An image to process.
* @param callback The callback that is invoked with the stylized image or
* `null` if no face was detected. The lifetime of the returned data is
* only guaranteed for the duration of the callback.
*/
stylize(image: ImageSource, callback: FaceStylizerCallback): void;
/**
* Performs face stylization on the provided single image and invokes the
* callback with result. The method returns synchronously once the callback
* returns. Only use this method when the FaceStylizer is created with the
* image running mode.
*
* The 'imageProcessingOptions' parameter can be used to specify one or all
* of:
* - the rotation to apply to the image before performing stylization, by
* setting its 'rotationDegrees' property.
* - the region-of-interest on which to perform stylization, by setting its
* 'regionOfInterest' property. If not specified, the full image is used.
* If both are specified, the crop around the region-of-interest is extracted
* first, then the specified rotation is applied to the crop.
*
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @param callback The callback that is invoked with the stylized image or
* `null` if no face was detected. The lifetime of the returned data is
* only guaranteed for the duration of the callback.
*/
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
/**
* Performs face stylization on the provided single image and returns the
* result. This method creates a copy of the resulting image and should not be
* used in high-throughput applications. Only use this method when the
* FaceStylizer is created with the image running mode.
*
* @param image An image to process.
* @return A stylized face or `null` if no face was detected. The result is
* copied to avoid lifetime issues.
*/
stylize(image: ImageSource): MPImage | null;
/**
* Performs face stylization on the provided single image and returns the
* result. This method creates a copy of the resulting image and should not be
* used in high-throughput applications. Only use this method when the
* FaceStylizer is created with the image running mode.
*
* The 'imageProcessingOptions' parameter can be used to specify one or all
* of:
* - the rotation to apply to the image before performing stylization, by
* setting its 'rotationDegrees' property.
* - the region-of-interest on which to perform stylization, by setting its
* 'regionOfInterest' property. If not specified, the full image is used.
* If both are specified, the crop around the region-of-interest is extracted
* first, then the specified rotation is applied to the crop.
*
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return A stylized face or `null` if no face was detected. The result is
* copied to avoid lifetime issues.
*/
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
}
/**
* A callback that receives an `MPImage` object from the face stylizer, or
* `null` if no face was detected. The lifetime of the underlying data is
* limited to the duration of the callback. If asynchronous processing is
* needed, all data needs to be copied before the callback returns (via
* `image.clone()`).
*/
export declare type FaceStylizerCallback = (image: MPImage | null) => void;
/** Options to configure the MediaPipe Face Stylizer Task */
export declare interface FaceStylizerOptions extends VisionTaskOptions {
}
/**
* Resolves the files required for the MediaPipe Task APIs.
*
* This class verifies whether SIMD is supported in the current environment and
* loads the SIMD files only if support is detected. The returned filesets
* require that the Wasm files are published without renaming. If this is not
* possible, you can invoke the MediaPipe Tasks APIs using a manually created
* `WasmFileset`.
*/
export declare class FilesetResolver {
/**
* Returns whether SIMD is supported in the current environment.
*
* If your environment requires custom locations for the MediaPipe Wasm files,
* you can use `isSimdSupported()` to decide whether to load the SIMD-based
* assets.
*
* @export
* @return Whether SIMD support was detected in the current environment.
*/
static isSimdSupported(): Promise<boolean>;
/**
* Creates a fileset for the MediaPipe Audio tasks.
*
* @export
* @param basePath An optional base path to specify the directory the Wasm
* files should be loaded from. If not specified, the Wasm files are
* loaded from the host's root directory.
* @return A `WasmFileset` that can be used to initialize MediaPipe Audio
* tasks.
*/
static forAudioTasks(basePath?: string): Promise<WasmFileset>;
/**
* Creates a fileset for the MediaPipe Text tasks.
*
* @export
* @param basePath An optional base path to specify the directory the Wasm
* files should be loaded from. If not specified, the Wasm files are
* loaded from the host's root directory.
* @return A `WasmFileset` that can be used to initialize MediaPipe Text
* tasks.
*/
static forTextTasks(basePath?: string): Promise<WasmFileset>;
/**
* Creates a fileset for the MediaPipe Vision tasks.
*
* @export
* @param basePath An optional base path to specify the directory the Wasm
* files should be loaded from. If not specified, the Wasm files are
* loaded from the host's root directory.
* @return A `WasmFileset` that can be used to initialize MediaPipe Vision
* tasks.
*/
static forVisionTasks(basePath?: string): Promise<WasmFileset>;
}
/** Performs hand gesture recognition on images. */
export declare class GestureRecognizer extends VisionTaskRunner {
/**
* An array containing the pairs of hand landmark indices to be rendered with
* connections.
* @export
* @nocollapse
*/
static HAND_CONNECTIONS: Connection[];
/**
* Initializes the Wasm runtime and creates a new gesture recognizer from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param gestureRecognizerOptions The options for the gesture recognizer.
* Note that either a path to the model asset or a model buffer needs to
* be provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, gestureRecognizerOptions: GestureRecognizerOptions): Promise<GestureRecognizer>;
/**
* Initializes the Wasm runtime and creates a new gesture recognizer based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<GestureRecognizer>;
/**
* Initializes the Wasm runtime and creates a new gesture recognizer based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<GestureRecognizer>;
private constructor();
/**
* Sets new options for the gesture recognizer.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the gesture recognizer.
*/
setOptions(options: GestureRecognizerOptions): Promise<void>;
/**
* Performs gesture recognition on the provided single image and waits
* synchronously for the response. Only use this method when the
* GestureRecognizer is created with running mode `image`.
*
* @export
* @param image A single image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected gestures.
*/
recognize(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): GestureRecognizerResult;
/**
* Performs gesture recognition on the provided video frame and waits
* synchronously for the response. Only use this method when the
* GestureRecognizer is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected gestures.
*/
recognizeForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): GestureRecognizerResult;
}
/** Options to configure the MediaPipe Gesture Recognizer Task */
export declare interface GestureRecognizerOptions extends VisionTaskOptions {
/**
* The maximum number of hands can be detected by the GestureRecognizer.
* Defaults to 1.
*/
numHands?: number | undefined;
/**
* The minimum confidence score for the hand detection to be considered
* successful. Defaults to 0.5.
*/
minHandDetectionConfidence?: number | undefined;
/**
* The minimum confidence score of hand presence score in the hand landmark
* detection. Defaults to 0.5.
*/
minHandPresenceConfidence?: number | undefined;
/**
* The minimum confidence score for the hand tracking to be considered
* successful. Defaults to 0.5.
*/
minTrackingConfidence?: number | undefined;
/**
* Sets the optional `ClassifierOptions` controlling the canned gestures
* classifier, such as score threshold, allow list and deny list of gestures.
* The categories for canned gesture
* classifiers are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up",
* "Thumb_Down", "Thumb_Up", "Victory", "ILoveYou"]
*/
cannedGesturesClassifierOptions?: ClassifierOptions | undefined;
/**
* Options for configuring the custom gestures classifier, such as score
* threshold, allow list and deny list of gestures.
*/
customGesturesClassifierOptions?: ClassifierOptions | undefined;
}
/**
* Represents the gesture recognition results generated by `GestureRecognizer`.
*/
export declare interface GestureRecognizerResult {
/** Hand landmarks of detected hands. */
landmarks: NormalizedLandmark[][];
/** Hand landmarks in world coordinates of detected hands. */
worldLandmarks: Landmark[][];
/** Handedness of detected hands. */
handedness: Category[][];
/**
* Handedness of detected hands.
* @deprecated Use `.handedness` instead.
*/
handednesses: Category[][];
/**
* Recognized hand gestures of detected hands. Note that the index of the
* gesture is always -1, because the raw indices from multiple gesture
* classifiers cannot consolidate to a meaningful index.
*/
gestures: Category[][];
}
/** Performs hand landmarks detection on images. */
export declare class HandLandmarker extends VisionTaskRunner {
/**
* An array containing the pairs of hand landmark indices to be rendered with
* connections.
* @export
* @nocollapse
*/
static HAND_CONNECTIONS: Connection[];
/**
* Initializes the Wasm runtime and creates a new `HandLandmarker` from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param handLandmarkerOptions The options for the HandLandmarker.
* Note that either a path to the model asset or a model buffer needs to
* be provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, handLandmarkerOptions: HandLandmarkerOptions): Promise<HandLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `HandLandmarker` based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<HandLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `HandLandmarker` based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<HandLandmarker>;
private constructor();
/**
* Sets new options for this `HandLandmarker`.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the hand landmarker.
*/
setOptions(options: HandLandmarkerOptions): Promise<void>;
/**
* Performs hand landmarks detection on the provided single image and waits
* synchronously for the response. Only use this method when the
* HandLandmarker is created with running mode `image`.
*
* @export
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected hand landmarks.
*/
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): HandLandmarkerResult;
/**
* Performs hand landmarks detection on the provided video frame and waits
* synchronously for the response. Only use this method when the
* HandLandmarker is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The detected hand landmarks.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): HandLandmarkerResult;
}
/** Options to configure the MediaPipe HandLandmarker Task */
export declare interface HandLandmarkerOptions extends VisionTaskOptions {
/**
* The maximum number of hands can be detected by the HandLandmarker.
* Defaults to 1.
*/
numHands?: number | undefined;
/**
* The minimum confidence score for the hand detection to be considered
* successful. Defaults to 0.5.
*/
minHandDetectionConfidence?: number | undefined;
/**
* The minimum confidence score of hand presence score in the hand landmark
* detection. Defaults to 0.5.
*/
minHandPresenceConfidence?: number | undefined;
/**
* The minimum confidence score for the hand tracking to be considered
* successful. Defaults to 0.5.
*/
minTrackingConfidence?: number | undefined;
}
/**
* Represents the hand landmarks deection results generated by `HandLandmarker`.
*/
export declare interface HandLandmarkerResult {
/** Hand landmarks of detected hands. */
landmarks: NormalizedLandmark[][];
/** Hand landmarks in world coordinates of detected hands. */
worldLandmarks: Landmark[][];
/**
* Handedness of detected hands.
* @deprecated Use `.handedness` instead.
*/
handednesses: Category[][];
/** Handedness of detected hands. */
handedness: Category[][];
}
/** Performs classification on images. */
export declare class ImageClassifier extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new image classifier from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location
* Wasm binary and its loader.
* @param imageClassifierOptions The options for the image classifier. Note
* that either a path to the model asset or a model buffer needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, imageClassifierOptions: ImageClassifierOptions): Promise<ImageClassifier>;
/**
* Initializes the Wasm runtime and creates a new image classifier based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageClassifier>;
/**
* Initializes the Wasm runtime and creates a new image classifier based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageClassifier>;
private constructor();
/**
* Sets new options for the image classifier.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the image classifier.
*/
setOptions(options: ImageClassifierOptions): Promise<void>;
/**
* Performs image classification on the provided single image and waits
* synchronously for the response. Only use this method when the
* ImageClassifier is created with running mode `image`.
*
* @export
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The classification result of the image
*/
classify(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): ImageClassifierResult;
/**
* Performs image classification on the provided video frame and waits
* synchronously for the response. Only use this method when the
* ImageClassifier is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The classification result of the image
*/
classifyForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): ImageClassifierResult;
}
/** Options to configure the MediaPipe Image Classifier Task. */
export declare interface ImageClassifierOptions extends ClassifierOptions, VisionTaskOptions {
}
/** Classification results of a model. */
export declare interface ImageClassifierResult {
/** The classification results for each head of the model. */
classifications: Classifications[];
/**
* The optional timestamp (in milliseconds) of the start of the chunk of data
* corresponding to these results.
*
* This is only used for classification on time series (e.g. audio
* classification). In these use cases, the amount of data to process might
* exceed the maximum size that the model can process: to solve this, the
* input data is split into multiple chunks starting at different timestamps.
*/
timestampMs?: number;
}
/** Performs embedding extraction on images. */
export declare class ImageEmbedder extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new image embedder from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param imageEmbedderOptions The options for the image embedder. Note that
* either a path to the TFLite model or the model itself needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, imageEmbedderOptions: ImageEmbedderOptions): Promise<ImageEmbedder>;
/**
* Initializes the Wasm runtime and creates a new image embedder based on the
* provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the TFLite model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageEmbedder>;
/**
* Initializes the Wasm runtime and creates a new image embedder based on the
* path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the TFLite model.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageEmbedder>;
private constructor();
/**
* Sets new options for the image embedder.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the image embedder.
*/
setOptions(options: ImageEmbedderOptions): Promise<void>;
/**
* Performs embedding extraction on the provided single image and waits
* synchronously for the response. Only use this method when the
* ImageEmbedder is created with running mode `image`.
*
* @export
* @param image The image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The classification result of the image
*/
embed(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
/**
* Performs embedding extraction on the provided video frame and waits
* synchronously for the response. Only use this method when the
* ImageEmbedder is created with running mode `video`.
*
* @export
* @param imageFrame The image frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The classification result of the image
*/
embedForVideo(imageFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
/**
* Utility function to compute cosine similarity[1] between two `Embedding`
* objects.
*
* [1]: https://en.wikipedia.org/wiki/Cosine_similarity
*
* @export
* @throws if the embeddings are of different types(float vs. quantized), have
* different sizes, or have an L2-norm of 0.
*/
static cosineSimilarity(u: Embedding, v: Embedding): number;
}
/** Options for configuring a MediaPipe Image Embedder task. */
export declare interface ImageEmbedderOptions extends EmbedderOptions, VisionTaskOptions {
}
/** Embedding results for a given embedder model. */
export declare interface ImageEmbedderResult {
/**
* The embedding results for each model head, i.e. one for each output tensor.
*/
embeddings: Embedding[];
/**
* The optional timestamp (in milliseconds) of the start of the chunk of
* data corresponding to these results.
*
* This is only used for embedding extraction on time series (e.g. audio
* embedding). In these use cases, the amount of data to process might
* exceed the maximum size that the model can process: to solve this, the
* input data is split into multiple chunks starting at different timestamps.
*/
timestampMs?: number;
}
/**
* Options for image processing.
*
* If both region-or-interest and rotation are specified, the crop around the
* region-of-interest is extracted first, then the specified rotation is applied
* to the crop.
*/
declare interface ImageProcessingOptions {
/**
* The optional region-of-interest to crop from the image. If not specified,
* the full image is used.
*
* Coordinates must be in [0,1] with 'left' < 'right' and 'top' < bottom.
*/
regionOfInterest?: RectF;
/**
* The rotation to apply to the image (or cropped region-of-interest), in
* degrees clockwise.
*
* The rotation must be a multiple (positive or negative) of 90°.
*/
rotationDegrees?: number;
}
/** Performs image segmentation on images. */
export declare class ImageSegmenter extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new image segmenter from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param imageSegmenterOptions The options for the Image Segmenter. Note
* that either a path to the model asset or a model buffer needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, imageSegmenterOptions: ImageSegmenterOptions): Promise<ImageSegmenter>;
/**
* Initializes the Wasm runtime and creates a new image segmenter based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ImageSegmenter>;
/**
* Initializes the Wasm runtime and creates a new image segmenter based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageSegmenter>;
private constructor();
/**
* Sets new options for the image segmenter.
*
* Calling `setOptions()` with a subset of options only affects those
* options. You can reset an option back to its default value by
* explicitly setting it to `undefined`.
*
* @export
* @param options The options for the image segmenter.
*/
setOptions(options: ImageSegmenterOptions): Promise<void>;
/**
* Performs image segmentation on the provided single image and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the ImageSegmenter is
* created with running mode `image`.
*
* @param image An image to process.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segment(image: ImageSource, callback: ImageSegmenterCallback): void;
/**
* Performs image segmentation on the provided single image and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the ImageSegmenter is
* created with running mode `image`.
*
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
/**
* Performs image segmentation on the provided single image and returns the
* segmentation result. This method creates a copy of the resulting masks and
* should not be used in high-throughput applications. Only use this method
* when the ImageSegmenter is created with running mode `image`.
*
* @param image An image to process.
* @return The segmentation result. The data is copied to avoid lifetime
* issues.
*/
segment(image: ImageSource): ImageSegmenterResult;
/**
* Performs image segmentation on the provided single image and returns the
* segmentation result. This method creates a copy of the resulting masks and
* should not be used in high-v applications. Only use this method when
* the ImageSegmenter is created with running mode `image`.
*
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The segmentation result. The data is copied to avoid lifetime
* issues.
*/
segment(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
/**
* Performs image segmentation on the provided video frame and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the ImageSegmenter is
* created with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segmentForVideo(videoFrame: ImageSource, timestamp: number, callback: ImageSegmenterCallback): void;
/**
* Performs image segmentation on the provided video frame and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the ImageSegmenter is
* created with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input frame before running inference.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: ImageSegmenterCallback): void;
/**
* Performs image segmentation on the provided video frame and returns the
* segmentation result. This method creates a copy of the resulting masks and
* should not be used in high-throughput applications. Only use this method
* when the ImageSegmenter is created with running mode `video`.
*
* @param videoFrame A video frame to process.
* @return The segmentation result. The data is copied to avoid lifetime
* issues.
*/
segmentForVideo(videoFrame: ImageSource, timestamp: number): ImageSegmenterResult;
/**
* Performs image segmentation on the provided video frame and returns the
* segmentation result. This method creates a copy of the resulting masks and
* should not be used in high-v applications. Only use this method when
* the ImageSegmenter is created with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input frame before running inference.
* @return The segmentation result. The data is copied to avoid lifetime
* issues.
*/
segmentForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): ImageSegmenterResult;
/**
* Get the category label list of the ImageSegmenter can recognize. For
* `CATEGORY_MASK` type, the index in the category mask corresponds to the
* category in the label list. For `CONFIDENCE_MASK` type, the output mask
* list at index corresponds to the category in the label list.
*
* If there is no labelmap provided in the model file, empty label array is
* returned.
*
* @export
* @return The labels used by the current model.
*/
getLabels(): string[];
}
/**
* A callback that receives the computed masks from the image segmenter. The
* returned data is only valid for the duration of the callback. If
* asynchronous processing is needed, all data needs to be copied before the
* callback returns.
*/
export declare type ImageSegmenterCallback = (result: ImageSegmenterResult) => void;
/** Options to configure the MediaPipe Image Segmenter Task */
export declare interface ImageSegmenterOptions extends VisionTaskOptions {
/**
* The locale to use for display names specified through the TFLite Model
* Metadata, if any. Defaults to English.
*/
displayNamesLocale?: string | undefined;
/** Whether to output confidence masks. Defaults to true. */
outputConfidenceMasks?: boolean | undefined;
/** Whether to output the category masks. Defaults to false. */
outputCategoryMask?: boolean | undefined;
}
/** The output result of ImageSegmenter. */
export declare class ImageSegmenterResult {
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
* @export
*/
readonly confidenceMasks?: MPMask[] | undefined;
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
* which the pixel in the original image was predicted to belong to.
* @export
*/
readonly categoryMask?: MPMask | undefined;
/**
* The quality scores of the result masks, in the range of [0, 1].
* Defaults to `1` if the model doesn't output quality scores. Each
* element corresponds to the score of the category in the model outputs.
* @export
*/
readonly qualityScores?: number[] | undefined;
constructor(
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
* @export
*/
confidenceMasks?: MPMask[] | undefined,
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
* which the pixel in the original image was predicted to belong to.
* @export
*/
categoryMask?: MPMask | undefined,
/**
* The quality scores of the result masks, in the range of [0, 1].
* Defaults to `1` if the model doesn't output quality scores. Each
* element corresponds to the score of the category in the model outputs.
* @export
*/
qualityScores?: number[] | undefined);
/**
* Frees the resources held by the category and confidence masks.
* @export
*/
close(): void;
}
/**
* Valid types of image sources which we can run our GraphRunner over.
*/
export declare type ImageSource = HTMLCanvasElement | HTMLVideoElement | HTMLImageElement | ImageData | ImageBitmap;
/**
* Performs interactive segmentation on images.
*
* Users can represent user interaction through `RegionOfInterest`, which gives
* a hint to InteractiveSegmenter to perform segmentation focusing on the given
* region of interest.
*
* The API expects a TFLite model with mandatory TFLite Model Metadata.
*
* Input tensor:
* (kTfLiteUInt8/kTfLiteFloat32)
* - image input of size `[batch x height x width x channels]`.
* - batch inference is not supported (`batch` is required to be 1).
* - RGB inputs is supported (`channels` is required to be 3).
* - if type is kTfLiteFloat32, NormalizationOptions are required to be
* attached to the metadata for input normalization.
* Output tensors:
* (kTfLiteUInt8/kTfLiteFloat32)
* - list of segmented masks.
* - if `output_type` is CATEGORY_MASK, uint8 Image, Image vector of size 1.
* - if `output_type` is CONFIDENCE_MASK, float32 Image list of size
* `channels`.
* - batch is always 1
*/
export declare class InteractiveSegmenter extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new interactive segmenter from
* the provided options.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param interactiveSegmenterOptions The options for the Interactive
* Segmenter. Note that either a path to the model asset or a model buffer
* needs to be provided (via `baseOptions`).
* @return A new `InteractiveSegmenter`.
*/
static createFromOptions(wasmFileset: WasmFileset, interactiveSegmenterOptions: InteractiveSegmenterOptions): Promise<InteractiveSegmenter>;
/**
* Initializes the Wasm runtime and creates a new interactive segmenter based
* on the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
* @return A new `InteractiveSegmenter`.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<InteractiveSegmenter>;
/**
* Initializes the Wasm runtime and creates a new interactive segmenter based
* on the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of
* the Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
* @return A new `InteractiveSegmenter`.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<InteractiveSegmenter>;
private constructor();
/**
* Sets new options for the interactive segmenter.
*
* Calling `setOptions()` with a subset of options only affects those
* options. You can reset an option back to its default value by
* explicitly setting it to `undefined`.
*
* @export
* @param options The options for the interactive segmenter.
* @return A Promise that resolves when the settings have been applied.
*/
setOptions(options: InteractiveSegmenterOptions): Promise<void>;
/**
* Performs interactive segmentation on the provided single image and invokes
* the callback with the response. The method returns synchronously once the
* callback returns. The `roi` parameter is used to represent a user's region
* of interest for segmentation.
*
* @param image An image to process.
* @param roi The region of interest for segmentation.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segment(image: ImageSource, roi: RegionOfInterest, callback: InteractiveSegmenterCallback): void;
/**
* Performs interactive segmentation on the provided single image and invokes
* the callback with the response. The method returns synchronously once the
* callback returns. The `roi` parameter is used to represent a user's region
* of interest for segmentation.
*
* The 'image_processing_options' parameter can be used to specify the
* rotation to apply to the image before performing segmentation, by setting
* its 'rotationDegrees' field. Note that specifying a region-of-interest
* using the 'regionOfInterest' field is NOT supported and will result in an
* error.
*
* @param image An image to process.
* @param roi The region of interest for segmentation.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @param callback The callback that is invoked with the segmented masks. The
* lifetime of the returned data is only guaranteed for the duration of the
* callback.
*/
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions, callback: InteractiveSegmenterCallback): void;
/**
* Performs interactive segmentation on the provided video frame and returns
* the segmentation result. This method creates a copy of the resulting masks
* and should not be used in high-throughput applications. The `roi` parameter
* is used to represent a user's region of interest for segmentation.
*
* @param image An image to process.
* @param roi The region of interest for segmentation.
* @return The segmentation result. The data is copied to avoid lifetime
* limits.
*/
segment(image: ImageSource, roi: RegionOfInterest): InteractiveSegmenterResult;
/**
* Performs interactive segmentation on the provided video frame and returns
* the segmentation result. This method creates a copy of the resulting masks
* and should not be used in high-throughput applications. The `roi` parameter
* is used to represent a user's region of interest for segmentation.
*
* The 'image_processing_options' parameter can be used to specify the
* rotation to apply to the image before performing segmentation, by setting
* its 'rotationDegrees' field. Note that specifying a region-of-interest
* using the 'regionOfInterest' field is NOT supported and will result in an
* error.
*
* @param image An image to process.
* @param roi The region of interest for segmentation.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The segmentation result. The data is copied to avoid lifetime
* limits.
*/
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions): InteractiveSegmenterResult;
}
/**
* A callback that receives the computed masks from the interactive segmenter.
* The returned data is only valid for the duration of the callback. If
* asynchronous processing is needed, all data needs to be copied before the
* callback returns.
*/
export declare type InteractiveSegmenterCallback = (result: InteractiveSegmenterResult) => void;
/** Options to configure the MediaPipe Interactive Segmenter Task */
export declare interface InteractiveSegmenterOptions extends TaskRunnerOptions {
/** Whether to output confidence masks. Defaults to true. */
outputConfidenceMasks?: boolean | undefined;
/** Whether to output the category masks. Defaults to false. */
outputCategoryMask?: boolean | undefined;
}
/** The output result of InteractiveSegmenter. */
export declare class InteractiveSegmenterResult {
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
* @export
*/
readonly confidenceMasks?: MPMask[] | undefined;
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
* which the pixel in the original image was predicted to belong to.
* @export
*/
readonly categoryMask?: MPMask | undefined;
/**
* The quality scores of the result masks, in the range of [0, 1].
* Defaults to `1` if the model doesn't output quality scores. Each
* element corresponds to the score of the category in the model outputs.
* @export
*/
readonly qualityScores?: number[] | undefined;
constructor(
/**
* Multiple masks represented as `Float32Array` or `WebGLTexture`-backed
* `MPImage`s where, for each mask, each pixel represents the prediction
* confidence, usually in the [0, 1] range.
* @export
*/
confidenceMasks?: MPMask[] | undefined,
/**
* A category mask represented as a `Uint8ClampedArray` or
* `WebGLTexture`-backed `MPImage` where each pixel represents the class
* which the pixel in the original image was predicted to belong to.
* @export
*/
categoryMask?: MPMask | undefined,
/**
* The quality scores of the result masks, in the range of [0, 1].
* Defaults to `1` if the model doesn't output quality scores. Each
* element corresponds to the score of the category in the model outputs.
* @export
*/
qualityScores?: number[] | undefined);
/**
* Frees the resources held by the category and confidence masks.
* @export
*/
close(): void;
}
/**
* Landmark represents a point in 3D space with x, y, z coordinates. The
* landmark coordinates are in meters. z represents the landmark depth,
* and the smaller the value the closer the world landmark is to the camera.
*/
export declare interface Landmark {
/** The x coordinates of the landmark. */
x: number;
/** The y coordinates of the landmark. */
y: number;
/** The z coordinates of the landmark. */
z: number;
}
/** Data that a user can use to specialize drawing options. */
export declare interface LandmarkData {
index?: number;
from?: NormalizedLandmark;
to?: NormalizedLandmark;
}
/**
* Copyright 2023 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** A two-dimensional matrix. */
declare interface Matrix {
/** The number of rows. */
rows: number;
/** The number of columns. */
columns: number;
/** The values as a flattened one-dimensional array. */
data: number[];
}
/**
* The wrapper class for MediaPipe Image objects.
*
* Images are stored as `ImageData`, `ImageBitmap` or `WebGLTexture` objects.
* You can convert the underlying type to any other type by passing the
* desired type to `getAs...()`. As type conversions can be expensive, it is
* recommended to limit these conversions. You can verify what underlying
* types are already available by invoking `has...()`.
*
* Images that are returned from a MediaPipe Tasks are owned by by the
* underlying C++ Task. If you need to extend the lifetime of these objects,
* you can invoke the `clone()` method. To free up the resources obtained
* during any clone or type conversion operation, it is important to invoke
* `close()` on the `MPImage` instance.
*
* Converting to and from ImageBitmap requires that the MediaPipe task is
* initialized with an `OffscreenCanvas`. As we require WebGL2 support, this
* places some limitations on Browser support as outlined here:
* https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
*/
export declare class MPImage {
/** Returns the canvas element that the image is bound to. */
readonly canvas: HTMLCanvasElement | OffscreenCanvas | undefined;
/** Returns the width of the image. */
readonly width: number;
/** Returns the height of the image. */
readonly height: number;
private constructor();
/**
* Returns whether this `MPImage` contains a mask of type `ImageData`.
* @export
*/
hasImageData(): boolean;
/**
* Returns whether this `MPImage` contains a mask of type `ImageBitmap`.
* @export
*/
hasImageBitmap(): boolean;
/**
* Returns whether this `MPImage` contains a mask of type `WebGLTexture`.
* @export
*/
hasWebGLTexture(): boolean;
/**
* Returns the underlying image as an `ImageData` object. Note that this
* involves an expensive GPU to CPU transfer if the current image is only
* available as an `ImageBitmap` or `WebGLTexture`.
*
* @export
* @return The current image as an ImageData object.
*/
getAsImageData(): ImageData;
/**
* Returns the underlying image as an `ImageBitmap`. Note that
* conversions to `ImageBitmap` are expensive, especially if the data
* currently resides on CPU.
*
* Processing with `ImageBitmap`s requires that the MediaPipe Task was
* initialized with an `OffscreenCanvas` with WebGL2 support. See
* https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
* for a list of supported platforms.
*
* @export
* @return The current image as an ImageBitmap object.
*/
getAsImageBitmap(): ImageBitmap;
/**
* Returns the underlying image as a `WebGLTexture` object. Note that this
* involves a CPU to GPU transfer if the current image is only available as
* an `ImageData` object. The returned texture is bound to the current
* canvas (see `.canvas`).
*
* @export
* @return The current image as a WebGLTexture.
*/
getAsWebGLTexture(): WebGLTexture;
/**
* Creates a copy of the resources stored in this `MPImage`. You can invoke
* this method to extend the lifetime of an image returned by a MediaPipe
* Task. Note that performance critical applications should aim to only use
* the `MPImage` within the MediaPipe Task callback so that copies can be
* avoided.
*
* @export
*/
clone(): MPImage;
/**
* Frees up any resources owned by this `MPImage` instance.
*
* Note that this method does not free images that are owned by the C++
* Task, as these are freed automatically once you leave the MediaPipe
* callback. Additionally, some shared state is freed only once you invoke the
* Task's `close()` method.
*
* @export
*/
close(): void;
}
/**
* The wrapper class for MediaPipe segmentation masks.
*
* Masks are stored as `Uint8Array`, `Float32Array` or `WebGLTexture` objects.
* You can convert the underlying type to any other type by passing the desired
* type to `getAs...()`. As type conversions can be expensive, it is recommended
* to limit these conversions. You can verify what underlying types are already
* available by invoking `has...()`.
*
* Masks that are returned from a MediaPipe Tasks are owned by by the
* underlying C++ Task. If you need to extend the lifetime of these objects,
* you can invoke the `clone()` method. To free up the resources obtained
* during any clone or type conversion operation, it is important to invoke
* `close()` on the `MPMask` instance.
*/
export declare class MPMask {
readonly interpolateValues: boolean;
/** Returns the canvas element that the mask is bound to. */
readonly canvas: HTMLCanvasElement | OffscreenCanvas | undefined;
/** Returns the width of the mask. */
readonly width: number;
/** Returns the height of the mask. */
readonly height: number;
private constructor();
/**
* Returns whether this `MPMask` contains a mask of type `Uint8Array`.
* @export
*/
hasUint8Array(): boolean;
/**
* Returns whether this `MPMask` contains a mask of type `Float32Array`.
* @export
*/
hasFloat32Array(): boolean;
/**
* Returns whether this `MPMask` contains a mask of type `WebGLTexture`.
* @export
*/
hasWebGLTexture(): boolean;
/**
* Returns the underlying mask as a Uint8Array`. Note that this involves an
* expensive GPU to CPU transfer if the current mask is only available as a
* `WebGLTexture`.
*
* @export
* @return The current data as a Uint8Array.
*/
getAsUint8Array(): Uint8Array;
/**
* Returns the underlying mask as a single channel `Float32Array`. Note that
* this involves an expensive GPU to CPU transfer if the current mask is
* only available as a `WebGLTexture`.
*
* @export
* @return The current mask as a Float32Array.
*/
getAsFloat32Array(): Float32Array;
/**
* Returns the underlying mask as a `WebGLTexture` object. Note that this
* involves a CPU to GPU transfer if the current mask is only available as
* a CPU array. The returned texture is bound to the current canvas (see
* `.canvas`).
*
* @export
* @return The current mask as a WebGLTexture.
*/
getAsWebGLTexture(): WebGLTexture;
/**
* Creates a copy of the resources stored in this `MPMask`. You can
* invoke this method to extend the lifetime of a mask returned by a
* MediaPipe Task. Note that performance critical applications should aim to
* only use the `MPMask` within the MediaPipe Task callback so that
* copies can be avoided.
*
* @export
*/
clone(): MPMask;
/**
* Frees up any resources owned by this `MPMask` instance.
*
* Note that this method does not free masks that are owned by the C++
* Task, as these are freed automatically once you leave the MediaPipe
* callback. Additionally, some shared state is freed only once you invoke
* the Task's `close()` method.
*
* @export
*/
close(): void;
}
/**
* Copyright 2023 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A keypoint, defined by the coordinates (x, y), normalized by the image
* dimensions.
*/
declare interface NormalizedKeypoint {
/** X in normalized image coordinates. */
x: number;
/** Y in normalized image coordinates. */
y: number;
/** Optional label of the keypoint. */
label?: string;
/** Optional score of the keypoint. */
score?: number;
}
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Normalized Landmark represents a point in 3D space with x, y, z coordinates.
* x and y are normalized to [0.0, 1.0] by the image width and height
* respectively. z represents the landmark depth, and the smaller the value the
* closer the landmark is to the camera. The magnitude of z uses roughly the
* same scale as x.
*/
export declare interface NormalizedLandmark {
/** The x coordinates of the normalized landmark. */
x: number;
/** The y coordinates of the normalized landmark. */
y: number;
/** The z coordinates of the normalized landmark. */
z: number;
}
/**
* Performs object detection on images.
*/
export declare class ObjectDetector extends VisionTaskRunner {
/**
* Initializes the Wasm runtime and creates a new object detector from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param objectDetectorOptions The options for the Object Detector. Note that
* either a path to the model asset or a model buffer needs to be
* provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, objectDetectorOptions: ObjectDetectorOptions): Promise<ObjectDetector>;
/**
* Initializes the Wasm runtime and creates a new object detector based on the
* provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<ObjectDetector>;
/**
* Initializes the Wasm runtime and creates a new object detector based on the
* path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ObjectDetector>;
private constructor();
/**
* Sets new options for the object detector.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the object detector.
*/
setOptions(options: ObjectDetectorOptions): Promise<void>;
/**
* Performs object detection on the provided single image and waits
* synchronously for the response. Only use this method when the
* ObjectDetector is created with running mode `image`.
*
* @export
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return A result containing a list of detected objects.
*/
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
/**
* Performs object detection on the provided video frame and waits
* synchronously for the response. Only use this method when the
* ObjectDetector is created with running mode `video`.
*
* @export
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return A result containing a list of detected objects.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
}
/** Options to configure the MediaPipe Object Detector Task */
export declare interface ObjectDetectorOptions extends VisionTaskOptions, ClassifierOptions {
}
/** Performs pose landmarks detection on images. */
export declare class PoseLandmarker extends VisionTaskRunner {
/**
* An array containing the pairs of pose landmark indices to be rendered with
* connections.
* @export
* @nocollapse
*/
static POSE_CONNECTIONS: Connection[];
/**
* Initializes the Wasm runtime and creates a new `PoseLandmarker` from the
* provided options.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param poseLandmarkerOptions The options for the PoseLandmarker.
* Note that either a path to the model asset or a model buffer needs to
* be provided (via `baseOptions`).
*/
static createFromOptions(wasmFileset: WasmFileset, poseLandmarkerOptions: PoseLandmarkerOptions): Promise<PoseLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `PoseLandmarker` based on
* the provided model asset buffer.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetBuffer A binary representation of the model.
*/
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<PoseLandmarker>;
/**
* Initializes the Wasm runtime and creates a new `PoseLandmarker` based on
* the path to the model asset.
* @export
* @param wasmFileset A configuration object that provides the location of the
* Wasm binary and its loader.
* @param modelAssetPath The path to the model asset.
*/
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<PoseLandmarker>;
private constructor();
/**
* Sets new options for this `PoseLandmarker`.
*
* Calling `setOptions()` with a subset of options only affects those options.
* You can reset an option back to its default value by explicitly setting it
* to `undefined`.
*
* @export
* @param options The options for the pose landmarker.
*/
setOptions(options: PoseLandmarkerOptions): Promise<void>;
/**
* Performs pose detection on the provided single image and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the PoseLandmarker is created
* with running mode `image`.
*
* @param image An image to process.
* @param callback The callback that is invoked with the result. The
* lifetime of the returned masks is only guaranteed for the duration of
* the callback.
*/
detect(image: ImageSource, callback: PoseLandmarkerCallback): void;
/**
* Performs pose detection on the provided single image and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the PoseLandmarker is created
* with running mode `image`.
*
* @param image An image to process.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @param callback The callback that is invoked with the result. The
* lifetime of the returned masks is only guaranteed for the duration of
* the callback.
*/
detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
/**
* Performs pose detection on the provided single image and waits
* synchronously for the response. This method creates a copy of the resulting
* masks and should not be used in high-throughput applications. Only
* use this method when the PoseLandmarker is created with running mode
* `image`.
*
* @param image An image to process.
* @return The landmarker result. Any masks are copied to avoid lifetime
* limits.
* @return The detected pose landmarks.
*/
detect(image: ImageSource): PoseLandmarkerResult;
/**
* Performs pose detection on the provided single image and waits
* synchronously for the response. This method creates a copy of the resulting
* masks and should not be used in high-throughput applications. Only
* use this method when the PoseLandmarker is created with running mode
* `image`.
*
* @param image An image to process.
* @return The landmarker result. Any masks are copied to avoid lifetime
* limits.
* @return The detected pose landmarks.
*/
detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
/**
* Performs pose detection on the provided video frame and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the PoseLandmarker is created
* with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param callback The callback that is invoked with the result. The
* lifetime of the returned masks is only guaranteed for the duration of
* the callback.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, callback: PoseLandmarkerCallback): void;
/**
* Performs pose detection on the provided video frame and invokes the
* callback with the response. The method returns synchronously once the
* callback returns. Only use this method when the PoseLandmarker is created
* with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @param callback The callback that is invoked with the result. The
* lifetime of the returned masks is only guaranteed for the duration of
* the callback.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;
/**
* Performs pose detection on the provided video frame and returns the result.
* This method creates a copy of the resulting masks and should not be used
* in high-throughput applications. Only use this method when the
* PoseLandmarker is created with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @return The landmarker result. Any masks are copied to extend the
* lifetime of the returned data.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number): PoseLandmarkerResult;
/**
* Performs pose detection on the provided video frame and returns the result.
* This method creates a copy of the resulting masks and should not be used
* in high-throughput applications. The method returns synchronously once the
* callback returns. Only use this method when the PoseLandmarker is created
* with running mode `video`.
*
* @param videoFrame A video frame to process.
* @param timestamp The timestamp of the current frame, in ms.
* @param imageProcessingOptions the `ImageProcessingOptions` specifying how
* to process the input image before running inference.
* @return The landmarker result. Any masks are copied to extend the lifetime
* of the returned data.
*/
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;
}
/**
* A callback that receives the result from the pose detector. The returned
* masks are only valid for the duration of the callback. If asynchronous
* processing is needed, the masks need to be copied before the callback
* returns.
*/
export declare type PoseLandmarkerCallback = (result: PoseLandmarkerResult) => void;
/** Options to configure the MediaPipe PoseLandmarker Task */
export declare interface PoseLandmarkerOptions extends VisionTaskOptions {
/**
* The maximum number of poses can be detected by the PoseLandmarker.
* Defaults to 1.
*/
numPoses?: number | undefined;
/**
* The minimum confidence score for the pose detection to be considered
* successful. Defaults to 0.5.
*/
minPoseDetectionConfidence?: number | undefined;
/**
* The minimum confidence score of pose presence score in the pose landmark
* detection. Defaults to 0.5.
*/
minPosePresenceConfidence?: number | undefined;
/**
* The minimum confidence score for the pose tracking to be considered
* successful. Defaults to 0.5.
*/
minTrackingConfidence?: number | undefined;
/** Whether to output segmentation masks. Defaults to false. */
outputSegmentationMasks?: boolean | undefined;
}
/**
* Represents the pose landmarks deection results generated by `PoseLandmarker`.
* Each vector element represents a single pose detected in the image.
*/
export declare class PoseLandmarkerResult {
readonly landmarks: NormalizedLandmark[][];
/** Pose landmarks in world coordinates of detected poses. */
readonly worldLandmarks: Landmark[][];
/** Segmentation mask for the detected pose. */
readonly segmentationMasks?: MPMask[] | undefined;
constructor(/** Pose landmarks of detected poses. */ landmarks: NormalizedLandmark[][],
/** Pose landmarks in world coordinates of detected poses. */
worldLandmarks: Landmark[][],
/** Segmentation mask for the detected pose. */
segmentationMasks?: MPMask[] | undefined);
/** Frees the resources held by the segmentation masks. */
close(): void;
}
/**
* Defines a rectangle, used e.g. as part of detection results or as input
* region-of-interest.
*
* The coordinates are normalized with respect to the image dimensions, i.e.
* generally in [0,1] but they may exceed these bounds if describing a region
* overlapping the image. The origin is on the top-left corner of the image.
*/
declare interface RectF {
left: number;
top: number;
right: number;
bottom: number;
}
/** A Region-Of-Interest (ROI) to represent a region within an image. */
export declare interface RegionOfInterest {
/** The ROI in keypoint format. */
keypoint?: NormalizedKeypoint;
/** The ROI as scribbles over the object that the user wants to segment. */
scribble?: NormalizedKeypoint[];
}
/**
* A four channel color with values for red, green, blue and alpha
* respectively.
*/
export declare type RGBAColor = [
number,
number,
number,
number
] | number[];
/**
* The two running modes of a vision task.
* 1) The image mode for processing single image inputs.
* 2) The video mode for processing decoded frames of a video.
*/
declare type RunningMode = "IMAGE" | "VIDEO";
/** Base class for all MediaPipe Tasks. */
declare abstract class TaskRunner {
protected constructor();
/** Configures the task with custom options. */
abstract setOptions(options: TaskRunnerOptions): Promise<void>;
/**
* Closes and cleans up the resources held by this task.
* @export
*/
close(): void;
}
/** Options to configure MediaPipe Tasks in general. */
declare interface TaskRunnerOptions {
/** Options to configure the loading of the model assets. */
baseOptions?: BaseOptions_2;
}
/** The options for configuring a MediaPipe vision task. */
declare interface VisionTaskOptions extends TaskRunnerOptions {
/**
* The canvas element to bind textures to. This has to be set for GPU
* processing. The task will initialize a WebGL context and throw an error if
* this fails (e.g. if you have already initialized a different type of
* context).
*/
canvas?: HTMLCanvasElement | OffscreenCanvas;
/**
* The running mode of the task. Default to the image mode.
* Vision tasks have two running modes:
* 1) The image mode for processing single image inputs.
* 2) The video mode for processing decoded frames of a video.
*/
runningMode?: RunningMode;
}
/** Base class for all MediaPipe Vision Tasks. */
declare abstract class VisionTaskRunner extends TaskRunner {
protected constructor();
/**
* Closes and cleans up the resources held by this task.
* @export
*/
close(): void;
}
/**
* Copyright 2022 The MediaPipe Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** An object containing the locations of the Wasm assets */
declare interface WasmFileset {
/** The path to the Wasm loader script. */
wasmLoaderPath: string;
/** The path to the Wasm binary. */
wasmBinaryPath: string;
/** The optional path to the asset loader script. */
assetLoaderPath?: string;
/** The optional path to the assets binary. */
assetBinaryPath?: string;
}
export { }
|