/usr/include/ni/XnCppWrapper.h is in libopenni-dev 1.5.4.0-14.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 | /****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
#ifndef __XN_CPP_WRAPPER_H__
#define __XN_CPP_WRAPPER_H__
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnOpenNI.h>
#include <XnCodecIDs.h>
//---------------------------------------------------------------------------
// Types
//---------------------------------------------------------------------------
namespace xn
{
//---------------------------------------------------------------------------
// Forward Declarations
//---------------------------------------------------------------------------
class ProductionNode;
class EnumerationErrors;
class NodeInfo;
class NodeInfoList;
class Context;
class Query;
class Generator;
/**
* @ingroup cppref
* @defgroup cppref_glb_ev_hndlrs Global Event Handlers
*/
/**
* @ingroup cppref
* @defgroup cppref_graph_mgmt Managing the Production Graph
*/
/**
* @ingroup cppref
* @defgroup cppref_meta_data Meta-Data Objects (Frame Objects)
*/
/**
* @ingroup cppref
* @defgroup cppref_prd_func Production Nodes Functionality
*/
/**
* @ingroup cppref
* @defgroup cppref_misc Misc
*/
//---------------------------------------------------------------------------
// Types
//---------------------------------------------------------------------------
/**
* @ingroup cppref_glb_ev_hndlrs
* Type definition to define event handlers for the 'State Change' event.
*
* @param [in] node Node issuing the event.
* @param [in] pCookie User cookie passed on registration.
*
* <b>Remarks</b>
*
* The 'State Change' event can be invoked by a number of OpenNI objects.
* For example, this event is invoked by the @ref xn::ErrorStateCapability "ErrorStateCapability"
* object whenever a node's error state changes. As another example, this event is
* also invoked by the @ref xn::MirrorCapability "MirrorCapability" object whenever a node's
* mirror configuration has been changed.
*
* <b>Example:</b>
*
* The following is an example of a callback method that follows that signature:
*
@code
void XN_CALLBACK_TYPE OnEvent(ProductionNode& node, void* pCookie)
{
}
@endcode
*/
typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
//---------------------------------------------------------------------------
// Internal stuff
//---------------------------------------------------------------------------
typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
//---------------------------------------------------------------------------
// Some Utilities
//---------------------------------------------------------------------------
/**
* @ingroup cppref_misc
* <b>Purpose:</b> The Version class provides functionality for accessing the OpenNI version information.
*/
class Version
{
public:
Version(const XnVersion& version) : m_version(version) {}
Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild)
{
m_version.nMajor = nMajor;
m_version.nMinor = nMinor;
m_version.nMaintenance = nMaintenance;
m_version.nBuild = nBuild;
}
bool operator==(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) == 0);
}
bool operator!=(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) != 0);
}
bool operator<(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) < 0);
}
bool operator<=(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) <= 0);
}
bool operator>(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) > 0);
}
bool operator>=(const Version& other) const
{
return (xnVersionCompare(&m_version, &other.m_version) >= 0);
}
static Version Current()
{
XnVersion version;
xnGetVersion(&version);
return Version(version);
}
XnUInt8 Major() const { return m_version.nMajor; }
XnUInt8 Minor() const { return m_version.nMinor; }
XnUInt16 Maintenance() const { return m_version.nMaintenance; }
XnUInt32 Build() const { return m_version.nBuild; }
XnUInt8& Major() { return m_version.nMajor; }
XnUInt8& Minor() { return m_version.nMinor; }
XnUInt16& Maintenance() { return m_version.nMaintenance; }
XnUInt32& Build() { return m_version.nBuild; }
const XnVersion* GetUnderlying() const { return &m_version; }
XnVersion* GetUnderlying() { return &m_version; }
private:
XnVersion m_version;
};
//---------------------------------------------------------------------------
// Meta Data
//---------------------------------------------------------------------------
/**
* @ingroup cppref_meta_data
* <b>Purpose:</b> The OutputMetaData class provides functionality for supporting fast
* cached data access to many types of generator nodes.
*
* <b>Remarks:</b>
*
* The OutputMetaData class is the most basic OpenNI metadata class, whose main properties
* include <code>Timestamp</code>, <code>FrameID</code>, and <code>DataSize</code>.
* This class is never instantiated; it is used a base class to help build the hierarchy.
*
* An instance of this class hold a @ref glos_frame_object "frame object".
* The frame object is a snapshot of the generated data at a certain point in time.
*/
class OutputMetaData
{
public:
/**
* Ctor. Intended for use by other MetaData objects.
*
* @param [in] ppData A pointer to the data member of the meta data object.
*/
inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
{
xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
}
/**
* Dtor. Frees any allocated data.
*/
virtual ~OutputMetaData() { Free(); }
/**
* Returns the timestamp of the @ref glos_frame_object "frame object" saved in this object.
*/
inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
/**
* Returns the timestamp of the @ref glos_frame_object "frame object" saved in this object.
*/
inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
/**
* Returns the frame ID of the @ref glos_frame_object "frame object" saved in this object.
* Frame IDs are sequential unique numbers starting with 1.
*/
inline XnUInt32 FrameID() const { return m_output.nFrameID; }
/**
* Returns the frame ID of the @ref glos_frame_object "frame object" saved in this object.
* Frame IDs are sequential unique numbers starting with 1.
*/
inline XnUInt32& FrameID() { return m_output.nFrameID; }
/**
* @brief Returns the size, in bytes, of the data of the @ref glos_frame_object "frame object" saved in this object.
*
* <b>Remarks</b>
*
* For map metadata, this value equals to
* @ref xn::MapMetaData::XRes "XRes()" * @ref xn::MapMetaData::YRes "YRes()" * @ref xn::MapMetaData::BytesPerPixel "BytesPerPixel()".
*/
inline XnUInt32 DataSize() const { return m_output.nDataSize; }
/**
* @brief Returns the size, in bytes, of the data of the @ref glos_frame_object "frame object" saved in this object.
*
* <b>Remarks</b>
*
* For map metadata, this value equals to
* @ref xn::MapMetaData::XRes "XRes()" * @ref xn::MapMetaData::YRes "YRes()" * @ref xn::MapMetaData::BytesPerPixel "BytesPerPixel()".
*/
inline XnUInt32& DataSize() { return m_output.nDataSize; }
/**
* Returns whether this node's frame data was updated by the most recent call to
* any @ref conc_updating_data "'WaitXUpdateAll()'" function, e.g., @ref xn::Context::WaitAnyUpdateAll().
*/
inline XnBool IsDataNew() const { return m_output.bIsNew; }
/**
* Returns whether this node's frame data was updated by the most recent call to
* any @ref conc_updating_data "'WaitXUpdateAll()'" function, e.g., @ref xn::Context::WaitAnyUpdateAll().
*/
inline XnBool& IsDataNew() { return m_output.bIsNew; }
/**
* Gets the C object that is wrapped by this object.
*/
inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
/**
* Gets the C object that is wrapped by this object.
*/
inline XnOutputMetaData* GetUnderlying() { return &m_output; }
/**
* Gets a pointer to the data of the @ref glos_frame_object "frame object"
* saved in this object.
*/
inline const XnUInt8* Data() const { return *m_ppData; }
/**
* Gets a pointer to the data of the @ref glos_frame_object "frame object"
* saved in this object.
*/
inline const XnUInt8*& Data() { return *m_ppData; }
/**
* Gets a pointer to the writable buffer (see @ref conc_meta_data).
*/
inline XnUInt8* WritableData()
{
MakeDataWritable();
return m_pAllocatedData;
}
/**
* @brief Allocates a writable buffer. If a previous buffer was allocated it will
* be freed (or reused if possible).
*
* Also see @ref conc_meta_data.
*
* @param [in] nBytes The requested size for the buffer, in bytes.
*/
XnStatus AllocateData(XnUInt32 nBytes)
{
if (nBytes > m_nAllocatedSize)
{
// reallocate
XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
XN_VALIDATE_ALLOC_PTR(pData);
// allocation succeeded, replace
Free();
m_pAllocatedData = pData;
m_nAllocatedSize = nBytes;
}
DataSize() = nBytes;
*m_ppData = m_pAllocatedData;
return XN_STATUS_OK;
}
/**
* Frees the writable buffer, if one was allocated.
*/
void Free()
{
if (m_nAllocatedSize != 0)
{
xnOSFreeAligned(m_pAllocatedData);
m_pAllocatedData = NULL;
m_nAllocatedSize = 0;
}
}
/**
* Creates a writable copy of the data, and stores it instead of the original (read-only) data.
* Also see @ref conc_meta_data.
*/
XnStatus MakeDataWritable()
{
XnStatus nRetVal = XN_STATUS_OK;
// check data isn't already writable
if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
{
const XnUInt8* pOrigData = *m_ppData;
nRetVal = AllocateData(DataSize());
XN_IS_STATUS_OK(nRetVal);
if (pOrigData != NULL)
{
xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
}
else
{
xnOSMemSet(m_pAllocatedData, 0, DataSize());
}
}
return (XN_STATUS_OK);
}
protected:
XnUInt8* m_pAllocatedData;
private:
XnOutputMetaData m_output;
const XnUInt8** m_ppData;
XnUInt32 m_nAllocatedSize;
};
/**
* @ingroup cppref_meta_data
* The MapMetaData class is a base class for providing the fast data access functionality
* for the @ref glos_frame_object "frame object" saved in metadata. This functionality
* is applicable to all generator nodes that have an associated metadata object.
*
* MapMetaData is the next metadata class in the metadata hierarchy after the OutputMetaData
* class.
*
* The MapMetaData class - like OutputMetaData - is never instantiated;
* it is a base class of the OpenNI metadata class hierarchy.
*/
class MapMetaData : public OutputMetaData
{
public:
/**
* Ctor. Intended for use by inheriting classes.
*
* @param [in] format Pixel Format
* @param [in] ppData A pointer to the data member of the meta data object
*/
inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
{
xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
m_map.pOutput = OutputMetaData::GetUnderlying();
m_map.PixelFormat = format;
}
/**
* Gets the frame X resolution of the @ref glos_frame_object "frame object" saved in this object.
* The X resolution is the actual number of columns in the frame after any required cropping has
* been applied.
*/
inline XnUInt32 XRes() const { return m_map.Res.X; }
/**
* Gets the frame X resolution of the @ref glos_frame_object "frame object" saved in this object.
* The X resolution is the actual number of columns in the frame after any required cropping has
* been applied.
*/
inline XnUInt32& XRes() { return m_map.Res.X; }
/**
* Gets the frame Y resolution of the @ref glos_frame_object "frame object" saved in this object.
* The Y resolution is the actual number of rows in the frame after any required cropping has
* been applied.
*/
inline XnUInt32 YRes() const { return m_map.Res.Y; }
/**
* Gets the frame Y resolution of the @ref glos_frame_object "frame object" saved in this object.
* The Y resolution is the actual number of rows in the frame after any required cropping has
* been applied.
*/
inline XnUInt32& YRes() { return m_map.Res.Y; }
/**
* Gets the cropping area X offset of the @ref glos_frame_object "frame object" saved in this object.
* This is the horizontal offset, measured in units of pixel columns, of the buffer within the field of view.
*
* <b>Remarks</b>
*
* The X offset is 0 if cropping is disabled (see @ref XnCropping).
*/
inline XnUInt32 XOffset() const { return m_map.Offset.X; }
/**
* Gets the cropping area X offset of the @ref glos_frame_object "frame object" saved in this object.
* This is the horizontal offset, measured in units of pixel columns, of the buffer within the field of view.
*
* <b>Remarks</b>
*
* The X offset is 0 if cropping is disabled (see @ref XnCropping).
*/
inline XnUInt32& XOffset() { return m_map.Offset.X; }
/**
* Gets the cropping area Y offset of the @ref glos_frame_object "frame object" saved in this object.
* This is the vertical offset, measured in units of pixel rows, of the buffer within the field of view.
*
* <b>Remarks</b>
*
* The Y offset is 0 if cropping is disabled (see @ref XnCropping).
*/
inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
/**
* Gets the cropping area Y offset of the @ref glos_frame_object "frame object" saved in this object.
* This is the vertical offset, measured in units of pixel rows, of the buffer within the field of view.
*
* <b>Remarks</b>
*
* The Y offset is 0 if cropping is disabled (see @ref XnCropping).
*/
inline XnUInt32& YOffset() { return m_map.Offset.Y; }
/**
* Gets the number of columns in the full frame (entire field-of-view, ignoring
* cropping).
*/
inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
/**
* Gets the number of columns in the full frame (entire field-of-view, ignoring
* cropping).
*/
inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
/**
* Gets the number of rows in the full frame (entire field-of-view, ignoring cropping).
*/
inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
/**
* Gets the number of rows in the full frame (entire field-of-view, ignoring cropping).
*/
inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
/**
* Gets the FPS in which frame was generated.
*/
inline XnUInt32 FPS() const { return m_map.nFPS; }
/**
* Gets the FPS in which frame was generated.
*/
inline XnUInt32& FPS() { return m_map.nFPS; }
/**
* Gets the pixel format of the pixel-map.
*/
inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
/**
* Gets the C object that is wrapped by this object.
*/
inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
/**
* Gets the C object that is wrapped by this object.
*/
inline XnMapMetaData* GetUnderlying() { return &m_map; }
/**
* Gets the number of bytes each pixel occupies.
*/
inline XnUInt32 BytesPerPixel() const
{
switch (PixelFormat())
{
case XN_PIXEL_FORMAT_RGB24:
return sizeof(XnRGB24Pixel);
case XN_PIXEL_FORMAT_YUV422:
return sizeof(XnYUV422DoublePixel)/2;
case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT:
return sizeof(XnGrayscale8Pixel);
case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT:
return sizeof(XnGrayscale16Pixel);
case XN_PIXEL_FORMAT_MJPEG:
return 2;
default:
XN_ASSERT(FALSE);
return 0;
}
}
/**
* @copybrief xn::OutputMetaData::AllocateData
*
* @param [in] nXRes The number of required columns in the map.
* @param [in] nYRes The number of required rows in the map.
*/
XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
{
XnStatus nRetVal = XN_STATUS_OK;
XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
nRetVal = OutputMetaData::AllocateData(nSize);
XN_IS_STATUS_OK(nRetVal);
FullXRes() = XRes() = nXRes;
FullYRes() = YRes() = nYRes;
XOffset() = YOffset() = 0;
return (XN_STATUS_OK);
}
/**
* Changes dimensions of the pixel-map.
*
* @param [in] nXRes Number of columns in the map
* @param [in] nYRes Number of rows in the map
* @param [in] pExternalBuffer Optional. An external buffer to be used. If NULL is passed,
* a buffer will be allocated.
*/
XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
{
XnStatus nRetVal = XN_STATUS_OK;
if (pExternalBuffer == NULL)
{
nRetVal = AllocateData(nXRes, nYRes);
XN_IS_STATUS_OK(nRetVal);
}
else
{
FullXRes() = XRes() = nXRes;
FullYRes() = YRes() = nYRes;
XOffset() = YOffset() = 0;
Data() = pExternalBuffer;
DataSize() = nXRes * nYRes * BytesPerPixel();
}
return (XN_STATUS_OK);
}
protected:
XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; }
private:
// block copy ctor and assignment operator
MapMetaData& operator=(const MapMetaData&);
inline MapMetaData(const MapMetaData& other);
// Members
XnMapMetaData m_map;
};
/**
* @ingroup cppref_meta_data
* The Map Wrapper classes are light wrappers for @ref glos_frame_object maps (from metadata classes). These wrapper classes
* provide small data-focused objects for simplified data access to frame objects generated by the generator nodes.
*
* @tparam _pixelType The data type of a single pixel in this map
*/
template<class _pixelType>
class Map
{
public:
inline Map(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) :
m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes)
{}
/**
* Gets the frame X resolution. The X resolution is the actual number of columns in the frame after any required cropping has been applied.
*
* <b>Remarks</b>
*
* This is the same as @ref xn::MapMetaData::XRes "MapMetaData::XRes()".
*/
inline XnUInt32 XRes() const { return m_nXRes; }
/**
* Gets the frame Y resolution. The Y resolution is the actual number of rows in the frame after any required cropping has been applied.
*
* <b>Remarks</b>
*
* This is the same as @ref xn::MapMetaData::YRes "MapMetaData::YRes()".
*/
inline XnUInt32 YRes() const { return m_nYRes; }
/**
* Gets a single pixel of the frame map by indexing a map as a one-dimensional array.
*
* @param [in] nIndex The position of the pixel in the buffer
*
* @returns A pixel of type <code>_pixelType</code>.
*
* <b>Remarks</b>
*
* Indexing a map in this way can give improved speed in some situations.
*/
inline const _pixelType& operator[](XnUInt32 nIndex) const
{
XN_ASSERT(nIndex < (m_nXRes * m_nYRes));
return m_pData[nIndex];
}
/**
* Gets a single pixel of the frame map by indexing a map as a one-dimensional array.
*
* @param [in] nIndex The position of the pixel in the buffer
*
* @returns A pixel of type <code>_pixelType</code>.
*
* <b>Remarks</b>
*
* Indexing a map in this way can give improved speed in some situations.
*/
inline _pixelType& operator[](XnUInt32 nIndex)
{
XN_ASSERT(nIndex < (m_nXRes *m_nYRes));
return m_pData[nIndex];
}
/**
* Gets a single pixel of the frame map by its X and Y coordinates.
*
* @param [in] x The horizontal position of the pixel (from left to right)
* @param [in] y The vertical position of the pixel in the buffer (from top to bottom)
*
* @returns A pixel of type <code>_pixelType</code>.
*/
inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const
{
XN_ASSERT(x < m_nXRes && y < m_nYRes);
return m_pData[y*m_nXRes + x];
}
/**
* Gets a single pixel of the frame map by its X and Y coordinates.
*
* @param [in] x The horizontal position of the pixel (from left to right)
* @param [in] y The vertical position of the pixel in the buffer (from top to bottom)
*
* @returns A pixel of type <code>_pixelType</code>.
*/
inline _pixelType& operator()(XnUInt32 x, XnUInt32 y)
{
XN_ASSERT(x < m_nXRes && y < m_nYRes);
return m_pData[y*m_nXRes + x];
}
private:
/* block copy ctor and assignment operator */
Map(const Map& other);
Map& operator=(const Map&);
_pixelType*& m_pData;
XnUInt32& m_nXRes;
XnUInt32& m_nYRes;
};
/** @ingroup cppref_meta_data
* @{
*/
/** Declares a @ref xn::Map "Map" class with pixel of type XnDepthPixel */
typedef Map<XnDepthPixel> DepthMap;
/** Declares a @ref xn::Map "Map" class with pixel of type XnUInt8 */
typedef Map<XnUInt8> ImageMap;
/** Declares a @ref xn::Map "Map" class with pixel of type XnRGB24Pixel */
typedef Map<XnRGB24Pixel> RGB24Map;
/** Declares a @ref xn::Map "Map" class with pixel of type XnGrayscale16Pixel */
typedef Map<XnGrayscale16Pixel> Grayscale16Map;
/** Declares a @ref xn::Map "Map" class with pixel of type XnGrayscale8Pixel */
typedef Map<XnGrayscale8Pixel> Grayscale8Map;
/** Declares a @ref xn::Map "Map" class with pixel of type XnIRPixel */
typedef Map<XnIRPixel> IRMap;
/** Declares a @ref xn::Map "Map" class with pixel of type XnLabel */
typedef Map<XnLabel> LabelMap;
/** @} */
/**
* @ingroup cppref_meta_data
*
* For saving the @ref glos_frame_object "frame object" (data and configuration) from
* the @ref xn::DepthGenerator "DepthGenerator" node. This @ref glos_frame_object "frame
* object" is a snapshot of the DepthGenerator's generated depth map and its associated
* configuration information at a certain point in time. This saved @ref glos_frame_object
* "frame object" provides fast and easy access to the DepthGenerator node's data and
* configuration information.
*
* It is important to get a good understanding of the purpose and design of the OpenNI
* metadata objects. For a comprehensive overview of OpenNI metadata objects, see @ref
* conc_meta_data.
*
* The DepthGenerator node generates depth data of the FOV. This is the
* Z-coordinate of the X-Y-Z coordinate of each point. The Z-axis is the distance, in
* millimeters from the sensor plane.
* A smaller depth value indicates a scene point that is a <i>closer</i> to the sensor,
* and a larger depth value indicates a scene point that is <i>further away</i> from
* the sensor. A zero depth value indicates that the DepthGenerator node did not succeed
* in obtaining a valid depth reading.
*
* DepthMetaData's @ref xn::DepthMetaData::Data() method provides the actual depth
* data. This method returns the pointer to the first depth pixel in the map.
*
* The pixel format of depth map is XnDepthPixel, i.e. 16-bit values.
*
* DepthMetaData provides the <code>ZRes</code> property to contain the depth resolution.
* This is the maximum value of a pixel (plus one).
*
* DepthMetaData is similar to ImageMetaData; they are both metadata for a type of map.
*/
class DepthMetaData : public MapMetaData
{
public:
/**
* Ctor.
*/
inline DepthMetaData() :
MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
{
xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
m_depth.pMap = MapMetaData::GetUnderlying();
}
/**
* @brief Shallow-Copies a DepthMetaData object.
*
* @param [in] other source object.
*
* @remarks Note that the data buffer is not copied, and that both object will point to the same buffer.
*/
inline void InitFrom(const DepthMetaData& other)
{
xnCopyDepthMetaData(&m_depth, &other.m_depth);
}
/**
* Shallow copies another @ref DepthMetaData object, and then @ref ReAdjust "readjusts
* it".
*
* @param [in] other Source object
* @param [in] nXRes Requested number of columns in the map
* @param [in] nYRes Requested number of rows in the map
* @param [in] pExternalBuffer Optional. An external buffer matching requested resolution.
* If NULL, A buffer will be allocated.
*/
inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
{
InitFrom(other);
return ReAdjust(nXRes, nYRes, pExternalBuffer);
}
/**
* Performs a deep-copy of another metadata object (including duplication of the
* data buffer).
*
* @param [in] other source object
*/
XnStatus CopyFrom(const DepthMetaData& other)
{
// copy props
InitFrom(other);
// and make a copy of the data (this will allocate and copy data)
return MakeDataWritable();
}
/**
* @copydoc xn::MapMetaData::ReAdjust
*/
XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
{
return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
}
/**
* Gets the maximum depth (depth resolution) that the DepthGenerator node can produce.
* This is the same as the resolution of the depth axis
* (i.e., @ref DepthGenerator::GetDeviceMaxDepth() + 1).
*/
inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
/**
* Gets the maximum depth (depth resolution) that the DepthGenerator node can produce.
* This is the same as the resolution of the depth axis
* (i.e., @ref DepthGenerator::GetDeviceMaxDepth() + 1).
*/
inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
/**
* @brief Returns the depth map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first depth pixel in the map. The depth
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnDepthPixel, i.e. 16-bit integer values.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
/**
* @brief Returns the depth map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first depth pixel in the map. The depth
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnDepthPixel, i.e. 16-bit integer values.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
/**
* @copydoc xn::OutputMetaData::WritableData
*/
inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); }
/**
* Gets a light object wrapping the depth map
*/
inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
/**
* Gets a light object wrapping the writable depth map
*/
inline xn::DepthMap& WritableDepthMap()
{
MakeDataWritable();
return m_writableDepthMap;
}
/**
* Gets the value of a single pixel of the frame map by its index in the array.
*
* @param [in] nIndex The index of the pixel in the buffer.
*/
inline const XnDepthPixel& operator[](XnUInt32 nIndex) const
{
XN_ASSERT(nIndex < (XRes()*YRes()));
return Data()[nIndex];
}
/**
* Gets the value of a single pixel of the frame map by its X and Y coordinates.
*
* @param [in] x X-coordinate of the pixel in the map
* @param [in] y Y-coordinate of the pixel in the map
*/
inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const
{
XN_ASSERT(x < XRes() && y < YRes());
return Data()[y*XRes() + x];
}
/**
* @copydoc xn::OutputMetaData::GetUnderlying
*/
inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
/**
* @copydoc xn::OutputMetaData::GetUnderlying
*/
inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
private:
// block copy ctor and assignment operator (because we can't return errors in those)
DepthMetaData(const DepthMetaData& other);
DepthMetaData& operator=(const DepthMetaData&);
XnDepthMetaData m_depth;
const xn::DepthMap m_depthMap;
xn::DepthMap m_writableDepthMap;
};
/**
* @ingroup cppref_meta_data
*
* For saving the @ref glos_frame_object "frame object" (data and configuration) from
* the @ref xn::DepthGenerator "DepthGenerator" node. This @ref glos_frame_object "frame
* object" is a snapshot of the DepthGenerator's generated depth map and its associated
* configuration information at a certain point in time. This saved @ref glos_frame_object
* "frame object" provides fast and easy access to the DepthGenerator node's data and
* configuration information.
*
* It is important to get a good understanding of the purpose and design of the OpenNI
* metadata objects. For a comprehensive overview of OpenNI metadata objects, see @ref
* conc_meta_data.
*
* The ImageMetaData object provides a number of different methods to get the image
* as a different format. You must use the 'Get Data' method most appropriate for the
* data format of the latest available frame. For example, if you requested the ImageGenerator
* node to generate RGB24 format you must use the @ref RGB24Data() method to get the
* data.
*
* Each of the 'Get Data' methods gets the image as a pointer to the first pixel
* in the image map. From the address of that first pixel you can access all the pixels.
*
* Depending on the format, the pixels are different in size. This means that image
* maps are a different size.
*/
class ImageMetaData : public MapMetaData
{
public:
inline ImageMetaData() :
MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
{
xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
m_image.pMap = MapMetaData::GetUnderlying();
}
/**
* @brief Shallow-copies an ImageMetaData object.
*
* @param [in] other source object.
*
* @remarks Note that the data buffer is not copied, and that both object will point to the same buffer.
*/
inline void InitFrom(const ImageMetaData& other)
{
xnCopyImageMetaData(&m_image, &other.m_image);
}
/**
* Shallow copies another @ref ImageMetaData object, and then @ref ReAdjust "readjusts"
* it.
*
* @param [in] other Source object
* @param [in] nXRes Requested number of columns in the map
* @param [in] nYRes Requested number of rows in the map
* @param [in] format Requested pixel format
* @param [in] pExternalBuffer Optional. An external buffer matching requested resolution.
* If NULL, A buffer will be allocated.
*/
inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
{
InitFrom(other);
XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
XN_IS_STATUS_OK(nRetVal);
PixelFormat() = format;
return XN_STATUS_OK;
}
/**
* @copybrief xn::OutputMetaData::AllocateData
*
* @param [in] nXRes Requested number of columns in the map
* @param [in] nYRes Requested number of rows in the map
* @param [in] format Requested pixel format
*/
inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
{
XnPixelFormat origFormat = PixelFormat();
PixelFormat() = format;
XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
if (nRetVal != XN_STATUS_OK)
{
PixelFormat() = origFormat;
return (nRetVal);
}
return XN_STATUS_OK;
}
/**
* Performs a deep-copy of another metadata object (including duplication of the data buffer)
*
* @param [in] other source object
*/
inline XnStatus CopyFrom(const ImageMetaData& other)
{
// copy props
xnCopyImageMetaData(&m_image, &other.m_image);
// and make a copy of the data (this will allocate and copy data)
return MakeDataWritable();
}
/**
* @copybrief xn::MapMetaData::ReAdjust
*
* @param [in] nXRes Requested number of columns in the map
* @param [in] nYRes Requested number of rows in the map
* @param [in] format Requested pixel format
* @param [in] pExternalBuffer Optional. An external buffer to be used. If NULL
* is passed, a buffer will be allocated.
*/
XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
{
XnPixelFormat origFormat = PixelFormat();
PixelFormat() = format;
XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
if (nRetVal != XN_STATUS_OK)
{
PixelFormat() = origFormat;
return (nRetVal);
}
return XN_STATUS_OK;
}
/**
* @brief Gets the frame's pixel color format used in this image map. This is the
* format of the @ref glos_frame_object "frame object" saved in this object.
*
* <b>Remarks</b>
*
* Knowing the pixel format of the image map helps you to enumerate over the map
* and process its data.
*
* Reimplemented from @ref xn::MapMetaData.
*/
inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); }
/**
* @brief Gets the frame's pixel color format used in this image map. This is the
* format of the @ref glos_frame_object "frame object" saved in this object.
*
* <b>Remarks</b>
*
* Knowing the pixel format of the image map helps you to enumerate over the map
* and process its data.
*/
inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); }
/**
* @copydoc MapMetaData::WritableData
*/
inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
/**
* @brief Gets a pointer to the first pixel of the image in @ref xn::XnRGB24Pixel "RGB24" format.
* RGB24 format represents each pixel as one byte for red, one byte for green, and one byte for blue.
*/
inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
/**
* @brief Gets a pointer to the first pixel of the image in @ref xn::XnRGB24Pixel "RGB24" format.
* RGB24 format represents each pixel as one byte for red, one byte for green, and one byte for blue.
*/
inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
/**
* @copydoc MapMetaData::WritableData
*/
inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); }
/**
* @brief Gets a pointer to the first pixel of the image in @ref xn::XnYUV422DoublePixel "YUV422" format.
* YUV422 is a type of compression with a single Y byte followed by a U byte, then another Y byte and then a V byte: YUY'V.
* These four values represent two pixels: YUV and Y'UV.
*/
inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
/**
* @brief Gets a pointer to the first pixel of the image in @ref xn::XnYUV422DoublePixel "YUV422" format.
* YUV422 is a type of compression with a single Y byte followed by a U byte, then another Y byte and then a V byte: YUY'V.
* These four values represent two pixels: YUV and Y'UV.
*/
inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); }
/**
* @copydoc MapMetaData::WritableData
*/
inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); }
/**
* @brief Gets a pointer to the first pixel of the image in Grayscale8 format.
* Grayscale8 represents each pixel as an 8-bit (1 byte) gray scale.
*/
inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
/**
* @brief Gets a pointer to the first pixel of the image in Grayscale8 format.
* Grayscale8 represents each pixel as an 8-bit (1-byte) gray scale.
*/
inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); }
/**
* @copydoc MapMetaData::WritableData
*/
inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); }
/**
* @brief Gets a pointer to the first pixel of the image in Grayscale16 format.
* Grayscale16 represents each pixel as a 16-bit (2-byte) gray scale.
*/
inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
/**
* @brief Gets a pointer to the first pixel of the image in Grayscale16 format.
* Grayscale16 represents each pixel as a 16-bit (2-byte) gray scale.
*/
inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); }
/**
* @copydoc MapMetaData::WritableData
*/
inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); }
/**
* @brief Gets a light object wrapping the image map.
*/
inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
/**
* Gets a light object wrapping the writable image-map
*/
inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
/**
* @brief Gets a light wrapper object for wrapping the image map as RGB24 format.
* RGB24 format represents each pixel as one byte for red, one byte for green, and
* one byte for blue.
*/
inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
/**
* @copydoc xn::ImageMetaData::WritableImageMap
*/
inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
/**
* @brief Gets a light wrapper object wrapping the image map as Grayscale8 format.
*/
inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
/**
* @copydoc xn::ImageMetaData::WritableImageMap
*/
inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
/**
* @brief Gets a light wrapper object wrapping the frame's image map as Grayscale16
* format.
*/
inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
/**
* @copydoc xn::ImageMetaData::WritableImageMap
*/
inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
/**
* @copydoc xn::OutputMetaData::GetUnderlying
*/
inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
/**
* @copydoc xn::OutputMetaData::GetUnderlying
*/
inline XnImageMetaData* GetUnderlying() { return &m_image; }
private:
// block copy ctor and assignment operator
ImageMetaData(const ImageMetaData& other);
ImageMetaData& operator=(const ImageMetaData&);
XnImageMetaData m_image;
const xn::ImageMap m_imageMap;
xn::ImageMap m_writableImageMap;
const xn::RGB24Map m_rgb24Map;
xn::RGB24Map m_writableRgb24Map;
const xn::Grayscale16Map m_gray16Map;
xn::Grayscale16Map m_writableGray16Map;
const xn::Grayscale8Map m_gray8Map;
xn::Grayscale8Map m_writableGray8Map;
};
/**
* @ingroup cppref_meta_data
*
* <b>Purpose:</b> For saving the @ref glos_frame_object "frame object" (data and configuration)
* from an xn::IRGenerator node. This @ref glos_frame_object "frame object" is a snapshot
* of the generated infra-red map data and its associated configuration information
* at a certain point in time. This saved @ref glos_frame_object "frame object" provides
* fast and easy access to the IRGenerator node's data and configuration information.
*/
class IRMetaData : public MapMetaData
{
public:
inline IRMetaData() :
MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
{
xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
m_ir.pMap = MapMetaData::GetUnderlying();
}
/**
* @brief Shallow-Copies an IRMetaData object.
*
* @param [in] other source object.
*
* @remarks Note that the data buffer is not copied, and that both object will point to the same buffer.
*/
inline void InitFrom(const IRMetaData& other)
{
xnCopyIRMetaData(&m_ir, &other.m_ir);
}
/**
* Shallow copies another IRMetaData object, and then @ref ReAdjust it.
*
* @param [in] other source object
* @param [in] nXRes requested number of columns in the map
* @param [in] nYRes requested number of rows in the map
* @param [in] pExternalBuffer Optional. An external buffer matching requested resolution. If NULL,
* A buffer will be allocated.
*/
inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
{
InitFrom(other);
return ReAdjust(nXRes, nYRes, pExternalBuffer);
}
/**
* Performs a deep-copy of another metadata object (including duplication of the data buffer)
*
* @param [in] other source object
*/
XnStatus CopyFrom(const IRMetaData& other)
{
// copy props
xnCopyIRMetaData(&m_ir, &other.m_ir);
// and make a copy of the data (this will allocate and copy data)
return MakeDataWritable();
}
/**
* @copydoc MapMetaData::ReAdjust
*/
XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
{
return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
}
/**
* @brief Returns the IR map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first IR pixel in the map. The IR
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnIRPixel, i.e. 16-bit integer values.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
/**
* @brief Returns the IR map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first IR pixel in the map. The IR
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnIRPixel, i.e. 16-bit integer values.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
/**
* @copydoc OutputMetaData::WritableData
*/
inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); }
/**
* Gets the value of a single pixel of the frame map by its index in the array.
*
* @param [in] nIndex The index of the pixel in the buffer.
*/
inline const XnIRPixel& operator[](XnUInt32 nIndex) const
{
XN_ASSERT(nIndex < (XRes()*YRes()));
return Data()[nIndex];
}
/**
* Gets the value of a single pixel of the frame map by its X and Y coordinates.
*
* @param [in] x X-coordinate of the pixel in the map
* @param [in] y Y-coordinate of the pixel in the map
*/
inline const XnIRPixel& operator()(XnUInt32 x, XnUInt32 y) const
{
XN_ASSERT(x < XRes() && y < YRes());
return Data()[y*XRes() + x];
}
/**
* @brief Gets a fast, light object wrapping the IR map.
* <b>Remarks</b>
*
* The Map Wrapper classes are light wrappers for generated maps saved as @ref glos_frame_object
* "frame objects" in metadata. These wrapper classes provide small data-focused
* objects for simplified data access to frame objects.
*/
inline const xn::IRMap& IRMap() const { return m_irMap; }
/**
* @brief Gets a fast, light object wrapping the writable IR map.
* <b>Remarks</b>
*
* The Map Wrapper classes are light wrappers for generated maps saved as @ref glos_frame_object
* "frame objects" in metadata. These wrapper classes provide small data-focused
* objects for simplified data access to frame objects.
*/
inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline XnIRMetaData* GetUnderlying() { return &m_ir; }
private:
// block copy ctor and assignment operator
IRMetaData(const IRMetaData& other);
IRMetaData& operator=(const IRMetaData&);
XnIRMetaData m_ir;
const xn::IRMap m_irMap;
xn::IRMap m_writableIRMap;
};
/**
* @ingroup cppref_meta_data
* For saving the audio data from the @ref xn::AudioGenerator node.
* This saved metadata object provides fast and easy access to the AudioGenerator node's
* data and configuration information.
*/
class AudioMetaData : public OutputMetaData
{
public:
XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_UNALIGNED_ADDRESS_WARNING_ID);
inline AudioMetaData() : OutputMetaData(&m_audio.pData)
{
xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
m_audio.pOutput = OutputMetaData::GetUnderlying();
}
XN_PRAGMA_STOP_DISABLED_WARNING_SECTION;
/**
* @brief Shallow-Copies an AudioMetaData object.
*
* @param [in] other source object.
*
* @remarks Note that the data buffer is not copied, and that both object will point to the same buffer.
*/
inline void InitFrom(const AudioMetaData& other)
{
xnCopyAudioMetaData(&m_audio, &other.m_audio);
}
/**
* @brief Gets the number of channels in each sample. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
/**
* @brief Gets the number of channels in each sample. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
/**
* @brief Gets the rate at which the audio interface was sampled. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
/**
* @brief Gets the rate at which the audio interface was sampled. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
/**
* @brief Gets the number of bits per channel in a sample. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
/**
* @brief Gets the number of bits per channel in a sample. This is a packet configuration setting associated with the saved audio metadata object.
*/
inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
private:
// block copy ctor and assignment operator
AudioMetaData(const AudioMetaData& other);
AudioMetaData& operator=(const AudioMetaData&);
XnAudioMetaData m_audio;
};
/**
* @ingroup cppref_meta_data
* Saves the @ref glos_frame_object "frame object" (data and configuration)
* from the @ref xn::SceneAnalyzer node. This @ref glos_frame_object "frame object"
* is a snapshot of the generated scene data and its associated configuration information
* at a certain point in time. This metadata provides fast and easy access to the SceneAnalyzer
* node's saved frame object.
*/
class SceneMetaData : public MapMetaData
{
public:
inline SceneMetaData() :
MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
{
xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
m_scene.pMap = MapMetaData::GetUnderlying();
}
/**
* @brief Shallow-Copies an SceneMetaData object.
*
* @param [in] other source object.
*
* @remarks Note that the data buffer is not copied, and that both object will point to the same buffer.
*/
inline void InitFrom(const SceneMetaData& other)
{
xnCopySceneMetaData(&m_scene, &other.m_scene);
}
/**
* Shallow copies another SceneMetaData object, and then @ref ReAdjust it.
*
* @param [in] other source object
* @param [in] nXRes requested number of columns in the map
* @param [in] nYRes requested number of rows in the map
* @param [in] pExternalBuffer Optional. An external buffer matching requested resolution. If NULL,
* A buffer will be allocated.
*/
inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
{
InitFrom(other);
return ReAdjust(nXRes, nYRes, pExternalBuffer);
}
/**
* Performs a deep-copy of another metadata object (including duplication of the data buffer)
*
* @param [in] other source object
*/
XnStatus CopyFrom(const SceneMetaData& other)
{
// copy props
xnCopySceneMetaData(&m_scene, &other.m_scene);
// and make a copy of the data (this will allocate and copy data)
return MakeDataWritable();
}
/**
* @copydoc DepthMetaData::ReAdjust
*/
XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
{
return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
}
/**
* @brief Returns the scene map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first scene pixel in the map. The scene
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnLabel, i.e. 16-bit integer values, where every
* user has a distinct label.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
/**
* @brief Returns the scene map.
*
* <b>Remarks</b>
*
* This method returns a pointer to the first scene pixel in the map. The scene
* map is implemented as a row-major order compact layout of pixels in the map.
*
* The pixel format of the map is XnLabel, i.e. 16-bit integer values, where every
* user has a distinct label.
*
* This method is reimplemented from the @ref xn::OutputMetaData class.
*/
inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
/**
* @copydoc OutputMetaData::WritableData
*/
inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); }
/**
* Gets a light object wrapping the label map
*/
inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
/**
* Gets a light object wrapping the writable label map
*/
inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
/**
* Gets the label of a single pixel of the frame map by its index in the array.
*
* @param [in] nIndex The index of the pixel in the buffer.
*
* <b>Remarks</b>
*
* The values are of type @ref XnLabel. Each pixel's value labels it according to
* user.
*/
inline const XnLabel& operator[](XnUInt32 nIndex) const
{
XN_ASSERT(nIndex < (XRes()*YRes()));
return Data()[nIndex];
}
/**
* Gets the label of a single pixel of the frame map by its X and Y positions.
*
* @param [in] x X-coordinate of the pixel in the map
* @param [in] y Y-coordinate of the pixel in the map
*
* <b>Remarks</b>
*
* The values are of type @ref XnLabel. Each pixel's value labels it according to
* user.
*/
inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
{
XN_ASSERT(x < XRes() && y < YRes());
return (*this)[y*XRes() + x];
}
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
/**
* @copydoc OutputMetaData::GetUnderlying
*/
inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
private:
// block copy ctor and assignment operator
SceneMetaData(const SceneMetaData& other);
SceneMetaData& operator=(const SceneMetaData&);
XnSceneMetaData m_scene;
const xn::LabelMap m_labelMap;
xn::LabelMap m_writableLabelMap;
};
//---------------------------------------------------------------------------
// NodeWrapper
//---------------------------------------------------------------------------
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The NodeWrapper class is the base class for all OpenNI production
* node classes in C++, for example, the @ref xn::ProductionNode class and the @ref
* xn::Generator class.
*
* The NodeWrapper class is the C++ API wrapper around the OpenNI C XnNodeHandle API.
*
* <b>Remarks:</b>
*
* A fundamental OpenNI concept that is critical to understand about nodes and node
* creation is that all C++ objects are "smart pointers" to the actual nodes. The reason
* why OpenNI is designed this way is so that the same node can be used to produce data
* (or provide information) for more than just one (dependant) node or for more than
* just one software component.
*
* When instantiating an object of this class, it doesn't point to any actual node. In order
* to create an actual node, use one of the <code>Create()</code> methods (e.g. @ref DepthGenerator::Create()).
*/
class NodeWrapper
{
public:
friend class Context;
/**
* Ctor
*
* @param [in] hNode A node handle.
*/
inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
{
SetHandle(hNode);
}
inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
{
SetHandle(other.GetHandle());
}
inline NodeWrapper& operator=(const NodeWrapper& other)
{
SetHandle(other.GetHandle());
return *this;
}
inline ~NodeWrapper()
{
SetHandle(NULL);
}
inline operator XnNodeHandle() const { return GetHandle(); }
/**
* Gets the underlying C handle.
*/
inline XnNodeHandle GetHandle() const { return m_hNode; }
/**
* Checks if two node references point to the same actual node
*
* @param [in] other Another object
*/
inline XnBool operator==(const NodeWrapper& other)
{
return (GetHandle() == other.GetHandle());
}
/**
* Checks if two node references do <i>not</i> point to the same actual node.
*
* @param [in] other Another object
*/
inline XnBool operator!=(const NodeWrapper& other)
{
return (GetHandle() != other.GetHandle());
}
/** @brief
* This method checks that this object points to an <i>actual</i> node (that has
* been 'created') and does not point to NULL.
*
* Returns TRUE if the object points to a node, i.e., the node has been 'created';
* FALSE otherwise.
*
* <b>Remarks</b>
*
* This method is a very important for managing nodes in the production graph. This
* check is concerned with the stage before actually creating the node, i.e., before
* invoking the node's <code>Create()</code> method.
*/
inline XnBool IsValid() const { return (GetHandle() != NULL); }
/*
* @brief Gets the instance name of a node. Unless the application made a specific
* request for a specific name, the name will be of the form: "Depth1", "Image2", etc.
*/
const XnChar* GetName() const {return xnGetNodeName(GetHandle()); }
/**
* @copybrief xnProductionNodeAddRef
* For full details and usage, see @ref xnProductionNodeAddRef
*/
inline XnStatus AddRef() { return xnProductionNodeAddRef(GetHandle()); }
/**
* Unreference a production node, decreasing its reference count by 1. If the reference count reaches
* zero, the node will be destroyed.
*/
inline void Release()
{
SetHandle(NULL);
}
/**
* Replaces the object being pointed.
*/
inline void SetHandle(XnNodeHandle hNode)
{
if (m_hNode == hNode)
{
// Optimization: do nothing
return;
}
// check currently held node. If we're holding a node, release it
if (m_hNode != NULL)
{
XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode);
xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback);
xnContextRelease(pContext);
xnProductionNodeRelease(m_hNode);
}
// check new node handle, if it points to a node, add ref to it
if (hNode != NULL)
{
XnStatus nRetVal = xnProductionNodeAddRef(hNode);
XN_ASSERT(nRetVal == XN_STATUS_OK);
XN_REFERENCE_VARIABLE(nRetVal);
XnContext* pContext = xnGetRefContextFromNodeHandle(hNode);
nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
XN_ASSERT(nRetVal == XN_STATUS_OK);
xnContextRelease(pContext);
}
m_hNode = hNode;
}
inline void TakeOwnership(XnNodeHandle hNode)
{
SetHandle(hNode);
if (hNode != NULL)
{
xnProductionNodeRelease(hNode);
}
}
/** @cond */
inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
/** @endcond */
private:
XnNodeHandle m_hNode;
XnCallbackHandle m_hShuttingDownCallback;
static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
{
NodeWrapper* pThis = (NodeWrapper*)pCookie;
pThis->m_hNode = NULL;
}
};
//---------------------------------------------------------------------------
// Node Info
//---------------------------------------------------------------------------
/**
* @ingroup cppref_graph_mgmt
* <b>Purpose:</b> This class provides functionality for getting information about a
* @ref node_alternative "node alternative". A @ref node_alternative is either an existing
* node, or a not-yet instantiated alternative.
*
* <b>Remarks:</b>
*
* Each instantiated node has a NodeInfo object and it can be accessed through the @ref
* xn::ProductionNode::GetInfo() method.
*/
class NodeInfo
{
public:
/**
* Ctor
*
* @param [in] pInfo The C object to wrap
*/
NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
{
SetUnderlyingObject(pInfo);
}
/**
* Copy Ctor
*
* @param [in] other An object to copy from.
*/
NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
{
SetUnderlyingObject(other.m_pInfo);
}
/**
* Dtor
*/
~NodeInfo()
{
SetUnderlyingObject(NULL);
}
/**
* Assignment operator
*
* @param [in] other another object
*/
inline NodeInfo& operator=(const NodeInfo& other)
{
SetUnderlyingObject(other.m_pInfo);
return *this;
}
/**
* Gets the underlying C object
*/
inline operator XnNodeInfo*()
{
return m_pInfo;
}
/**
* @brief Sets the instance name of the NodeInfo object. The name can only be set <i>before the instance is created</i>.
*
* @param [in] strName Name to give to this instance.
*/
inline XnStatus SetInstanceName(const XnChar* strName)
{
return xnNodeInfoSetInstanceName(m_pInfo, strName);
}
/**
* @brief Gets the description of a node alternative.
*
* <b>Remarks</b>
*
* When you instantiate a production node object -- for example a DepthGenerator
* -- you cannot access it's NodeInfo object until after <code>Create()</code>
* has been called.
*
* However - you can also get NodeInfo objects by enumeration, for example, from
* the @ref xn::Context::EnumerateProductionTrees() "EnumerateProductionTrees()"
* method.
*/
inline const XnProductionNodeDescription& GetDescription() const
{
return *xnNodeInfoGetDescription(m_pInfo);
}
/**
* @brief Gets the instance name of a node alternative.
*
* <b>Remarks</b>
*
* When you instantiate a DepthGenerator object, for example, you cannot access
* it's NodeInfo object until after its <code>Create()</code> method has been called.
*
* However - you can also get NodeInfo objects by enumeration, for example, from
* the EnumerateProductionTrees() method.
*/
inline const XnChar* GetInstanceName() const
{
return xnNodeInfoGetInstanceName(m_pInfo);
}
/**
* @brief Gets the creation information of the node alternative.
*
* <b>Remarks</b>
*
* A node's creation information is a way for a node implementation to have two
* distinct instances of the same node class, that is two nodes.
* For example, a Device node implementation can use this field for the name of
* the device it represents, so that if two sensors are connected, each will have
* a different value here.
*/
inline const XnChar* GetCreationInfo() const
{
return xnNodeInfoGetCreationInfo(m_pInfo);
}
/*
* @brief Gets the list of dependant nodes for this node alternative.
* These are any other node alternatives that the node is dependant on.
*/
inline NodeInfoList& GetNeededNodes() const;
/**
* Gets a reference to the node instance represented by this node alternative.
*
* @param node [in/out] The production node to be pointing to the node.
*
* @returns an error if this node info object does not point to an actual node.
*/
inline XnStatus GetInstance(ProductionNode& node) const;
/**
* @copybrief xnNodeInfoGetAdditionalData
* For full details and usage, see @ref xnNodeInfoGetAdditionalData
*/
inline const void* GetAdditionalData() const
{
return xnNodeInfoGetAdditionalData(m_pInfo);
}
/**
* @copybrief xnNodeInfoGetTreeStringRepresentation
* For full details and usage, see @ref xnNodeInfoGetTreeStringRepresentation
*/
inline XnStatus GetTreeStringRepresentation(XnChar* csResultBuffer, XnUInt32 nBufferSize) const
{
return xnNodeInfoGetTreeStringRepresentation(m_pInfo, csResultBuffer, nBufferSize);
}
private:
inline void SetUnderlyingObject(XnNodeInfo* pInfo);
XnNodeInfo* m_pInfo;
mutable NodeInfoList* m_pNeededNodes;
XnBool m_bOwnerOfNode; // backwards compatibility
friend class Context;
};
//---------------------------------------------------------------------------
// Query
//---------------------------------------------------------------------------
/**
* @ingroup cppref_graph_mgmt
*
* <b>Purpose:</b> Represents a query, containing filters regarding node info objects.
* Note that the relation between the filters is an AND relation.
*
* <b>Usage: </b> Instantiate a Query object and then use the provided methods to set
* up the filter conditions.
*
* <b>Remarks:</b>
* The Query class provides a mechanism for searching and returning NodeInfo objects
* from a list while filtering them according to a filter argument. The relation between
* the filters is an AND relationship.
*
* The mechanism works by instantiating a Query object and then using the provided methods
* to set up the filter conditions. The Query object is then used by a number of methods
* that search for nodes, e.g., the Create() method.
*/
class Query
{
public:
inline Query() : m_bAllocated(TRUE)
{
xnNodeQueryAllocate(&m_pQuery);
}
inline Query(XnNodeQuery* pNodeQuery) : m_bAllocated(FALSE), m_pQuery(pNodeQuery)
{
}
~Query()
{
if (m_bAllocated)
{
xnNodeQueryFree(m_pQuery);
}
}
/**
* Gets the underlying C object
*/
inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
/**
* @brief Sets in the Query object the vendor name to search for.
* @param [in] strVendor Vendor Name.
*/
inline XnStatus SetVendor(const XnChar* strVendor)
{
return xnNodeQuerySetVendor(m_pQuery, strVendor);
}
/**
* @brief Sets in the Query object the implementation name to search for.
* The same vendor might have more than one implementation, for example,
* two @ref xn::DepthGenerator "DepthGenerators" "SensorV2" and "EEDepthGenerator".
* This is not the same as the instance name.
*
* @param [in] strName Implementation name.
*/
inline XnStatus SetName(const XnChar* strName)
{
return xnNodeQuerySetName(m_pQuery, strName);
}
/**
* @brief Sets in the Query object the minimum required version allowed for the @ref node_alternative.
*/
inline XnStatus SetMinVersion(const XnVersion& minVersion)
{
return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
}
/**
* @brief Sets in the Query object the minimum required version allowed for the @ref node_alternative.
*/
inline XnStatus SetMinVersion(const Version& minVersion)
{
return xnNodeQuerySetMinVersion(m_pQuery, minVersion.GetUnderlying());
}
/**
* @brief Sets in the Query object the maximum required version allowed for the node alternative.
*/
inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
{
return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
}
/**
* @brief Sets in the Query object the maximum required version allowed for the node alternative.
*/
inline XnStatus SetMaxVersion(const Version& maxVersion)
{
return xnNodeQuerySetMaxVersion(m_pQuery, maxVersion.GetUnderlying());
}
/**
* @brief Sets in the Query object a capability that the @ref node_alternative must support.
*
* @param [in] strNeededCapability Name of the capability that the @ref node_alternative
* must support.
*
* <b>Remarks</b>
*
* Note that for checking if a capability is supported, the node must be created
* if it's not an already existing node. This operation might take a bit longer
* than usual.
*/
inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
{
return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
}
/**
* @brief Sets in the Query object a MapOutput mode that the @ref node_alternative must support.
*
* @param [in] MapOutputMode Map output mode. Each field of the mode can be set to
* (-1), meaning results will not be filtered by this field.
*
* @remark Note that for checking if a capability is supported, the node must be created
* if it's not an already existing node. This operation might take a bit longer
* than usual.
*/
inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
{
return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
}
/**
* @copybrief xnNodeQuerySetSupportedMinUserPositions
* For full details and usage, see @ref xnNodeQuerySetSupportedMinUserPositions
*/
inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
{
return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
}
/**
* @brief Sets in the Query object that the query will return only existing nodes,
* i.e., nodes that have been created, in other words their <code>Create()</code> method has been called.
*
* @param [in] bExistingNode TRUE to return only existing nodes, FALSE otherwise.
*
* <b>Remarks</b>
*
* Note that there are many ways to create nodes, not just by their @ref create_method
* "Create() method".
*/
inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
{
return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
}
/**
* @brief Sets in the Query object that a specified node must be a dependant of the named node type.
* @param [in] strInstanceName Name of the needed node.
*/
inline XnStatus AddNeededNode(const XnChar* strInstanceName)
{
return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
}
/**
* @brief Sets the creation information field of the Query object. This relates to the creation information of the @ref xn::NodeInfo class.
* @param [in] strCreationInfo Creation information to set in the Query object.
*/
inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
{
return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
}
private:
XnNodeQuery* m_pQuery;
XnBool m_bAllocated;
};
//---------------------------------------------------------------------------
// Node Info List
//---------------------------------------------------------------------------
/**
* @ingroup cppref_graph_mgmt
* A NodeInfoList object contains a list of @ref NodeInfo objects.
*/
class NodeInfoList
{
public:
/**
* Represents an iterator over a @ref NodeInfoList list.
*/
class Iterator
{
public:
friend class NodeInfoList;
/**
* Returns whether the iterator points to the same location as another iterator.
*
* @param [in] other Another iterator
*
* <b>Remarks</b>
*
* This method can be used for checking if the two iterators are pointing to
* the same NodeInfo object.
*
* Note that the two iterators can also both point to NULL.
*/
XnBool operator==(const Iterator& other) const
{
return m_it.pCurrent == other.m_it.pCurrent;
}
/**
* Returns whether the iterator points to a different location than another
* iterator.
*
* @param [in] other Another iterator
*/
XnBool operator!=(const Iterator& other) const
{
return m_it.pCurrent != other.m_it.pCurrent;
}
/**
* Moves the iterator to the next object. If the end of the list was reached,
* the iterator will now be equal to @ref NodeInfoList::End().
*/
inline Iterator& operator++()
{
UpdateInternalObject(xnNodeInfoListGetNext(m_it));
return *this;
}
/**
* Returns an iterator pointing at the next object. If the end of the list was
* reached, that iterator will now be equal to @ref NodeInfoList::End().
*/
inline Iterator operator++(int)
{
XnNodeInfoListIterator curr = m_it;
UpdateInternalObject(xnNodeInfoListGetNext(m_it));
return Iterator(curr);
}
/**
* Moves the iterator to the previous object.
*/
inline Iterator& operator--()
{
UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
return *this;
}
/**
* Returns an iterator pointing at the previous object.
*/
inline Iterator operator--(int)
{
XnNodeInfoListIterator curr = m_it;
UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
return Iterator(curr);
}
/**
* Gets the @ref NodeInfo object pointed by the iterator.
*/
inline NodeInfo operator*()
{
return m_Info;
}
private:
inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
{
UpdateInternalObject(it);
}
inline void UpdateInternalObject(XnNodeInfoListIterator it)
{
m_it = it;
if (xnNodeInfoListIteratorIsValid(it))
{
XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
m_Info = NodeInfo(pInfo);
}
else
{
m_Info = NodeInfo(NULL);
}
}
NodeInfo m_Info;
XnNodeInfoListIterator m_it;
};
/**
* Creates a new @ref NodeInfoList object.
*/
inline NodeInfoList()
{
xnNodeInfoListAllocate(&m_pList);
m_bAllocated = TRUE;
}
/**
* Creates a new @ref NodeInfoList object by wrapping a C @ref XnNodeInfoList object.
* Note that this list will not be freed upon destruction.
*
* @param [in] pList The list to wrap.
*/
inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
inline ~NodeInfoList()
{
FreeImpl();
}
/**
* Gets the underlying C object.
*/
inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
/**
* Replaces the underlying object, taking ownership of the object (meaning, it
* will be freed upon destruction).
*
* @param [in] pList The list to wrap.
*/
inline void ReplaceUnderlyingObject(XnNodeInfoList* pList)
{
FreeImpl();
m_pList = pList;
m_bAllocated = TRUE;
}
/**
* @copybrief xnNodeInfoListAdd
* For full details and usage, see @ref xnNodeInfoListAdd
*/
inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
{
XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
}
/**
* @copybrief xnNodeInfoListAddEx
* For full details and usage, see @ref xnNodeInfoListAddEx
*/
inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
{
XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
}
/**
* @copybrief xnNodeInfoListAddNode
* For full details and usage, see @ref xnNodeInfoListAddNode
*/
inline XnStatus AddNode(NodeInfo& info)
{
return xnNodeInfoListAddNode(m_pList, info);
}
/**
* @copybrief xnNodeInfoListAddNodeFromList
* For full details and usage, see @ref xnNodeInfoListAddNodeFromList
*/
inline XnStatus AddNodeFromAnotherList(Iterator& it)
{
return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
}
/**
* Returns an iterator to the beginning of the list. If the list
* is empty, that iterator will be equal to @ref NodeInfoList::End().
*/
inline Iterator Begin() const
{
return Iterator(xnNodeInfoListGetFirst(m_pList));
}
/**
* Returns an iterator marking the end of the list.
* This iterator does not point to a valid item.
*/
inline Iterator End() const
{
XnNodeInfoListIterator it = { NULL };
return Iterator(it);
}
/**
* Returns an iterator to the reverse beginning of the list. If the list
* is empty, that iterator will be equal to @ref NodeInfoList::REnd().
*/
inline Iterator RBegin() const
{
return Iterator(xnNodeInfoListGetLast(m_pList));
}
/**
* Returns an iterator marking the reverse end of the list.
* This iterator does not point to a valid item.
*/
inline Iterator REnd() const
{
XnNodeInfoListIterator it = { NULL };
return Iterator(it);
}
/**
* @copybrief xnNodeInfoListRemove
* For full details and usage, see @ref xnNodeInfoListRemove
*/
inline XnStatus Remove(Iterator& it)
{
return xnNodeInfoListRemove(m_pList, it.m_it);
}
/**
* @copybrief xnNodeInfoListClear
* For full details and usage, see @ref xnNodeInfoListClear
*/
inline XnStatus Clear()
{
return xnNodeInfoListClear(m_pList);
}
/**
* @copybrief xnNodeInfoListAppend
* For full details and usage, see @ref xnNodeInfoListAppend
*/
inline XnStatus Append(NodeInfoList& other)
{
return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
}
/**
* @brief Checks if the list NodeInfoList object is empty.
*/
inline XnBool IsEmpty()
{
return xnNodeInfoListIsEmpty(m_pList);
}
/**
* @copybrief xnNodeQueryFilterList
* For full details and usage, see @ref xnNodeQueryFilterList
*/
inline XnStatus FilterList(Context& context, Query& query);
private:
inline void FreeImpl()
{
if (m_bAllocated)
{
xnNodeInfoListFree(m_pList);
m_bAllocated = FALSE;
m_pList = NULL;
}
}
XnNodeInfoList* m_pList;
XnBool m_bAllocated;
};
//---------------------------------------------------------------------------
// Production Nodes Functionality
//---------------------------------------------------------------------------
/**
* @ingroup cppref_prd_func
* Base class for all capabilities.
*/
class Capability : public NodeWrapper
{
public:
/**
* Ctor
*
* @param [in] hNode The node handle
*/
Capability(XnNodeHandle hNode) : NodeWrapper(hNode) {}
Capability(const NodeWrapper& node) : NodeWrapper(node) {}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The Error State capability lets a node report that it has entered
* an error state, and so might not function correctly.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref ProductionNode::GetErrorStateCap()
* to obtain an instance.
*
* <b>Remarks:</b>
*
* An application can use the @ref GetErrorState() method to get the error state of
* a node at any time, and it can also register a callback function to be called whenever
* the error state changes.
*
* The error state of a node is represented using @ref XnStatus. A value of @ref XN_STATUS_OK
* means the node is OK. Any other value represents some sort of error situation in
* the node.
*
* <b>Event: 'Error State Change'</b>
*
* Signals that the @ref holder_node "holder node"'s error state has changed.
*
* This is the same value that can be obtained by the @ref GetErrorState() method.
*
* This event can be used by the application to get a signal as soon as any error occurs
* in the @ref holder_node "holder node". By handling all the error states of all nodes,
* the application can use this event to respond immediately to any error situation.
*
* Use @ref RegisterToErrorStateChange() and @ref UnregisterFromErrorStateChange() for using this event.
*
* Instead of registering to the error state callback of all the nodes in the context,
* an application may register to the 'Global Error State Change' event - see @ref context_global_error_event.
*/
class ErrorStateCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
ErrorStateCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Gets the current error state of the holding node.
*/
inline XnStatus GetErrorState() const
{
return xnGetNodeErrorState(GetHandle());
}
/**
* @brief Registers an event handler for the 'Error State Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback. To be used for unregistering the callback.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Error State Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* Allows access to general integer capabilities functions - see @ref general_int for
* additional details.
*/
class GeneralIntCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
* @param [in] strCap Name of the capability
*/
GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
GeneralIntCapability(const NodeWrapper& node, const XnChar* strCap) : Capability(node), m_strCap(strCap) {}
/**
* @copybrief xnGetGeneralIntRange
* For full details and usage, see @ref xnGetGeneralIntRange
*/
inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
{
xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
}
/**
* @copybrief xnGetGeneralIntValue
* For full details and usage, see @ref xnGetGeneralIntValue
*/
inline XnInt32 Get()
{
XnInt32 nValue;
xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
return nValue;
}
/**
* @copybrief xnSetGeneralIntValue
* For full details and usage, see @ref xnSetGeneralIntValue
*/
inline XnStatus Set(XnInt32 nValue)
{
return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
}
/**
* @brief Registers an event handler for the 'Value Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
/**
* @brief Unregisters the event handler for the 'Value Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
void UnregisterFromValueChange(XnCallbackHandle hCallback);
private:
const XnChar* m_strCap;
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The ProductionNode class is a base class for all production nodes
* and generator nodes. As such, the ProductionNode class is the fundamental base class
* of the entire OpenNI interface for building and accessing the production graph.
*
* <b>Usage:</b> Base class for all production nodes; not usually instantiated.
*
* <b>Class Overview:</b>
*
* The OpenNI Production Graph is comprised entirely of production nodes of one type
* or another. The ProductionNode class itself exposes a very limited functionality
* set. This is the most basic and common functionality set of all the nodes in the
* graph.
*
* All types of core generator nodes are derived from this ProductionNode class, for
* example, the @ref xn::DepthGenerator node and the @ref xn::Device node. Each node
* type has its own set of methods that it supports.
*
* Two of the most important methods provided by the ProductionNode class are @ref IsCapabilitySupported()
* and @ref GetContext(), both described further below.
*
* <b>Capabilities Mechanism:</b>
*
* In addition to being the base class for all core generator nodes, the ProductionNode
* class also provides key support for the OpenNI capabilities mechanism. OpenNI defines
* core functionality which is always supported by all node implementations of a specific node
* type. Additional optional functionality is also defined by OpenNI and exposed
* as "capabilities".
* The ProductionNode class provides the @ref IsCapabilitySupported() method to check
* if this specific implementation supports a certain capability.
*
* For a comprehensive overview to the Capabilities mechanism see @ref conc_capabilities
* "Capabilities Mechanism".
*/
class ProductionNode : public NodeWrapper
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
/**
* @brief Gets information about the node.
*
* <b>Remarks</b>
*
* This method returns a @ref xn::NodeInfo object containing information such as
* the node description and the identities of dependent nodes.
*/
inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
/**
* @copybrief xnAddNeededNode
* For full details and usage, see @ref xnAddNeededNode
*/
inline XnStatus AddNeededNode(ProductionNode& needed)
{
return xnAddNeededNode(GetHandle(), needed.GetHandle());
}
/**
* @copybrief xnRemoveNeededNode
* For full details and usage, see @ref xnRemoveNeededNode
*/
inline XnStatus RemoveNeededNode(ProductionNode& needed)
{
return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
}
/**
* @brief Gets the node's context.
*
* @param [out] context The node's context.
*
* <b>Remarks</b>
*
* This method is useful for applications that have to take into account the
* possibility of multiple contexts. Using this method, the application can access
* all other nodes and other resources within the same context.
*/
inline void GetContext(Context& context) const;
/**
* @brief Gets the node's context
*
* <b>Remarks</b>
*
* This method is useful for applications that have to take into account the
* possibility of multiple contexts. Using this method, the application can access
* all other nodes and other resources within the same context.
*/
inline Context GetContext() const;
/**
* @brief Returns whether a production node supports a specific capability.
*
* @param [in] strCapabilityName The capability name to check.
*
* <b>Remarks</b>
*
* The application specifies the capability by supplying the capability's name in
* the <i>strCapabilityName</i> parameter. Before attempting to access any capability
* this method should be used to check that this node actually supports this capability.
*/
inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
{
return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
}
/**
* @copybrief xnSetIntProperty
* For full details and usage, see @ref xnSetIntProperty
*/
inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
{
return xnSetIntProperty(GetHandle(), strName, nValue);
}
/**
* @copybrief xnSetRealProperty
* For full details and usage, see @ref xnSetRealProperty
*/
inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
{
return xnSetRealProperty(GetHandle(), strName, dValue);
}
/**
* @copybrief xnSetStringProperty
* For full details and usage, see @ref xnSetStringProperty
*/
inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
{
return xnSetStringProperty(GetHandle(), strName, strValue);
}
/**
* @copybrief xnSetGeneralProperty
* For full details and usage, see @ref xnSetGeneralProperty
*/
inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
{
return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
}
/**
* @copybrief xnGetIntProperty
* For full details and usage, see @ref xnGetIntProperty
*/
inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
{
return xnGetIntProperty(GetHandle(), strName, &nValue);
}
/**
* @copybrief xnGetRealProperty
* For full details and usage, see @ref xnGetRealProperty
*/
inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
{
return xnGetRealProperty(GetHandle(), strName, &dValue);
}
/**
* @copybrief xnGetStringProperty
* For full details and usage, see @ref xnGetStringProperty
*/
inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
{
return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
}
/**
* @copybrief xnGetGeneralProperty
* For full details and usage, see @ref xnGetGeneralProperty
*/
inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
{
return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
}
/**
* @copybrief xnLockNodeForChanges
* For full details and usage, see @ref xnLockNodeForChanges
*/
inline XnStatus LockForChanges(XnLockHandle* phLock)
{
return xnLockNodeForChanges(GetHandle(), phLock);
}
/**
* @copybrief xnUnlockNodeForChanges
* For full details and usage, see @ref xnUnlockNodeForChanges
*/
inline void UnlockForChanges(XnLockHandle hLock)
{
xnUnlockNodeForChanges(GetHandle(), hLock);
}
/**
* @copybrief xnLockedNodeStartChanges
* For full details and usage, see @ref xnLockedNodeStartChanges
*/
inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
{
return xnLockedNodeStartChanges(GetHandle(), hLock);
}
/**
* @copybrief xnLockedNodeEndChanges
* For full details and usage, see @ref xnLockedNodeEndChanges
*/
inline void LockedNodeEndChanges(XnLockHandle hLock)
{
xnLockedNodeEndChanges(GetHandle(), hLock);
}
/**
* @brief Gets an @ref xn::ErrorStateCapability object for accessing the functionality
* of the Error State capability.
*
* <b>Remarks:</b>
* The application is responsible for first checking if @ref XN_CAPABILITY_ERROR_STATE
* is supported by calling @ref xn::ProductionNode::IsCapabilitySupported().
*/
inline const ErrorStateCapability GetErrorStateCap() const
{
return ErrorStateCapability(GetHandle());
}
/**
* @brief Gets an @ref xn::ErrorStateCapability object for accessing the functionality
* of the Error State capability.
*
* <b>Remarks:</b>
* The application is responsible for first checking if @ref XN_CAPABILITY_ERROR_STATE
* is supported by calling @ref xn::ProductionNode::IsCapabilitySupported()
*/
inline ErrorStateCapability GetErrorStateCap()
{
return ErrorStateCapability(GetHandle());
}
/**
* @brief Gets an @ref GeneralIntCapability object for accessing the capability
* functionality.
*
* <b>Remarks:</b>
*
* It is the application responsibility to check first if the capability is supported
* by calling @ref IsCapabilitySupported().
*
* @param [in] strCapability Name of the capability to get
*/
inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
{
return GeneralIntCapability(GetHandle(), strCapability);
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The DeviceIdentificationCapability object allows an application to
* receive some device-specific information about a hardware device, like its serial
* number and its model name.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref Device::GetIdentificationCap()
* to obtain an instance.
*/
class DeviceIdentificationCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
DeviceIdentificationCapability(XnNodeHandle hNode) : Capability(hNode) {}
DeviceIdentificationCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Gets the name of the device holding this capability object.
*
* @param [in] strBuffer Buffer to accept the device information.
* @param [in,out] nBufferSize Size of the buffer.
*
* @retval XN_STATUS_OK Operation succeeded.
* @retval XN_STATUS_OUTPUT_BUFFER_OVERFLOW The size of the buffer is not sufficient.
*/
inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
{
return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
}
/**
* @brief Gets the vendor-specific name of the device holding this capability object.
*
* @param [in] strBuffer Buffer to accept the device information.
* @param [in,out] nBufferSize Size of the buffer.
*
* @retval XN_STATUS_OK Operation succeeded.
* @retval XN_STATUS_OUTPUT_BUFFER_OVERFLOW The size of the buffer is not sufficient.
*/
inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
{
return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
}
/**
* @brief Gets the vendor-specific name of the device holding this capability object.
*
* @param [in] strBuffer Buffer to accept the serial number
* @param [in,out] nBufferSize Size of the buffer.
*
* @retval XN_STATUS_OK Operation succeeded.
* @retval XN_STATUS_OUTPUT_BUFFER_OVERFLOW The size of the buffer is not sufficient.
*/
inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
{
return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> A smart pointer to a device node in the
* production graph of a context.
*
* The device node represents a physical hardware device
* currently connected in the system and used for generating data.
* The Device node represents the hardware device by providing, for example,
* the device's model name, serial number, and some vendor-specific data.
* The Device node itself does not generate data.
*
* <b>Capabilities:</b> @ref DeviceIdentificationCapability
*/
class Device : public ProductionNode
{
public:
inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline Device(const NodeWrapper& other) : ProductionNode(other) {}
/**
* @brief Creates a Device node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks</b>
*
* See @ref create_method "Concepts: the Create() Method" for a detailed description
* of the operation of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* Gets a @ref DeviceIdentificationCapability object for accessing device identification
* functionality.
*
* <b>Remarks</b>
*
* If this node supports this method then the node can identify which device is
* being used right now, for example, its name, serial number, and specific
* vendors can place specific data.
*
* It is the application's responsibility to check first if @ref XN_CAPABILITY_DEVICE_IDENTIFICATION
* is supported by calling @ref IsCapabilitySupported().
*/
inline DeviceIdentificationCapability GetIdentificationCap()
{
return DeviceIdentificationCapability(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> Applying the MirrorCapability to a node allows enabling the Mirroring
* mode on a per node basis. Compare this with enabling the Global Mirror, which applies
* mirroring to any node supporting the Mirroring capability. To understand mirroring
* see the Overview below.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref Generator::GetMirrorCap()
* to obtain an instance.
*
* <b>Remarks:</b>
*
* When you stand facing the sensor device, and the image is processed directly,
* the sensor "sees" your left hand at your right-hand side, and your right hand
* at your left-hand side.
*
* If your movements are used to control an avatar, and that avatar is facing you then
* the avatar on the screen is opposite: your right hand is facing the left of the avatar
* on the screen, and your left hand is facing the right of the avatar.
*
* The effect of applying and enabling the Mirroring capability on a node makes all
* the data replace right with left, and left with right.
*
* Thus, if mirroring is <i>disabled</i> (default), then when you raise your right hand,
* the avatar on the screen opposite you correspondingly also raises its own right hand,
* this being to the left of yourself.
*
* If mirroring is <i>enabled</i>, when you raise your right hand on the screen the
* avatar opposite you mirrors you by raising its hand on your right, which is the avatar's
* <i>left</i> hand.
*
* Enabling mirroring is useful when the avatar is facing the player. Disabling mirroring
* is useful when the player sees the avatar from behind (for example in third person
* shooters or to see yourself kicking a football).
*
* Changing the GlobalMirror flag affects mirroring in all existing nodes and in all
* nodes to be created in the future - see @ref Context::SetGlobalMirror().
*
* <b>Event: 'Mirror Change'</b>
*
* Signals that the @ref holder_node "holder node"'s mirror configuration has been changed (also see @ref event_cmn_conf).
*
* Use @ref RegisterToMirrorChange() and @ref UnregisterFromMirrorChange() for using this event.
*
* Calling the @ref SetMirror() method raises this event.
*/
class MirrorCapability : public Capability
{
public:
inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
MirrorCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Sets the current mirror configuration of the @ref holder_node "holder node",
* enabling or disabling mirroring. This configuration is used for generating the next frame.
*
* @param [in] bMirror TRUE for mirroring output, FALSE otherwise.
*/
inline XnStatus SetMirror(XnBool bMirror)
{
return xnSetMirror(GetHandle(), bMirror);
}
/**
* @brief Gets the current mirroring configuration of the @ref holder_node "holder node". This configuration is used for generating the next frame.
*/
inline XnBool IsMirrored() const
{
return xnIsMirrored(GetHandle());
}
/**
* @brief Registers an event handler for the 'Mirror Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Mirror Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> The AlternativeViewPoint capability enables any type of map generator
* (depth, image, or IR) to transform its data to appear as if the sensor is placed
* in another location. The other location is represented by a second production node,
* usually representing another sensor.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref Generator::GetAlternativeViewPointCap()
* to obtain an instance.
*
* <b>Remarks:</b>
*
* This capability provides a solution for the situation where you want to impose
* color over depth, but there is then the problem that the two sensing media (transducers)
* are looking in slightly different directions. This capability superimposes the two
* sensing media of one sensor.
*
* Other uses are also possible.
*
* @note The AlternativeViewPoint capability has nothing to do with the actual physical
* position of a sensor. You could move the location of the sensor itself, but this
* will not change the current viewpoint.
*
* <b>Event: 'Viewpoint Change' </b>
*
* Signals that the @ref holder_node "holder node"'s viewpoint has changed (also see @ref event_cmn_conf).
*
* Use @ref RegisterToViewPointChange() and @ref UnregisterFromViewPointChange() for using this event.
*
* Calling the @ref SetViewPoint() or @ref ResetViewPoint() methods raises this event.
*/
class AlternativeViewPointCapability : public Capability
{
public:
inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
AlternativeViewPointCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Checks if the generator node holding this capability can change its output to appear
* as if the sensor was placed at the viewpoint of another specific @ref xn::ProductionNode
* "production node".
*
* @param [in] otherNode Other production node, whose viewpoint against which this
* node's viewpoint is being checked.
*
* <b>Remarks</b>
*
* This is not the same as @ref xn::ProductionNode::IsCapabilitySupported(). Although
* the node implementation supports this capability, it may nevertheless support only
* the viewpoints of nodes of some specific sensors and not of other specific sensors.
*/
inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
{
return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
}
/**
* @brief Sets the current viewpoint of the holding generator node to look as if it
* is placed at a different generator location. All further generated output will appear
* as if the sensor was placed at the different location.
*
* @param [in] otherNode Viewpoint to be set.
*/
inline XnStatus SetViewPoint(ProductionNode& otherNode)
{
return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
}
/**
* @brief Sets the viewpoint of the holding generator node to its normal viewpoint.
*/
inline XnStatus ResetViewPoint()
{
return xnResetViewPoint(GetHandle());
}
/**
* @brief Returns whether the @ref holder_node "holder node"'s viewpoint is the same
* viewpoint as that of another specified node. Thus, this method is somewhat of an equality operator.
*
* @param [in] otherNode Other node, whose viewpoint is used for comparison with
* the viewpoint of this node.
*/
inline XnBool IsViewPointAs(ProductionNode& otherNode) const
{
return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
}
/**
* @brief Registers a handler for the 'Viewpoint Change' event (see the above overview to this class).
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the the 'Viewpoint Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The Frame Sync capability allows frame synchronization between two
* @ref xn::Generator "generator" nodes producing frame data. This lets the two sensors
* output their frames at the same time. This allows smaller latency between two maps
* of the same scene, for example, a depth map and an image map.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref Generator::GetFrameSyncCap()
* to obtain an instance.
*
* <b>Event: 'Frame Sync Change'</b>
*
* Signals that the @ref holder_node "holder node"'s frame synchronization setting has
* been changed. That is, this setting has changed from activated to deactivated, or
* from deactivated to activated, or the frame synchronization has been changed and
* is now synchronized with a different 'other node'.
*
* Use @ref RegisterToFrameSyncChange() and @ref UnregisterFromFrameSyncChange() for using this event.
*
* Calling the @ref FrameSyncWith() or @ref StopFrameSyncWith() methods raises this event.
*/
class FrameSyncCapability : public Capability
{
public:
inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
FrameSyncCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Returns whether the generator node holding this capability can
* synchronize frames with the other specified node.
*
* @param [in] other Specifies the other node to be checked whether it can
* frame-sync with the node holding this capability.
* @returns TRUE if frame-sync to the other node is supported; FALSE otherwise.
*/
inline XnBool CanFrameSyncWith(Generator& other) const;
/**
* @brief Activates frame synchronization with the other generator node.
*
* @param [in] other Specifies the other node to be frame sync-ed with the node
* holding this capability.
*/
inline XnStatus FrameSyncWith(Generator& other);
/**
* @brief Removes the frame sync between the node holding this capability and the specified other node.
* @param [in] other Specifies the other node from which to remove the frame sync.
*/
inline XnStatus StopFrameSyncWith(Generator& other);
/**
* @brief Returns whether a frame sync has been applied between the node holding this capability and
* another specified node.
* @param [in] other Specifies the other node for checking whether frame sync has
* been applied.
*/
inline XnBool IsFrameSyncedWith(Generator& other) const;
/**
* @brief Registers an event handler for the 'Frame Sync Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the 'Frame Sync Change' event handler.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> A generator node produces some type of data. This is in addition
* to the node's basic characteristic, as a derivative of the @ref xn::ProductionNode
* class, i.e., that it represents a logical entity in the OpenNI @ref prod_graph "Production
* Graph".
*
* <b>Usage summary</b>: Immediate base class for all generator types. It itself is
* not usually instantiated.
*
* <b>Class Overview:</b>
*
* Each generator can be in Generating state or Non-Generating state. The application makes
* the node enter Generating state by calling the @ref xn::Generator::StartGenerating()
* method.
*
* When a generator node is created, by default it is in Non-Generating state, so it
* does not generate data.
*
* Generators have a default configuration (for example the FOV resolution) and an application
* can change the default configuration before actual data generation starts.
*
* Once the application has completed configuring the generator node, the application
* can cause the node to start generating data.
*
* Typically, the application will configure the generator only in the configuration
* stage, i.e., in Non-Generating state. The application can usually also configure
* the node while generating data, however configuration might then take longer and
* the application could also lose some frames of data. For example, if the application
* changes the resolution while in the Configuration stage (Non-Generating state), the
* resolution change occurs immediately; but if the application changes the configuration
* while the generator is generating data, the resolution change can take up to a few
* seconds to occur.
*
* <b>Data Storage:</b>
*
* Each call to an @ref conc_updating_data "'Update Data'" method updates the generator
* node's application buffer, making the latest data available for applications to access.
* After a call to an @ref conc_updating_data "'Update Data'" method, all subsequent
* calls to @ref GetData() will return exactly the same data until you call @ref conc_updating_data
* "'Update Data'" again. The @ref conc_updating_data "'Update Data'" method can be
* the generator node's own @ref WaitAndUpdateData() method or one of the Context's
* @ref conc_updating_data "'WaitXUpdateAll'" methods.
*
* <b>Getting the Generated Data:</b>
*
* Generator nodes will not output data to make it available for getting, until the
* application calls the node's WaitAndUpdateData() method (see below) or one of the
* context's @ref conc_updating_data "'WaitXUpdateAll'" methods.
*
* @ref conc_updating_data__sample_code_cmn
*/
class Generator : public ProductionNode
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
/**
* @brief Enters the node into Generating state.
*
* Enters the node into Generating state. In this state the node generates new frames.
*
* After the application has called this method it can call an @ref conc_updating_data
* "'Update Data'" method, e.g., @ref xn::Generator::WaitAndUpdateData(), to make
* a new frame available for getting. The application can then get the data (for
* example, using a metadata GetData() method, or some other mechanism depending
* on the type of node).
*
* <b>Remarks:</b>
*
* On entering the node into Generating state, OpenNI enters also all dependent
* nodes into Generating state. For example, if a UserGenerator node depends on
* data input from a DepthGenerator node, and the UserGenerator node is entered
* into Generating state, then OpenNI will enter also the DepthGenerator node into
* Generating state.
*/
inline XnStatus StartGenerating()
{
return xnStartGenerating(GetHandle());
}
/**
* @brief Returns whether the node is currently in Generating state.
*/
inline XnBool IsGenerating() const
{
return xnIsGenerating(GetHandle());
}
/**
* @brief Makes the node leave Generating state (enters Non-Generating state).
*
* <b>Remarks:</b>
*
* If the node has metadata, after calling this method the data is still available
* as a saved @ref glos_frame_object "frame object" in the metadata object.
*/
inline XnStatus StopGenerating()
{
return xnStopGenerating(GetHandle());
}
/**
* @brief Registers an event handler for the 'Generation State Change' event.
*
* Registers a callback function to be called when generation starts or
* stops, i.e., when the generation state toggles between generating and not
* generating.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
{
return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the 'Generation State Change' event handler.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
}
/**
* @brief Registers an event handler for the 'New Data Available' event.
*
* The 'New Data Available' event is raised whenever a generator node has new data available. The new
* data is available for updating, but can not yet be accessed by the application. The application
* needs to call @ref conc_updating_data "'Update Data'" to gain access to that new data.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
{
return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'New Data Available' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
}
/**
* @brief Returns whether the node has new data available.
* The new data is available for updating, but can not yet be accessed by the application. The application
* needs to call @ref conc_updating_data "'Update Data'" to gain access to that new data.
*
* @param [out] pnTimestamp [Optional] If new data is available (TRUE is returned from the method),
* this param will hold the timestamp of that new data.
*/
inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
{
return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
}
/**
* @brief Updates the generator node to the latest available data, first waiting for the node to have new data available.
*
* <b>Remarks:</b>
*
* This method requests from OpenNI to cause the node to update its application buffers
* with new data, if it has new data available.
*
* At this stage the generator node has "generated" new data. This method returns a
* success status. The application can now read the newly generated data.
*
* An error situation is defined as: after a preset timeout, the node has not yet notified
* OpenNI it has new data available. On error, the method stops waiting and returns
* an error status.
*
* @retval XN_STATUS_INVALID_OPERATION This production node is not a generator.
* @retval XN_STATUS_WAIT_DATA_TIMEOUT No new data available within 2 seconds.
*/
inline XnStatus WaitAndUpdateData()
{
return xnWaitAndUpdateData(GetHandle());
}
/**
* Returns whether this node's frame data was updated by the most recent call to
* any @ref conc_updating_data "'WaitXUpdateAll()'" function, e.g., @ref xn::Context::WaitAnyUpdateAll().
*/
inline XnBool IsDataNew() const
{
return xnIsDataNew(GetHandle());
}
/**
* @brief Gets the @ref frame_data "frame data" from the generator node. This is
* the latest data that the generator node has generated.
*
* <b>Remarks:</b>
*
* This method gets the data directly from the Generator node; not from the metadata
* object.
*
* Compare this method with the Data() method of the @ref xn::OutputMetaData object,
* where the latter gets the data from the metadata object.
* GetData() returns the same data as the GetMetaData().Data() method. However,
* using the GetData() method is slightly more costly.
*
* The application usually should not use this method, but call each generator own
* data access methods, e.g. DepthGenerator::GetDepthMap().
*/
inline const void* GetData()
{
return xnGetData(GetHandle());
}
/**
* @brief Gets the data size of the @ref frame_data "frame data".
* This method gets the data size directly from the Generator node.
*
* <b>Remarks:</b>
*
* The size of the data is returned as a number of bytes.
*
* Compare this method with the DataSize() method of the @ref xn::OutputMetaData
* object, where the latter gets the data from the metadata object.
* GetDataSize() returns the same data as the GetMetaData().DataSize() method. However,
* using the GetDataSize() method is slightly more costly.
*/
inline XnUInt32 GetDataSize() const
{
return xnGetDataSize(GetHandle());
}
/**
* @brief Gets the frame timestamp from the <b>Generator</b> node
* This method gets the timestamp directly from the Generator node.
*
* <b>Remarks:</b>
*
* The time is returned in microseconds.
*
* Compare this method with the <b>GetTimestamp()</b> method of the @ref xn::OutputMetaData
* object, where the latter gets the data from the metadata object.
* <b>GetTimestamp()</b> returns the same data as the GetMetaData().GetTimestamp()
* method. However, using the <b>GetTimestamp()</b> method is slightly more costly.
*/
inline XnUInt64 GetTimestamp() const
{
return xnGetTimestamp(GetHandle());
}
/**
* @brief Gets the frame ID of the current frame data from the Generator node.
*
* <b>Remarks:</b>
*
* This method gets the frame ID directly from the Generator node.
*
* Compare this method with the <b>GetFrameID()</b> method of the @ref xn::OutputMetaData
* object, where the latter gets the data from the metadata object.
* <b>GetFrameID()</b> returns the same data as the GetMetaData().GetFrameID() method.
* However, using the <b>GetFrameID()</b> method is slightly more costly.
*/
inline XnUInt32 GetFrameID() const
{
return xnGetFrameID(GetHandle());
}
/**
* @brief Gets a @ref MirrorCapability object for accessing Mirror functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if @ref XN_CAPABILITY_MIRROR
* is supported by calling @ref xn::ProductionNode::IsCapabilitySupported().
*/
inline const MirrorCapability GetMirrorCap() const
{
return MirrorCapability(GetHandle());
}
/**
* @brief Gets a @ref MirrorCapability object for accessing Mirror functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if @ref XN_CAPABILITY_MIRROR
* is supported by calling @ref xn::ProductionNode::IsCapabilitySupported().
*/
inline MirrorCapability GetMirrorCap()
{
return MirrorCapability(GetHandle());
}
/**
* Gets an @ref AlternativeViewPointCapability object for accessing Alternative
* Viewpoint functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if
* @ref XN_CAPABILITY_ALTERNATIVE_VIEW_POINT is supported
* by calling @ref xn::Generator::IsCapabilitySupported().
*/
inline const AlternativeViewPointCapability GetAlternativeViewPointCap() const
{
return AlternativeViewPointCapability(GetHandle());
}
/**
* Gets an @ref AlternativeViewPointCapability object for accessing Alternative
* Viewpoint functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if
* @ref XN_CAPABILITY_ALTERNATIVE_VIEW_POINT is supported
* by calling @ref xn::Generator::IsCapabilitySupported().
*/
inline AlternativeViewPointCapability GetAlternativeViewPointCap()
{
return AlternativeViewPointCapability(GetHandle());
}
/**
* Gets an @ref FrameSyncCapability object for accessing Frame Sync functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if
* @ref XN_CAPABILITY_FRAME_SYNC is supported
* by calling @ref xn::Generator::IsCapabilitySupported().
*/
inline const FrameSyncCapability GetFrameSyncCap() const
{
return FrameSyncCapability(GetHandle());
}
/**
* Gets an @ref FrameSyncCapability object for accessing Frame Sync functionality.
*
* <b>Remarks:</b>
*
* It is the application's responsibility to check first if
* @ref XN_CAPABILITY_FRAME_SYNC is supported
* by calling @ref xn::Generator::IsCapabilitySupported().
*/
inline FrameSyncCapability GetFrameSyncCap()
{
return FrameSyncCapability(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> To create and manage a Recorder node.
*
* <b>Usage: </b> Instatiate and create a Recorder node.
*
* <b>Data output:</b> Records to a specified destination medium the frames of data
* from each node that was added to the Recorder node.
*
* <b>Remarks:</b>
*
* Recordings are a powerful debug tool. A recording enables a full capture of data
* generation and the ability to later play it back by 'regeneration' so that applications
* can simulate an exact replica of the situation to be debugged.
*
* OpenNI supports recordings of the production nodes in the production graph, both
* the entire configuration of each node, and all data streamed from a node.
*
* OpenNI has a framework for recording data and for playing it back (using mock nodes).
* It also comes with the nimRecorder module, which defines a new file format (".ONI")
* - and implements a Recorder node and a Player node for this format.
*
* If a recorder exists while generating, the @ref conc_updating_data "'WaitXUpdateAll'"
* functions automatically record the data from all nodes added to this recorder.
*
* To record, an application creates a Recorder node, and set its destination - the
* file name to which it should write. The application must add to the Recorder node
* every production node that it wants to record. When adding a node to the recorder,
* the Recorder stores its configuration. It also registers to every possible event
* of the node, so that when any configuration change takes place, it is also recorded.
*
* Once all required nodes are added, the application can read data from the nodes and
* record it. Recording of data can be achieved either by explicitly calling the @ref
* xn::Recorder::Record() function, or by using one of the @ref conc_updating_data "'Update
* All'" functions.
*
* Applications that initialize OpenNI using an XML file can easily record their session
* without any change to the code. All that is required is that they create an additional
* node in the XML file for the recorder, add nodes to it, and when the application
* calls one of the 'WaitXUpdateAll' functions, recording will occur. see @ref xmlscripts
* for explanation on how to do that.
*
* Recordings are played back by using the services of the Player class.
*/
class Recorder : public ProductionNode
{
public:
/**
* Ctor
*
* @param [in] hNode A node handle
*/
inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
/**
* @brief Creates a Recorder node.
*
* @param [in] context The context in which to create the Recorder node.
* @param [in] strFormatName Optional. The name of the format the recorded file
* will be in. If NULL, file will be in ONI format.
*/
inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
/**
* @brief Specifies to where the recorder must send its recording. Typically this is a disk file of a particular file type.
*
* @param [in] destType The type of medium to record to. Currently only XN_RECORD_MEDIUM_FILE
* is supported.
* @param [in] strDest Recording destination. If destType is XN_RECORD_MEDIUM_FILE,
* this specifies a file name.
*/
inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
{
return xnSetRecorderDestination(GetHandle(), destType, strDest);
}
/**
* @brief Gets the destination medium for the Recorder node to record to.
*
* @param [out] destType The type of medium to record to. Currently only XN_RECORD_MEDIUM_FILE
* is supported.
* @param [out] strDest Recording destination. If destType is XN_RECORD_MEDIUM_FILE,
* this specifies a file name.
* @param [in] nBufSize Destination buffer size.
*/
inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
{
return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
}
/**
* @brief Adds a node to the recording setup, and starts recording data what the node generates.
* This method must be called for each node to be recorded with this recorder.
*
* @param [in] Node Node to add to the recording.
* @param [in] compression Type of compression that will be used to encode the node's
* data (see @ref XnCodecIDs.h). If @ref XN_CODEC_NULL
* is specified, a default compression will be chosen according to the node type.
*/
inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
{
return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
}
/**
* @brief Removes a node from the Recorder node and stops recording the node output.
* This function is called on a node that was added to recording with @ref AddNodeToRecording.
*
* @param [in] Node The node to remove from recording.
*/
inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
{
return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
}
/**
* @brief Records one frame of data from each node that was added to the recorder with AddNodeToRecording().
*
* <b>Remarks</b>
*
* To record continually, the recorder node must be called repeatedly for each frame.
*
* It is highly recommended that an application use the 'WaitXUpdateAll' methods,
* and not call Generator::WaitAndUpdateData() for each generator. When working
* with the 'WaitXUpdateAll' methods, OpenNI will automatically call @ref Record(),
* and there is no need for the application to call this method.
*/
inline XnStatus Record()
{
return xnRecord(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> The Player class is used for creating and managing a Player node.
* This node plays a saved recording of an OpenNI data generation session.
*
* <b>Remarks:</b>
*
* To play a file recording, use the @ref xn::Context::OpenFileRecording() function.
* OpenNI will open the file, create a mock node for each node in the file, and populate
* it with the recorded configuration.
*
* An application may take the nodes it needs by calling the @ref xn::Context::FindExistingNode()
* method, and use them normally.
*
* @note Nodes created by the player are locked, and cannot be changed, as the
* configuration must remain according to the recorded configuration.
*
* Applications that initialize OpenNI using an XML file can easily replace their input.
* This means that instead of reading from a physical device, which generates data in
* real-time, they read from a recording by replacing the nodes in the XML file with
* a recording element (see @ref xmlscripts).
*
* @note It is not the Player node itself that is generating data. (Accordingly, the
* Player node does not provide a GetData() method.) The Player node reads data from
* the file, and "pushes" it into the mock nodes.
*/
class Player : public ProductionNode
{
public:
/**
* Ctor
*
* @param [in] hNode Player node handle
*/
inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline Player(const NodeWrapper& other) : ProductionNode(other) {}
/**
* @brief Creates a player node.
*
* <b>Remarks</b>
*
* See @ref create_method "Concepts: the Create() Method" for a detailed description
* about the operation of this method.
*/
inline XnStatus Create(Context& context, const XnChar* strFormatName);
/**
* @brief Specifies whether the player will automatically rewind to the beginning
* of the recording after reaching the end of the recording.
*
* @param [in] bRepeat Determines whether the player will repeat or not.
*
* If bRepeat is set to TRUE, the player will automatically
* rewind when reaching the end.
*
* If bRepeat is set to FALSE, the player will stop playing
* when reaching the end, and will raise the 'End-Of-File Reached'
* event. In this state, @ref IsEOF() returns TRUE, and
* calls to @ref ReadNext() will fail.
*/
inline XnStatus SetRepeat(XnBool bRepeat)
{
return xnSetPlayerRepeat(GetHandle(), bRepeat);
}
/**
* @copybrief xnSetPlayerSource
* For full details and usage, see @ref xnSetPlayerSource
*/
inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
{
return xnSetPlayerSource(GetHandle(), sourceType, strSource);
}
/**
* @brief Gets the player's source, that is, the type and name of the medium
* that the recording is played back from.
*
* @param [out] sourceType Player's source type.
* @param [in] strSource Player's source.
* @param [in] nBufSize Size of the buffer specified by @c strSource.
*/
inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
{
return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
}
/**
* @copybrief xnPlayerReadNext
* For full details and usage, see @ref xnPlayerReadNext
*/
inline XnStatus ReadNext()
{
return xnPlayerReadNext(GetHandle());
}
/**
* @brief Moves the player to a specific time, so that playback will continue from that point onwards.
*
* @param [in] nTimeOffset Offset to move, relative to the specified origin. <br>
* Units in microseconds. <br> See the remark below.
* @param [in] origin Origin to seek from. See the remarks below.
*
* The meaning of the @c nTimeOffset parameter changes according to the origin parameter:
*
* <b>XN_PLAYER_SEEK_SET:</b> @c nTimeOffset specifies the total time passed since
* the beginning of the recording. This must be a positive value.
*
* <b>XN_PLAYER_SEEK_CUR:</b> @c nTimeOffset specifies a period of time to move, relative
* to the current player position. A positive value means to move forward, and a
* negative value means to move backwards.
*
* <b>XN_PLAYER_SEEK_END:</b> @c nTimeOffset specifies a period of time to move, relative
* to the end of the recording. This must be a negative value.
*
* <b>Remarks</b>
*
* For the built-in ONI player, this function is not currently supported and always
* returns XN_STATUS_NOT_IMPLEMENTED.
*/
inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
{
return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
}
/**
* @brief Moves the player to a specific frame of a specific played node, e.g., an
* ImageGenerator node, so that playing will continue from that frame onwards.
*
* @param [in] strNodeName Name of the node.
* @param [in] nFrameOffset Number of frames to move, relative to the specified
* origin. See remarks below.
* @param [in] origin Origin to seek from. See remarks below.
*
* The meaning of the @c nFrameOffset parameter changes according to the origin parameter:
*
* <b>XN_PLAYER_SEEK_SET:</b> @c nFrameOffset specifies the total number of frames
* since the beginning of the node's recording. This must be a positive value.
*
* <b>XN_PLAYER_SEEK_CUR:</b> @c nFrameOffset specifies the number of frames to move,
* relative to the current frame of the specified node. A positive value means to
* move forward, and a negative value means to move backwards.
*
* <b>XN_PLAYER_SEEK_END:</b> @c nFrameOffset specifies the number of frames to move,
* relative to the end of the node's recording. This must be a negative value.
*
* You can get different results using this function for different values of strNodeName,
* because the frame numbers of different nodes are not necessarily in sync.
*/
inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
{
return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
}
/**
* @brief Gets the current time of a player, i.e., the time passed since the beginning of the recording.
*
* @param [out] nTimestamp Retrieved timestamp. Units are in microseconds.
*/
inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
{
return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
}
/**
* @brief Gets the current frame number of a specific node played by a player,
* i.e., the number of frames passed since the beginning of the recording
*
* @param [in] strNodeName Name of the node.
* @param [out] nFrame Retrieved frame number.
*
* <b>Remarks</b>
*
* Different nodes that belong to the player can have different frame numbers, because
* the nodes are not necessarily in synchronization.
*/
inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
{
return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
}
/**
* @brief Gets the total number of frames a specific node has in the recording.
*
* @param [in] strNodeName Name of the node for which to retrieve the number of frames.
* @param [out] nFrames Retrieved number of frames.
*
*/
inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
{
return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
}
/**
* @copybrief xnGetPlayerSupportedFormat
* For full details and usage, see @ref xnGetPlayerSupportedFormat
*/
inline const XnChar* GetSupportedFormat() const
{
return xnGetPlayerSupportedFormat(GetHandle());
}
/**
* @copybrief xnEnumeratePlayerNodes
* For full details and usage, see @ref xnEnumeratePlayerNodes
*/
inline XnStatus EnumerateNodes(NodeInfoList& list) const
{
XnNodeInfoList* pList;
XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
XN_IS_STATUS_OK(nRetVal);
list.ReplaceUnderlyingObject(pList);
return (XN_STATUS_OK);
}
/**
* @brief Returns whether the player is at the end-of-file marker.
*
* <b>Remarks</b>
*
* When Repeat mode is on, this function never returns TRUE.
* However, the 'End of File Reached' event will be raised during rewind.
*/
inline XnBool IsEOF() const
{
return xnIsPlayerAtEOF(GetHandle());
}
/**
* @brief Registers an event handler for the 'End-Of-File Reached' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'End-Of-File Reached' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
}
/**
* @brief Sets the player's playback speed, as a ratio of the rate that the recording was made at.
*
* @param [in] dSpeed The speed ratio.
*
* <b>Values: </b>
*
* @c dSpeed = 1.0 - Player will try to output frames at the same rate they were recorded
* (according to their timestamps).
*
* @c dSpeed > 1.0 - Fast-forward
*
* 0 < @c dSpeed < 1.0 - Slow-motion.
*
* @c dSpeed = XN_PLAYBACK_SPEED_FASTEST (0.0) - There will be no delay, and frames
* will be returned immediately on demand.
*
*/
inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
{
return xnSetPlaybackSpeed(GetHandle(), dSpeed);
}
/**
* @brief Gets the playback speed.
* @returns Speed ratio, or -1.0 if this node is not a player.
*/
inline XnDouble GetPlaybackSpeed() const
{
return xnGetPlaybackSpeed(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> Provides Cropping capability for @ref MapGenerator "map generator nodes".
* Cropping capability restricts the size of the data frames to be generated by the
* MapGenerator node to a selected (cropped) area of the full field-of-view.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref MapGenerator::GetCroppingCap()
* to obtain an instance.
*
* <b>Remarks:</b>
*
* When cropping is enabled, the size of the generated map is reduced to fit a lower
* resolution (smaller FOV dimensions). For example, if the map generator is working
* in VGA resolution (640x480) and the application chooses to crop at 300x200, the next
* pixel row will begin after 300 pixels. Pixels outside the cropping area are not returned
* in the buffer - they are not blacked out; they are not returned at all. Thus, cropping
* is very useful for providing a performance boost.
*
* <b>Event: 'Cropping Change'</b>
*
* Signals that the @ref holder_node "holder node"'s cropping area has been changed.
*
* Use @ref RegisterToCroppingChange() and @ref UnregisterFromCroppingChange() for using this event.
*
* Calling the @ref SetCropping() method raises this event.
*/
class CroppingCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
CroppingCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Sets the @ref holder_node "holder node"'s current cropping
* configuration. This configuration is used for generating the next frame.
*
* @param [in] Cropping Cropping configuration to be set.
*
* @retval XN_STATUS_INVALID_OPERATION The @ref MapGenerator node does not support
* the Cropping capability.
*/
inline XnStatus SetCropping(const XnCropping& Cropping)
{
return xnSetCropping(GetHandle(), &Cropping);
}
/**
* @brief Gets the current cropping configuration of the @ref holder_node "holder node".
* This configuration is that set by @ref SetCropping(). This configuration is used
* for generating the next frame.
*
* @param [out] Cropping Retreived cropping configuration.
*
* @retval XN_STATUS_INVALID_OPERATION The @ref MapGenerator node does not
* support the Cropping capability.
*/
inline XnStatus GetCropping(XnCropping& Cropping) const
{
return xnGetCropping(GetHandle(), &Cropping);
}
/**
* @brief Registers an event handler for the 'Cropping Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Cropping Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* Allows access to <b>Anti Flicker</b> capability functions. see @ref anti_flicker
* for additional details.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref MapGenerator::GetAntiFlickerCap()
* to obtain an instance.
*/
class AntiFlickerCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline AntiFlickerCapability(XnNodeHandle hNode) : Capability(hNode) {}
AntiFlickerCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @copybrief xnSetPowerLineFrequency
* For full details and usage, see @ref xnSetPowerLineFrequency
*/
inline XnStatus SetPowerLineFrequency(XnPowerLineFrequency nFrequency)
{
return xnSetPowerLineFrequency(GetHandle(), nFrequency);
}
/**
* @copybrief xnGetPowerLineFrequency
* For full details and usage, see @ref xnGetPowerLineFrequency
*/
inline XnPowerLineFrequency GetPowerLineFrequency()
{
return xnGetPowerLineFrequency(GetHandle());
}
/**
* @brief Registers an event handler for the 'Power Line Frequency Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToPowerLineFrequencyChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Power Line Frequency Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromPowerLineFrequencyChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> The MapGenerator class is the base class for every generator node
* that produces 2D map data, for example, depth maps, color image maps, IR maps, and
* scene analysis maps.
*
* <b>Usage: </b> This class might be instantiated to reference any kind of map generator
* node (i.e., a node that derives from the MapGenerator class), however it is not intended
* to ever be instantiated to create any node of MapGenerator type itself.
*
* <b>Remarks:</b>
*
* Since the MapGenerator class is the base class for generator nodes that produce image
* maps, it provides the data structures common to all map generators: the current frame's
* X and Y dimensions and its frame rate.
*
* MapGenerator's two principle functions are GetMapOutputMode() and SetMapOutputMode()
* for controlling and checking the node's map output mode. The map output mode is the
* combination of the node's scene resolution and frame rate. Correspondingly, these
* functions read and write an @ref xn::XnMapOutputMode structure, comprising three
* parameters: the X and Y resolutions and the frame rate.
*/
class MapGenerator : public Generator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
/**
* @brief Gets the number of output modes that the generator node supports.
*
* <b>Remarks</b>
*
* This is useful for allocating an array that will be passed to GetSupportedMapOutputModes().
*/
inline XnUInt32 GetSupportedMapOutputModesCount() const
{
return xnGetSupportedMapOutputModesCount(GetHandle());
}
/**
* @brief Gets a list of all the output modes that the generator node supports.
*
* <b>Remarks</b>
*
* Each supported map output mode is represented by a @ref XnMapOutputMode structure
* comprising resolution (@c nXRes and @c nYRes) and frames rate (@c nFPS). The application
* then chooses one of the output modes. The size of the array that should be passed
* can be obtained by calling GetSupportedMapOutputModesCount().
*/
inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
{
return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
}
/**
* @brief Sets the current map output mode of the generator node.
*
* <b>Remarks</b>
*
* A map output mode is contained in a @ref xn::XnMapOutputMode structure comprising
* the frame rate (in frames per second), and the X and Y dimensions (the number
* of elements in each of the X- and Y- axes).
*
* It is the application programmer's responsibility to check first if the output
* mode is supported by calling the @ref xn::MapGenerator::GetSupportedMapOutputModes()
* "GetSupportedMapOutputModes()" method.
*/
inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
{
return xnSetMapOutputMode(GetHandle(), &OutputMode);
}
/**
* @brief Gets the current map output mode of the generator node. This is the
* map output mode that the generator node will use to generate the next data frame.
*
* <b>Remarks</b>
*
* A map output mode is the combination of the scene resolution and frame rate.
* It is contained in an @ref xn::XnMapOutputMode structure comprising the frame
* rate (in frames per second), and the X and Y dimensions (the number of elements
* in each of the X- and Y- axes).
*
* For the map output mode of the most recent data frame available in the node's
* metadata object, see the @ref xn::MapMetaData class (MapMetaData::Xres(), MapMetaData::YRes(),
* and MapMetaData::FPS() methods).
*
* This map output mode is the mode set by @ref SetMapOutputMode().
*/
inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
{
return xnGetMapOutputMode(GetHandle(), &OutputMode);
}
/**
* @brief Gets the number of bytes per pixel for the node's map data. This mode
* is set by SetPixelFormat() for the next frame that the generator node generates.
*
* <b>Remarks</b>
*
* In ImageGenerator this can be set. In other generators, it's pre-defined.
*/
inline XnUInt32 GetBytesPerPixel() const
{
return xnGetBytesPerPixel(GetHandle());
}
/**
* @brief Registers an event handler for the 'Map Output Mode Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Map Output Mode Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
}
/**
* @brief Gets a @ref CroppingCapability object for accessing Cropping functionality.
*
* <b>Remarks</b>
*
* It is the application's responsibility to check first if @ref XN_CAPABILITY_CROPPING
* is supported by calling @ref IsCapabilitySupported().
*/
inline const CroppingCapability GetCroppingCap() const
{
return CroppingCapability(GetHandle());
}
/**
* @brief Gets a @ref CroppingCapability object for accessing Cropping functionality.
*
* <b>Remarks</b>
*
* It is the application's responsibility to check first if @ref XN_CAPABILITY_CROPPING
* is supported by calling @ref IsCapabilitySupported().
*/
inline CroppingCapability GetCroppingCap()
{
return CroppingCapability(GetHandle());
}
/**
* Gets an @ref GeneralIntCapability object for accessing Brightness functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_BRIGHTNESS
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetBrightnessCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BRIGHTNESS);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Contrast functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_CONTRAST
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetContrastCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_CONTRAST);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Hue functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_HUE
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetHueCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_HUE);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Saturation functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_SATURATION
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetSaturationCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SATURATION);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Sharpness functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_SHARPNESS
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetSharpnessCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SHARPNESS);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Gamma functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_GAMMA
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetGammaCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAMMA);
}
/**
* Gets an @ref GeneralIntCapability object for accessing WhiteBalance functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_COLOR_TEMPERATURE
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetWhiteBalanceCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_COLOR_TEMPERATURE);
}
/**
* Gets an @ref GeneralIntCapability object for accessing BacklightCompensation functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_BACKLIGHT_COMPENSATION
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetBacklightCompensationCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BACKLIGHT_COMPENSATION);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Gain functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_GAIN
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetGainCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAIN);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Pan functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_PAN
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetPanCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_PAN);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Tilt functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_TILT
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetTiltCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_TILT);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Roll functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_ROLL
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetRollCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ROLL);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Zoom functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_ZOOM
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetZoomCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ZOOM);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Exposure functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_EXPOSURE
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetExposureCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_EXPOSURE);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Iris functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_IRIS
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetIrisCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_IRIS);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Focus functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_FOCUS
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetFocusCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_FOCUS);
}
/**
* Gets an @ref GeneralIntCapability object for accessing Low Light Compensation functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_LOW_LIGHT_COMPENSATION
* is supported by calling @ref IsCapabilitySupported().
*/
inline GeneralIntCapability GetLowLightCompensationCap()
{
return GeneralIntCapability(GetHandle(), XN_CAPABILITY_LOW_LIGHT_COMPENSATION);
}
/**
* Gets an @ref AntiFlickerCapability object for accessing Anti Flicker functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_ANTI_FLICKER
* is supported by calling @ref IsCapabilitySupported().
*/
inline AntiFlickerCapability GetAntiFlickerCap()
{
return AntiFlickerCapability(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
* Allows access to <b>User Position</b> capability functions. see @ref userpos for
* additional details.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref DepthGenerator::GetUserPositionCap()
* to obtain an instance.
*/
class UserPositionCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
UserPositionCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @copybrief xnGetSupportedUserPositionsCount
* For full details and usage, see @ref xnGetSupportedUserPositionsCount
*/
inline XnUInt32 GetSupportedUserPositionsCount() const
{
return xnGetSupportedUserPositionsCount(GetHandle());
}
/**
* @copybrief xnSetUserPosition
* For full details and usage, see @ref xnSetUserPosition
*/
inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
{
return xnSetUserPosition(GetHandle(), nIndex, &Position);
}
/**
* @copybrief xnGetUserPosition
* For full details and usage, see @ref xnGetUserPosition
*/
inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
{
return xnGetUserPosition(GetHandle(), nIndex, &Position);
}
/**
* @brief Registers an event handler for the 'User Position Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'User Position Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> A DepthGenerator node generates depth maps. Each pixel value of
* a depth map represents a distance from the sensor's plane in millimeters.
*
* <b>Usage:</b> Instantiate the class and call Create() to create a DepthGenerator
* node.
*
* This class is at the first level of classes in the OpenNI class hierarchy that is
* typically instantiated to create an actual node. (Examples of other classes at the
* first level are @ref xn::ImageGenerator and @ref xn::SceneAnalyzer).
*
* <b>Data output:</b> Depth maps and associated configuration data. Access via the node's
* @ref xn::DepthMetaData object.
*
* <b>Overview:</b>
*
* A DepthGenerator node generates a depth map as an array of pixels, where each pixel
* is a depth value representing a distance from the sensor's plane in millimeters. This is
* the Z-coordinate of the X-Y-Z coordinate of each user pixel. A smaller depth value
* indicates a scene point that is <i>closer</i> to the hardware sensor device; and
* a larger depth value indicates a scene point that is a <i>further away</i> from the
* sensor. A zero depth value indicates that the DepthGenerator node did not succeed
* in obtaining a valid depth reading.
*
* Typically, the process of generating 3D data begins by using a sensor device that
* produces raw output data. Dedicated middleware is then used to process this raw output,
* and produce a higher-level output, which can then be understood and used by the application.
*
* In a typical OpenNI production graph, a DepthGenerator node takes input directly
* from a sensor device and generates a depth map. Other generator nodes further along
* the production graph (dependant on the DepthGenerator node) take input from the DepthGenerator
* node's output. However, alternative dependency configurations are also possible.
*
* The DepthGenerator node's data and associated configuration are accessed through
* its @ref glos_frame_object "frame object" (i.e., its @ref xn::DepthMetaData object).
*
* Summary of Main Features:
* - Depth map: Provides the data of the depth map
* - Sensor device's maximum depth: Provides the maximum distance available for this
* depth generator
* - Field of View: Provides the sensor's maximum horizontal and vertical angles
* - User Position capability (optional)
*/
class DepthGenerator : public MapGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
/**
* @brief Creates a DepthGenerator node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks:</b>
*
* For full details and usage, see @ref create_method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Gets the depth generator node's latest @ref glos_frame_object "frame object", saving
* it in the @ref xn::DepthMetaData object. This @ref glos_frame_object "frame object" is a
* snapshot of the generated depth map data and its associated configuration information at a
* certain point in time. This saved @ref glos_frame_object "frame object" provides fast
* and easy access to the depth generator node's data and configuration information.
*
* @param [out] metaData Structure to be filled with the frame object.
*
* <b>Remarks:</b>
*
* This method is central in the use of the DepthGenerator node. Once the DepthGenerator
* node is generating data, after each @ref conc_updating_data "'Update Data'" call,
* the application calls this method to get the node's frame object, which contains
* the data and all its associated properties.
*/
inline void GetMetaData(DepthMetaData& metaData) const
{
xnGetDepthMetaData(GetHandle(), metaData.GetUnderlying());
}
/**
* @copybrief xnGetDepthMap
* For full details and usage, see @ref xnGetDepthMap
*/
inline const XnDepthPixel* GetDepthMap() const
{
return xnGetDepthMap(GetHandle());
}
/**
* @brief Gets the maximum depth value that the DepthGenerator node can generate.
* The maximum depth value is a hardware specification of the sensor.
*
* <b>Remarks:</b>
*
* A typical maximum depth supports up to 10 meters of depth. Units are in millimeters,
* so the maximum depth value for 10 meters of depth would range from 0 to 10,000.
*/
inline XnDepthPixel GetDeviceMaxDepth() const
{
return xnGetDeviceMaxDepth(GetHandle());
}
/**
* @brief Gets the dimensions of the field of view (FOV) of the hardware sensor.
*
* @param [out] FOV A struct to be filled with the field of view of the hardware sensor.
*
* <b>Remarks:</b>
*
* This method gets the dimensions of the field of view in radians. Radians are
* used for the output form since they are a spherical measurement and the FOV is
* defined in terms of the angle of width and height that the sensor sees, e.g.,
* 0.524 radians (30 degrees) above and below, and 1.047 radians (60 degrees) left
* and right.
*
* This method is useful for developers building algorithms to convert between real
* world and productive coordinate systems. Although OpenNI offers its own functionality
* for converting real-world and productive coordinate systems, some developers
* may wish to build their own conversion functions for reasons of optimization.
*/
inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
{
return xnGetDepthFieldOfView(GetHandle(), &FOV);
}
/**
* @brief Registers an event handler for the 'Field-Of-View Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Field-Of-View Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
}
/**
* @brief Converts a list of points from projective coordinates to real world coordinates.
*
* @param [in] nCount Number of points to convert.
* @param [in] aProjective Array of projective point coordinates.
* @param [in,out] aRealWorld Array to be filled with real-world point coordinates.
*
* See @ref conc_coord for futher information.
*/
inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
{
return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
}
/**
* @brief Converts a list of points from real world coordinates to projective coordinates.
*
* @param [in] nCount Number of points to convert.
* @param [in] aRealWorld Array of projective point coordinates.
* @param [in,out] aProjective Array to be filled with real-world point coordinates.
*
* See @ref conc_coord for futher information.
*/
inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
{
return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
}
/**
* Gets an @ref UserPositionCapability object for accessing User Position functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_USER_POSITION
* is supported by calling @ref IsCapabilitySupported().
*/
inline const UserPositionCapability GetUserPositionCap() const
{
return UserPositionCapability(GetHandle());
}
/**
* Gets an @ref UserPositionCapability object for accessing User Position functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_USER_POSITION
* is supported by calling @ref IsCapabilitySupported().
*/
inline UserPositionCapability GetUserPositionCap()
{
return UserPositionCapability(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
* Represents a mock depth generator
*/
class MockDepthGenerator : public DepthGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
/**
* Creates a mock depth generator
*
* @param [in] context The context in which the node should be generated
* @param [in] strName Optional. The name of the new node.
*/
XnStatus Create(Context& context, const XnChar* strName = NULL);
/**
* Creates a mock depth generator, copying the initial state from another depth
* generator.
*
* @param [in] other The depth generator to copy state from
* @param [in] strName Optional. The name of the new node.
*/
XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
/**
* @copybrief xnMockDepthSetData
* For full details and usage, see @ref xnMockDepthSetData
*/
inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
{
return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
}
/**
* Sets the data of the mock node from a meta data object, overriding frame ID and
* timestamp
*
* @param [in] depthMD Object to take data from
* @param [in] nFrameID Frame ID
* @param [in] nTimestamp Timestamp
*/
inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
{
return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
}
/**
* Sets the data of the mock node from a metadata object.
*
* @param [in] depthMD Object to take data from
*/
inline XnStatus SetData(const DepthMetaData& depthMD)
{
return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The ImageGenerator node generates color image maps of various formats.
*
* <b>Usage:</b> Instantiate the class and create an image generator node
*
* <b>Data output:</b> Image maps
*
* <b>Overview:</b>
*
* The ImageGenerator node generates color image maps of various formats, such as the
* RGB24 image format. Call its SetPixelFormat() method to set the image format to be
* generated.
*
* The other important function here is GetMetaData(), which, as in other generator
* nodes, gets the image frame object, through which you can access all the properties
* and the actual data of the saved frame.
*/
class ImageGenerator : public MapGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
/**
* @brief Creates and initializes an ImageGenerator node from available @ref node_alternative "production node alternatives".
*
* For full details and usage, see @ref create_method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Gets the image generator node's latest @ref glos_frame_object "frame object", saving
* it in the @ref xn::ImageMetaData object. This @ref glos_frame_object "frame object" is a
* snapshot of the generated image map data and its associated configuration information at a
* certain point in time. This saved @ref glos_frame_object "frame object" provides fast
* and easy access to the image generator node's data and configuration information.
*
* @param [out] metaData Structure to be filled with the frame object.
*
* <b>Remarks:</b>
*
* This method is central in the use of the ImageGenerator node. Once the ImageGenerator
* node is generating data, after each @ref conc_updating_data "'Update Data'" call,
* the application calls this method to get the node's frame object, which contains
* the data and all its associated properties.
*/
inline void GetMetaData(ImageMetaData& metaData) const
{
xnGetImageMetaData(GetHandle(), metaData.GetUnderlying());
}
/**
* @copybrief xnGetRGB24ImageMap
* For full details and usage, see @ref xnGetRGB24ImageMap
*/
inline const XnRGB24Pixel* GetRGB24ImageMap() const
{
return xnGetRGB24ImageMap(GetHandle());
}
/**
* @copybrief xnGetYUV422ImageMap
* For full details and usage, see @ref xnGetYUV422ImageMap
*/
inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
{
return xnGetYUV422ImageMap(GetHandle());
}
/**
* @copybrief xnGetGrayscale8ImageMap
* For full details and usage, see @ref xnGetGrayscale8ImageMap
*/
inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
{
return xnGetGrayscale8ImageMap(GetHandle());
}
/**
* @copybrief xnGetGrayscale16ImageMap
* For full details and usage, see @ref xnGetGrayscale16ImageMap
*/
inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
{
return xnGetGrayscale16ImageMap(GetHandle());
}
/**
* @copybrief xnGetImageMap()
* For full details, see @ref xnGetImageMap().
*/
inline const XnUInt8* GetImageMap() const
{
return xnGetImageMap(GetHandle());
}
/**
* @brief Returns whether the ImageGenerator node supports a specific
* pixel color format for the image map.
*
* @param [in] Format The format to check for.
*
* <b>Remarks</b>
*
* Use this method before setting the pixel format for the next frame to be generated.
*/
inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
{
return xnIsPixelFormatSupported(GetHandle(), Format);
}
/**
* @brief Sets the ImageGenerator node's current 'pixel color' format.
* This format is used for generating the next frame.
*
* @param [in] Format The format to set.
*
* <b>Remarks</b>
*
* As an example of a pixel color format, the RGB24 image format has one byte for
* red, one byte for green, and one byte for blue.
*
* When reading the generated data you must use the appropriate 'get' function,
* e.g., call RGB24Data() to read data generated as the RGB24Data format.
*
* It is the user responsibility to check first if the pixel format is supported
* by calling @ref xn::ImageGenerator::IsPixelFormatSupported().
*/
inline XnStatus SetPixelFormat(XnPixelFormat Format)
{
return xnSetPixelFormat(GetHandle(), Format);
}
/**
* @brief Gets the current pixel color format. This is the format set
* using @ref xn::ImageGenerator node::SetPixelFormat().
*
* <b>Remarks</b>
*
* To get the pixel format of the saved frame - in the @ref glos_frame_object "frame
* object" - use the appropriate method of the node's associated @ref xn::ImageMetaData
* object.
*/
inline XnPixelFormat GetPixelFormat() const
{
return xnGetPixelFormat(GetHandle());
}
/**
* @brief Registers an event handler for the 'Pixel Format Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters the event handler for the 'Pixel Format Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* Represents a mock image generator
*/
class MockImageGenerator : public ImageGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
/**
* Creates a mock image generator
*
* @param [in] context The context in which the node should be generated
* @param [in] strName Optional. The name of the new node.
*/
XnStatus Create(Context& context, const XnChar* strName = NULL);
/**
* Creates a mock image generator, copying the initial state from another image
* generator.
*
* @param [in] other The image generator to copy state from
* @param [in] strName Optional. The name of the new node.
*/
XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
/**
* @copybrief xnMockImageSetData
* For full details and usage, see @ref xnMockImageSetData
*/
inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
{
return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
}
/**
* Sets the data of the mock node from a meta data object, overriding frame ID and
* timestamp
*
* @param [in] imageMD Object to take data from
* @param [in] nFrameID Frame ID
* @param [in] nTimestamp Timestamp
*/
inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
{
return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
}
/**
* Sets the data of the mock node from a meta data object.
*
* @param [in] imageMD Object to take data from
*/
inline XnStatus SetData(const ImageMetaData& imageMD)
{
return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> An IRGenerator node is a map generator that outputs infra-red maps.
*
* <b>Usage:</b> Instantiate and create an IR generator node
*
* <b>Data output:</b> IR maps
*/
class IRGenerator : public MapGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
/**
* @brief Creates an IRGenerator node from available @ref node_alternative "production node alternatives".
*
* See @ref create_method for a detailed description
* about the operation of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Gets the IR generator node's latest @ref glos_frame_object "frame object", saving
* it in the @ref xn::IRMetaData object. This @ref glos_frame_object "frame object" is a
* snapshot of the generated IR map data and its associated configuration information at a
* certain point in time. This saved @ref glos_frame_object "frame object" provides fast
* and easy access to the IR generator node's data and configuration information.
*
* @param [out] metaData Structure to be filled with the frame object.
*
* <b>Remarks:</b>
*
* This method is central in the use of the IRGenerator node. Once the IRGenerator
* node is generating data, after each @ref conc_updating_data "'Update Data'" call,
* the application calls this method to get the node's frame object, which contains
* the data and all its associated properties.
*/
inline void GetMetaData(IRMetaData& metaData) const
{
xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
}
/**
* @brief Gets a pointer to the latest IR map.
*/
inline const XnIRPixel* GetIRMap() const
{
return xnGetIRMap(GetHandle());
}
};
/**
* @ingroup cppref_prd_func
* Represents a mock IR generator
*/
class MockIRGenerator : public IRGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
/**
* Creates a mock IR generator
*
* @param [in] context The context in which the node should be generated
* @param [in] strName Optional. The name of the new node.
*/
XnStatus Create(Context& context, const XnChar* strName = NULL);
/**
* Creates a mock IR generator, copying the initial state from another IR generator.
*
* @param [in] other The IR generator to copy state from
* @param [in] strName Optional. The name of the new node.
*/
XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
/**
* @copybrief xnMockIRSetData
* For full details and usage, see @ref xnMockIRSetData
*/
inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
{
return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
}
/**
* Sets the data of the mock node from a meta data object, overriding frame ID and
* timestamp
*
* @param [in] irMD Object to take data from
* @param [in] nFrameID Frame ID
* @param [in] nTimestamp Timestamp
*/
inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
{
return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
}
/**
* Sets the data of the mock node from a meta data object.
*
* @param [in] irMD Object to take data from
*/
inline XnStatus SetData(const IRMetaData& irMD)
{
return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b>A GesturesGenerator node recognizes certain hand gestures and raise
* corresponding events accordingly.
*
* A gesture is a specific hand movement. The gesture generator node scans the FOV to
* detect gestures and generates the gesture data.
*
* <b>Usage:</b> Instantiate to create a gesture generator node.
*
* An example of a gesture is a specific hand movement. For example, the developer who builds
* a gesture generator node can decide that waving a hand can be a gesture; pushing can be a gesture.
* The developer can build an OpenNI gesture generator to support any number of gestures.
*
* <b>Overview with Sample of a Usage Scenario:</b>
*
* @note Everything in this introduction is just an @e example of usage; there
* is no obligation to use the gesture generator node in the particular way described
* here.
*
* An application might want to know who is the person they should interact with. For example,
* if currently there are three people in the room, which hand should be tracked?
*
* The application can use a specific gesture (such as waving to the camera) as a focus gesture,
* meaning the person who performs this gesture will be the one interacting with the application.
*
* To do that, the application can use a GestureGenerator to detect that specific gesture and then
* use the position of that gesture to initialize the HandsGenerator, asking it to track the hand
* located at that position. (There is no inherent connection between the GestureGenerator and the
* HandsGenerator. Detecting a gesture and using that position to initialize the HandsGenerator is
* just an example of how applications can use the two).
*
* <b>Sample Process: Setting up a Gesture Generator</b>
*
* <b>1. Creating a Gesture Generator </b>
*
* Assuming there is a gesture generator module (plug-in) installed on the computer, the application
* can create a gesture generator node and configure it to recognize gestures. As for many other
* types of generator nodes, use the @ref Create() method of the GestureGenerator class to create a
* gesture generator node.
*
* <b>2. Enumerating generators</b>
*
* Now, once the application has created a gesture generator node, the application can
* find out which gestures are supported by enumerating all its gestures. The gestures
* are identified by their names, e.g., "Wave" and "Click".
*
* The gesture generator node maintains a list of active gestures. An active gesture
* is a gesture for which the gesture generator is scanning the FOV in an attempt
* to recognize the gesture. Thus, to cause the gesture generator node to start scanning
* for a gesture, the application must add it to its list of active gestures.
*
* In a typical application, the application detects one gesture - the focus gesture -
* and can then send its location to the hand generator node. The application typically
* will then not want to recognize further gestures and so it must remove the gesture from
* the list; further gestures in the FOV may cause confusion. For example, if one particular
* human user started to control the TV, that user would not want someone else "taking the control".
*
* <b>3. Recognizing Gestures </b>
*
* Every gesture has an identification point (the position where the gesture was identified - perhaps
* in retrospect) and an end point (the position in which the hand currently is), although in most cases,
* both points will be the same. The application must know the position of the end of the gesture
* movement; because that's where the hand really is at the time the application gets the 'Gesture Recognized'
* event. The gesture generator sends both positions with the 'Gesture Recognized' event to the application.
* The application can then pass the end position to the hand generator for tracking that hand.
*/
class GestureGenerator : public Generator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
/**
* @brief Creates a gesture generator node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks</b>
*
* The application then uses the @ref AddGesture() method in order to activate the
* gesture.
*
* Typical gestures are focus gestures. Examples of focus gestures are 'Wave' and
* 'Click'.
*
* See @ref create_method for a detailed description of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Activates the GestureGenerator node to start looking for the named gesture in the FOV.
* It does this by adding the gesture's name to the list of gestures that the GestureGenerator node
* actively scans for in the FOV. If an area is supplied, the gesture will only be recognized if
* it is detected in that area.
*
* @param [in] strGesture Name of the gesture to look for
* @param [in] pArea Area in which to look for the gesture (in real-world coordinates)
*
* <b>Remarks</b>
*
* This gesture must be one of the built-in gestures of the GestureGenerator node.
*/
inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
{
return xnAddGesture(GetHandle(), strGesture, pArea);
}
/**
* @brief Disables the GestureGenerator from looking for the named gesture in the FOV.
* It does this by removing the gesture's name from the list of gestures that the
* GestureGenerator node actively scans for in the FOV.
*
* @param [in] strGesture The name of the gesture to not look for anymore.
*/
inline XnStatus RemoveGesture(const XnChar* strGesture)
{
return xnRemoveGesture(GetHandle(), strGesture);
}
/**
* @brief Get the names of all gestures that are currently active in this generator node.
*
* @param [out] astrGestures Preallocated memory, for the gesture names
* @param [in] nNameLength Memory size for each gesture name
* @param [in,out] nGestures Inputs the total size of the preallocated memory.
* Outputs the total number of gestures in the list.
*/
inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
{
return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
}
/**
* @copybrief xnGetNumberOfAvailableGestures
* For full details and usage, see @ref xnGetNumberOfAvailableGestures
*/
inline XnUInt16 GetNumberOfAvailableGestures() const
{
return xnGetNumberOfAvailableGestures(GetHandle());
}
/**
* @brief Gets the names of all active gestures in this generator node.
*
* @param [out] astrGestures Preallocated memory, for the gesture names
* @param [in] nNameLength Memory size for each gesture name
* @param [in,out] nGestures The size of the preallocated memory. Changed to number
* of gestures
*/
inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
{
return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
}
/**
* @brief Returns whether a specific gesture is available in this generator node.
* @param [in] strGesture Name of the gesture to check
*
*/
inline XnBool IsGestureAvailable(const XnChar* strGesture) const
{
return xnIsGestureAvailable(GetHandle(), strGesture);
}
/**
* @copybrief xnIsGestureProgressSupported
* For full details and usage, see @ref xnIsGestureProgressSupported
*/
inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
{
return xnIsGestureProgressSupported(GetHandle(), strGesture);
}
/**
* Callback for the recognition of a gesture.
* Signals that the GestureGenerator node has recognized the named gesture in the scene.
* Example of a callback header to handle the event:
@code
void XN_CALLBACK_TYPE GestureRecognized (GestureGenerator &generator, const XnChar *strGesture,
const XnPoint3D *pIDPosition, const XnPoint3D *pEndPosition,
void *pCookie)
@endcode
*
* @param [in] generator Node that raised the event.
* @param [in] strGesture Name of the gesture that was recognized.
* @param [in] pIDPosition X-Y-Z location coordinates of the hand point position in which the gesture was identified.
* @param [in] pEndPosition Position of the hand at the end of the gesture. This is the hand that performed the gesture.
* @param [in] pCookie User-provided cookie that was given when registering to this event.
<b>Remarks</b>
This event returns the identification point (the position where the gesture was identified - perhaps in retrospect) and an end point (the position in which the hand currently is), although in most cases, both points will be the same. The end position of the gesture movement is where the hand is located at the time the GestureGenerator recognized a complete gesture and raised the event.
*/
typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
/**
* Callback for indication that a certain gesture is in progress.
*
* Signals to the application that a gesture is expected to soon be recognized,
* that is, a gesture is in progress.
*
* Example of a callback header to handle the event: @code
void XN_CALLBACK_TYPE GestureProgress (GestureGenerator &generator, const XnChar *strGesture,
const XnPoint3D *pPosition, XnFloat fProgress,
void *pCookie)
@endcode
*
* @param [in] generator The node that raised the event.
* @param [in] strGesture The gesture that is on its way to being recognized.
* @param [in] pPosition The current position of the hand that is performing the gesture.
* @param [in] fProgress The percentage of the gesture that was already performed.
* @param [in] pCookie A user-provided cookie that was given when registering to this event.
*
* Gesture progress varies between different types of gestures. For the 'Click'
* gesture, for example, the click gesture's first step is the 'Push' movement (assuming
* the click gesture is defined as 'Push' and then 'Pull'). When the hand in the
* FOV completes the 'Push' the GestureGenerator node raises this event.
*
* After the hand in the FOV completes the pull motion, the node sends the 'Gesture
* Recognized' event, as described above.
*/
typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
/**
* @brief Registers event handlers for the 'Gesture Recognized' and 'Gesture Progress' events.
* Pass NULL for any event the application does not need to receive.
*
* @param [in] RecognizedCB [Optional] Callback function to be invoked when the 'Gesture Recognized' event is raised.
* @param [in] ProgressCB [Optional] Callback function to be invoked when the 'Gesture Progress' event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
GestureCookie* pGestureCookie;
XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
pGestureCookie->recognizedHandler = RecognizedCB;
pGestureCookie->progressHandler = ProgressCB;
pGestureCookie->pUserCookie = pCookie;
nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pGestureCookie);
return (nRetVal);
}
hCallback = pGestureCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters the event handlers for the 'Gesture Recognized' and 'Gesture Progress' events.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
{
GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
xnOSFree(pGestureCookie);
}
/**
* @brief Registers an event handler for the 'Gesture Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters an event handler for the 'Gesture Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
}
/**
* Callback for indication that an intermediate stage of a gesture has been completed.
*
* Example of a callback function to handle the event:
@code
void XN_CALLBACK_TYPE GestureIntermediateStageCompleted(GestureGenerator& generator, const XnChar *strGesture,
const XnPoint3D *pPosition, void *pCookie)
@endcode
*
* @param [in] generator The node that raised the event.
* @param [in] strGesture The gesture that is on its way to being recognized.
* @param [in] pPosition The current position of the hand that is performing the gesture.
* @param [in] pCookie A user-provided cookie that was given when registering to this event.
*
* <b>Remarks</b>
*
* For different types of gestures there is a different point at which the GestureGenerator
* node can recognize that a gesture is in progress. For the 'Click' gesture, for
* example, the first step is the 'Push' movement (assuming the click gesture is
* defined as 'Push' and then 'Pull'). When the hand in the FOV completes the 'Push'
* the GestureGenerator node raises this event.
*
* The difference between the 'Gesture Intermediate Stage Completed' event and the
* 'Gesture Progress' event is that the 'Gesture Intermediate Stage Completed' event
* does not refer to how much of the gesture is complete. It deals with breaking
* the gesture into smaller intermediate stages, and informing about them.
*/
typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
/**
* @brief Registers an event handler for the 'Gesture Intermediate Stage Completed' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
XnStatus RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompleted handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
GestureIntermediateStageCompletedCookie* pGestureCookie;
XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
pGestureCookie->handler = handler;
pGestureCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pGestureCookie);
return (nRetVal);
}
hCallback = pGestureCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Gesture Intermediate Stage Completed' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromGestureIntermediateStageCompleted(XnCallbackHandle hCallback)
{
GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
xnOSFree(pGestureCookie);
}
/**
* Callback for indication that the GestureGenerator node recognizes it is ready
* for the next intermediate stage. The next stage is specific to the gesture.
*
* Example of a callback function to handle the event: @code
void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStage(GestureGenerator &generator, const XnChar *strGesture,
const XnPoint3D *pPosition, void *pCookie)
@endcode
*
* <b>Remarks</b>
*
* The number of intermediate stages that there can be is implementation-dependent.
*
* @param [in] generator The node that raised the event.
* @param [in] strGesture The gesture that is on its way to being recognized.
* @param [in] pPosition The current position of the hand that is performing the gesture.
* @param [in] pCookie A user-provided cookie that was given when registering to this event.
*/
typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
/**
* @brief Registers an event handler for the 'Gesture Ready For Next Intermediate Stage' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
XnStatus RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStage handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
GestureReadyForNextIntermediateStageCookie* pGestureCookie;
XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
pGestureCookie->handler = handler;
pGestureCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pGestureCookie);
return (nRetVal);
}
hCallback = pGestureCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Gesture Ready For Next Intermediate Stage' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromGestureReadyForNextIntermediateStageCallbacks(XnCallbackHandle hCallback)
{
GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
xnUnregisterFromGestureReadyForNextIntermediateStage(GetHandle(), pGestureCookie->hCallback);
xnOSFree(pGestureCookie);
}
/** @cond */
inline XnStatus XN_API_DEPRECATED("Use GetAllActiveGestures() instead") GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
{
return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
}
inline XnStatus XN_API_DEPRECATED("Use EnumerateAllGestures() instead") EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
{
return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
}
/** @endcond */
private:
typedef struct GestureCookie
{
GestureRecognized recognizedHandler;
GestureProgress progressHandler;
void* pUserCookie;
XnCallbackHandle hCallback;
} GestureCookie;
static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
{
GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
GestureGenerator gen(hNode);
if (pGestureCookie->recognizedHandler != NULL)
{
pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
}
}
static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
{
GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
GestureGenerator gen(hNode);
if (pGestureCookie->progressHandler != NULL)
{
pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
}
}
typedef struct GestureIntermediateStageCompletedCookie
{
GestureIntermediateStageCompleted handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} GestureIntermediateStageCompletedCookie;
static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
{
GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
GestureGenerator gen(hNode);
if (pGestureCookie->handler != NULL)
{
pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
}
}
typedef struct GestureReadyForNextIntermediateStageCookie
{
GestureReadyForNextIntermediateStage handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} GestureReadyForNextIntermediateStageCookie;
static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
{
GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
GestureGenerator gen(hNode);
if (pGestureCookie->handler != NULL)
{
pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
}
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> Performs an analysis of the scene, identifying different
* objects.
*
* <b>Data output:</b> A label map and the floor plane.
*
* <b>Remarks:</b>
*
* The scene analyzer node analyzes a scene, calculating the separation
* of the foreground from the background, identification of figures in the scene, and
* detection of the floor plane and its coordinates.
*
* The SceneAnalyzer node's main output is a label map, in which each pixel
* is labeled according to the object it belongs to. So, for example,
* each human person gets a separate label, and all pixels belonging to him
* are labeled with that label.
*/
class SceneAnalyzer : public MapGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
/**
* @brief Creates a SceneAnalyzer node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks</b>
*
* See @ref create_method for a detailed description of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Gets the scene analyzer node's latest @ref glos_frame_object "frame object", saving
* it in the @ref xn::SceneMetaData object. This @ref glos_frame_object "frame object" is a
* snapshot of the generated label map data and its associated configuration information at a
* certain point in time. This saved @ref glos_frame_object "frame object" provides fast
* and easy access to the scene analyzer node's data and configuration information.
*
* @param [out] metaData Structure to be filled with the frame object.
*
* <b>Remarks:</b>
*
* This method is central in the use of the SceneAnalyzer node. Once the SceneAnalyzer
* node is generating data, after each @ref conc_updating_data "'Update Data'" call,
* the application calls this method to get the node's frame object, which contains
* the data and all its associated properties.
*
* The frame scene is a labeled depth map, in which each pixel contains a numeric
* label indicating whether it represents a user, or it is part of the background.
*/
inline void GetMetaData(SceneMetaData& metaData) const
{
xnGetSceneMetaData(GetHandle(), metaData.GetUnderlying());
}
/**
* @copybrief xnGetLabelMap
* For full details and usage, see @ref xnGetLabelMap
*/
inline const XnLabel* GetLabelMap() const
{
return xnGetLabelMap(GetHandle());
}
/**
* @brief Gets a description of the floor, if it was found.
*
* @param [out] Plane A description of the floor
*/
inline XnStatus GetFloor(XnPlane3D& Plane) const
{
return xnGetFloor(GetHandle(), &Plane);
}
};
/**
* @ingroup cppref_prd_func
* Allows access to <b>Hand touching FOV edge</b> capability functions.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref HandsGenerator::GetHandTouchingFOVEdgeCap()
* to obtain an instance.
*/
class HandTouchingFOVEdgeCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline HandTouchingFOVEdgeCapability(XnNodeHandle hNode) : Capability(hNode) {}
HandTouchingFOVEdgeCapability(const NodeWrapper& node) : Capability(node) {}
/**
* Callback for the hand getting close to the edge of the FOV
*
* @param [in] touchingfov the hand touching fov edge capability that raised this event.
* @param [in] user ID of the hand that disappeared.
* @param [in] pPosition Position of the hand.
* @param [in] fTime Timestamp, in seconds.
* @param [in] eDir Direction of the FOV touched
* @param [in] pCookie User-provided cookie that was given when registering to this event.
*/
typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
/**
* @brief Registers an event handler for the 'Hand Touching FOV Edge' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToHandTouchingFOVEdge(HandTouchingFOVEdge handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
HandTouchingFOVEdgeCookie* pHandCookie;
XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
pHandCookie->handler = handler;
pHandCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pHandCookie);
return (nRetVal);
}
hCallback = pHandCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Hand Touching FOV Edge' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromHandTouchingFOVEdge(XnCallbackHandle hCallback)
{
HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
xnOSFree(pHandCookie);
}
private:
typedef struct HandTouchingFOVEdgeCookie
{
HandTouchingFOVEdge handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} HandTouchingFOVEdgeCookie;
static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
{
HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
HandTouchingFOVEdgeCapability cap(hNode);
if (pHandCookie->handler != NULL)
{
pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
}
}
};
/**
* @ingroup cppref_prd_func
* The HandsGenerator node generates tracking data about a single hand or multiple hands
* with persistent IDs.
*
* The user interface (UI) in natural interaction applications is specifically implemented
* and performed through hand movements.
*
* OpenNI's user interface (UI) ability is specifically through hand movements. Thus
* it is the HandsGenerator class that provides the main UI ability.
*
* Using events, the HandsGenerator object notifies the application of various occurrences: a
* 'Hand Create' event is sent when an expected hand has been positively identified or when a
* new hand appears; a 'Hand Update' event is sent when a tracked hand appears again in a new
* frame; a 'Hand Destroy' event is sent when a tracked hand disappears.
*
* <b>NOTE: </b> The HandsGenerator does not provide the mechanism for initially locating
* the hand. Initial location of the hand can be performed by the Gestures class (see
* further below). This is a typical scenario but not the only way to locate the hand.
*
* The following figure illustrates a typical scenario for using the HandsGenerator
* class. After hand recognition the HandsGenerator class continues tracking the hand
* and sending HandUpdate events until the application sends calls HandsGenerator's
* StopTracking method.
*
* <b>1. Creating a HandsGenerator</b>
*
* As for many other types of generator nodes, HandsGenerator provides a Create method
* to create a hands generator node.
*
* Assuming you have hands generator module (plug-in) installed on your computer, you
* can create a hands generator node. Then you can start tracking for an expected hand.
*
* @note Creating a HandsGenerator node has nothing to do with the 'Hand Create'
* event that OpenNI sends to the app on starting to successfully track the hand in
* the FOV.
*
* <b>2. Starting Tracking</b>
*
* When starting to track a hand, the application already expects that a person's hand
* is already present in the field of view and is at a certain coordinate (x,y) position.
*
* The source for this information, i.e., the presence of a hand object and its position,
* can be obtained, for example, from a gesture generator node.
* The application passes this location to the @ref StartTracking()
* method of the HandsGenerator object, which starts tracking for
* the expected hand. When - and if - the StartTracking() method finds the hand at the
* expected position it sends a 'Hand Create' event to the application.
*
* <b>3. Tracking</b>
*
* While tracking a hand, 'Hand Update' events are sent to the application notifying that the hand
* has moved to such and such a position. A 'Hand Update' event is sent each time a new
* frame processed by the input sensors shows the hand is still present. A 'Hand Update'
* event is sent even if the hand is still in the same position as it was in the previous
* frame.
*
* If the tracked hand disappears (e.g., when the person puts his hand behind his back)
* a 'Hand Destroy' event is sent to the application to notify that the hand has disappeared.
*
* The 'Hand Create' event is also sent if an additional hand is found internally.
*
* The tracking mechanism uses an algorithm that uses the depth to obtain points and
* track. This algorithm can be somewhat susceptible to jitter of the hand, so HandsGenerator
* provides a smoothing capability. Call the SetSmoothing() method to apply a smoothing
* factor of none (0) to maximum (1). The default is 0. Recommended is 0.1 when using
* the PrimeSense algorithm for hand generation.
*
* <b>4. Stopping Tracking</b>
*
* When the hand being tracked is no longer identified, the HandsGenerator object sends
* the 'Hand Destroy' event.
*
* The application can also intentionally stop tracking a specific hand, e.g., when
* the hand is no longer of interest. The application does this by calling the @ref StopTracking()
* method. When the node stops tracking the hand it sends a 'Hand Destroy' event to the application.
*
* The application can also stop the tracking of all hands at once by calling the @ref StopTrackingAll()
* method. In response, the node stops tracking all hands and for each hand it sends a
* 'Hand Destroy' event to the application.
* Even when there are no tracked hands, the HandsGenerator object remains functional
* for the next tracking request.
*
* <h2>Events:</h2>
*
* @image html ClassHandsGenerator_EventSeq-sm.png "Event Sequence for HandsGenerator node"
*/
class HandsGenerator : public Generator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
/**
* @brief Creates a HandsGenerator node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks:</b>
*
* See @ref create_method for a detailed description of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* Callback for the creation of a new hand.
*
* Signals that the hands generator has recognized and started tracking a new hand in response
* to the application calling the StartTracking() method. This event returns the
* ID of the new hand, the time of its recognition, and its position on recognition
* in the current frame.
*
* @param [in] generator Generator that raised this event.
* @param [in] user ID of the new hand.
* @param [in] pPosition Position at which the hand was created.
* @param [in] fTime Timestamp, in seconds.
* @param [in] pCookie User-provided cookie that was given when registering to
* this event.
*/
typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
/**
* Signals that an already-existing hand has moved to a new position.
*
* Signals that a currently tracked hand was recognized at a specific position in
* the new frame. OpenNI continues to send this event at each further frame that
* the hand is still present. This event returns the ID of the hand, which is the
* same ID returned by the HandCreate event, the hand's new position, and the time
* of the update.
*
* @param [in] generator the generator that raised this event.
* @param [in] user The id of the hand that moved.
* @param [in] pPosition The new position of the relevant hand.
* @param [in] fTime Timestamp, in seconds.
* @param [in] pCookie A user-provided cookie that was given when registering to
* this event.
*/
typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
/**
* Callback for the disappearance of a hand.
*
* Signals that an existing hand has disappeared from the frame for any reason.
* This event returns the user ID – still the same user ID as before –
* and the time that it disappeared.
*
* @param [in] generator the generator that raised this event.
* @param [in] user The id of the hand that disappeared.
* @param [in] fTime Timestamp, in seconds.
* @param [in] pCookie A user-provided cookie that was given when registering to
* this event.
*/
typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
/**
* @brief Registers event handlers for the 'Hand Create', 'Hand Update' and 'Hand Destroy' events.
* Pass NULL for any event you don't want your application to receive.
*
* @param [in] CreateCB [Optional] Callback function to be invoked when the 'Hand Create' event is raised.
* @param [in] UpdateCB [Optional] Callback function to be invoked when the 'Hand Update' event is raised.
* @param [in] DestroyCB [Optional] Callback function to be invoked when the 'Hand Destroy' event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
HandCookie* pHandCookie;
XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
pHandCookie->createHandler = CreateCB;
pHandCookie->updateHandler = UpdateCB;
pHandCookie->destroyHandler = DestroyCB;
pHandCookie->pUserCookie = pCookie;
nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pHandCookie);
return (nRetVal);
}
hCallback = pHandCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters event handlers for the 'Hand Create', 'Hand Update' and 'Hand Destroy' events.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
{
HandCookie* pHandCookie = (HandCookie*)hCallback;
xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
xnOSFree(pHandCookie);
}
/**
* @brief Stops tracking an existing hand that you are no longer interested in.
*
* @param [in] user Hand to stop tracking. This parameter is the ID of the hand.
*
* <b>Remarks</b>
*
* Typically, the application will stop tracking an existing hand that it is no
* longer interested in.
*
* Calling this method causes the 'Hand Destroy' event to be raised when OpenNI destroys
* the hand.
*/
inline XnStatus StopTracking(XnUserID user)
{
return xnStopTracking(GetHandle(), user);
}
/**
* @brief Stops tracking all existing hands.
*
* <b>Remarks</b>
*
* Calling this method causes the 'Hand Destroy' event to be raised when OpenNI destroys
* the hand.
*/
inline XnStatus StopTrackingAll()
{
return xnStopTrackingAll(GetHandle());
}
/**
* @brief Starts tracking at the specific position where the application expects a hand.
*
* @param [in] ptPosition The position at which there is a new hand
*
* <b>Remarks</b>
*
* Use the <code>ptPosition</code> parameter to tell the method what is the expected
* location (in X-Y-Z coordinates) of the hand.
*
* This expected location can be obtained from a 'Gesture Recognized' event, but
* it is not the only way of getting the hand's expected location.
*
* Calling this method causes the HandCreate event to be raised when OpenNI recognizes
* the hand.
*/
inline XnStatus StartTracking(const XnPoint3D& ptPosition)
{
return xnStartTracking(GetHandle(), &ptPosition);
}
/**
* @brief Changes the smoothing factor.
*
* @param [in] fSmoothingFactor Smoothing factor, in the range 0..1. 0 Means no
* smoothing, 1 means infinite smoothing.
* Inside the range is generator dependent.
* <br>
* Recommended: 0.1
*
* <b>Remarks</b>
*
* The hand is identified from its physical depth. Since the human hand is not absolutely
* steady, the hand point generated may be too jittery to be used for controlling
* the user interface, e.g., pressing buttons. This method provides an algorithm
* to smooth the jitter. You provide the desired smoothing factor as a parameter.
*/
inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
{
return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
}
/**
* Gets an @ref HandTouchingFOVEdgeCapability object for accessing hand touching
* FOV edge callbacks functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_HAND_TOUCHING_FOV_EDGE
* is supported
* by calling @ref IsCapabilitySupported().
*/
inline const HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() const
{
return HandTouchingFOVEdgeCapability(GetHandle());
}
/**
* Gets an @ref HandTouchingFOVEdgeCapability object for accessing hand touching
* FOV edge callbacks functionality.
* It is the application responsibility to check first if @ref XN_CAPABILITY_HAND_TOUCHING_FOV_EDGE
* is supported
* by calling @ref IsCapabilitySupported().
*/
inline HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap()
{
return HandTouchingFOVEdgeCapability(GetHandle());
}
private:
typedef struct HandCookie
{
HandCreate createHandler;
HandUpdate updateHandler;
HandDestroy destroyHandler;
void* pUserCookie;
XnCallbackHandle hCallback;
} HandCookie;
static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
{
HandCookie* pHandCookie = (HandCookie*)pCookie;
HandsGenerator gen(hNode);
if (pHandCookie->createHandler != NULL)
{
pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
}
}
static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
{
HandCookie* pHandCookie = (HandCookie*)pCookie;
HandsGenerator gen(hNode);
if (pHandCookie->updateHandler != NULL)
{
pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
}
}
static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
{
HandCookie* pHandCookie = (HandCookie*)pCookie;
HandsGenerator gen(hNode);
if (pHandCookie->destroyHandler != NULL)
{
pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
}
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> Provides the 'Skeleton' functionality for a @ref xn::UserGenerator
* node. This capability lets the node generate a skeleton representation for each human
* user generated by the node.
*
* @note See @ref meanings_of_user "Meanings of 'User'".
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref UserGenerator::GetSkeletonCap()
* to obtain an instance.
*
* <b>Data output:</b> Skeleton.
*
* The OpenNI definition of <i>joints</i> refers to a predefined set of points on the
* human body, as defined by the @ref xn::XnSkeletonJoint enum type. Examples of these
* joints are @ref XN_SKEL_HEAD, @ref XN_SKEL_TORSO, @ref XN_SKEL_LEFT_ELBOW,
* @ref XN_SKEL_LEFT_WRIST and @ref XN_SKEL_LEFT_HAND. Note that some of these <i>joints</i>
* are actual joints, in the conventional sense as termed by the English language, for
* example, @ref XN_SKEL_LEFT_ELBOW and @ref XN_SKEL_LEFT_WRIST; and other joints are in
* fact <i>limbs</i>, for example, @ref XN_SKEL_HEAD and @ref XN_SKEL_LEFT_HAND.
* However, OpenNI defines all these as <i>joints</i>, each joint with a single position
* coordinate. Each detected joint is defined by its <i>position</i>, which is held
* as a struct of type @ref xn::XnSkeletonJointPosition, comprising a 3D position coordinate
* and confidence. The 3D position coordinate defines a point somewhere in the center
* of the 'joint', for example, the position of the torso will be at the center of the
* torso, i.e., somewhere in the stomach area.
*
* To graphically draw a complete skeleton, therefore, each joint must be connected
* by a line to the adjacent point according to the form of the human body.
*
* An application typically uses this skeleton representation to track human motion,
* or to graphically display all or part of the user as an avatar on screen, and optionally
* graphically enhance it to make it look more like a full humanoid figure.
*
* @section skeleton_calib Calibration
*
* Tracking of a human user always starts with a process named 'Calibration'. In this
* process the algorithm performs some implementation-specific logic to enable it
* to track that user. there is no standard for what calibration is exactly and
* each implementation may use whatever it needs to produce and calibrate a skeleton.
* However, a typical way of calibrating the skeleton would be to measure distances
* between key joints for a particular user and record the data as the calibration data
* for that particular user.
*
* Some implementations of the user generator node require a human user to pose a specific
* posture for the calibration process to succeed. The application can check if current implementation
* requires such a pose by calling @ref NeedPoseForCalibration() method. If the answer is TRUE,
* the application should call @ref GetCalibrationPose() to find out the name of the pose a human user should
* take in order to calibrate the algorithm. The application can use the @ref xn::PoseDetectionCapability
* to find out if a human user is assuming a specific position, and once he does, calibration can start.
*
* The application starts the calibration process by calling @ref RequestCalibration(). There
* are several events raised during the calibration process, but the most important one is
* 'Calibration Complete'. Once calibration is done, the application may call @ref StartTracking()
* to make the algorithm start tracking the skeleton of that human user.
*/
class SkeletonCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
SkeletonCapability(const NodeWrapper& node) : Capability(node) {}
/**
* @brief Returns whether a specific skeleton joint is supported by the SkeletonCapability object.
*
* @param [in] eJoint Joint to check.
*/
inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
{
return xnIsJointAvailable(GetHandle(), eJoint);
}
/**
* @brief Returns whether a specific skeleton profile is supported by the SkeletonCapability object.
*
* @param [in] eProfile Profile to check.
*/
inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
{
return xnIsProfileAvailable(GetHandle(), eProfile);
}
/**
* @brief Sets the skeleton profile. The skeleton profile specifies which joints are to
* be active, and which to be inactive. The @ref UserGenerator node generates output data
* for the active joints only. This profile applies to all skeletons that the @ref UserGenerator node generates.
*
* @param [in] eProfile Specifies the profile to set.
*
* <b>Remarks</b>
*
* The profile (@ref xn::XnSkeletonProfile) enables the application to choose between
* generating all joints, just the upper or lower torso, or just the head and hands
* only.
*
* Since this method provides the flexibility to request only the data that the
* application requires, this can help to significantly improve response time: setting
* a smaller skeleton profile reduces the processing load on the computer, which
* can cause a significant increase in avatar responsiveness.
*
* Use the @ref SetJointActive() method for selecting the profile down to a finer
* resolution than possible with this method, e.g., to be able to select a specific
* hand or foot.
*
* OpenNI does not standardize the initial profile set. If no profile is set, each
* implementation may have its own default profile. For example, PrimeSense implementation's
* default profile is NONE. This means if no profile is set, no joint will be available.
*
* Setting a profile changes all the joint configuration to that profile. This means
* you can set a profile, then refine specific joints (adding or removing). You
* can't do it the other way around.
*/
inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
{
return xnSetSkeletonProfile(GetHandle(), eProfile);
}
/**
* @brief Changes the state of a specific skeleton joint to be active or inactive.
* The @ref xn::UserGenerator node generates output data for the active joints only.
* This state setting applies to all skeletons that the @ref xn::UserGenerator node generates.
*
* @param [in] eJoint Specifies the joint.
* @param [in] bState New activation state (true/false).
*
* <b>Remarks</b>
*
* This method lets the application set the skeleton profile down to a finer resolution
* than is possible with the @ref SetSkeletonProfile() method.
*
* The joint selector parameter (@ref xn::XnSkeletonJoint) lets the application
* choose specific parts of a skeleton, e.g., a specific hand or foot.
*
* Since this method provides the flexibility to request only the data that the
* application requires, this can help to significantly improve response time. Setting
* a smaller skeleton profile can reduce the processing load on the computer, which
* can cause a significant increase in avatar responsiveness (implementation-dependent).
* Some implementations may produce all the data they can, and only filter it at
* the end according to the configuration.
*/
inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
{
return xnSetJointActive(GetHandle(), eJoint, bState);
}
/**
* @brief Checks if a specific joint is tracked or not.
*
* @param [in] eJoint Specifies the joint.
*/
inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
{
return xnIsJointActive(GetHandle(), eJoint);
}
/**
* @brief Registers an event handler for the 'Joint Configuration Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters an event handler for the 'Joint Configuration Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
}
/**
* @copybrief xnEnumerateActiveJoints
* For full details and usage, see @ref xnEnumerateActiveJoints
*/
inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
{
return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
}
/**
* @brief Gets all available information about a specific joint in the skeleton.
*
* @param [in] user ID of the user.
* @param [in] eJoint Joint specifier.
* @param [out] Joint Transformation structure for the joint. Includes position
* and orientation.
*/
inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
{
return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
}
/**
* @brief Gets the position of one of the skeleton joints in the most recently generated user data.
*
* @param [in] user ID of the user.
* @param [in] eJoint Joint specifier.
* @param [out] Joint Latest position of the joint.
*
* <b>Remarks</b>
*
* The joint position is returned as a @ref XnSkeletonJointPosition structure, comprising
* a real-world coordinate together with a confidence rating.
*
* Confidence can be in the range of 0..1.
*
* 0 means 'I'm guessing here'.<br>
* 1 means 'This is where it is'. <br>
*
* The API is ready for when an implementation decides it is 'fairly certain'. In
* a typical implementation, 0.5 is used when there is an educated guess, or have
* run some heuristics to determine the position.
*/
inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
{
return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
}
/**
* @brief Gets the orientation of a specific skeleton joint.
*
* @param [in] user ID of the user.
* @param [in] eJoint Joint specifier.
* @param [out] Joint Joint's orientation.
*/
inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
{
return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
}
/**
* @brief Returns whether a user is currently being tracked.
*
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* This is a utility method. It is an alternative approach to saving the states
* from the events that notify stages in calibration and tracking.
*/
inline XnBool IsTracking(XnUserID user) const
{
return xnIsSkeletonTracking(GetHandle(), user);
}
/**
* @brief Returns whether a user has been calibrated. see @ref skeleton_calib.
*
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* This is a utility method. It is an alternative approach to saving the states
* from the events that notify stages in calibration.
*/
inline XnBool IsCalibrated(XnUserID user) const
{
return xnIsSkeletonCalibrated(GetHandle(), user);
}
/**
* @brief Returns whether a user is being calibrated right now. see @ref skeleton_calib.
*
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* This is a utility method. It is an alternative approach to saving the states
* from the events that notify stages in calibration.
*/
inline XnBool IsCalibrating(XnUserID user) const
{
return xnIsSkeletonCalibrating(GetHandle(), user);
}
/**
* @brief Starts the calibration process to calibrate a user.
*
* @param [in] user ID of the user.
* @param [in] bForce Disregard previous calibration to force a further calibration.<br>
* Values:<br>
* True: Disregards any previous calibration and forces a new calibration.<br>
* False: Starts the calibration process only if no calibration data is available
* for the skeleton.<br>
* This means that if the user was previously calibrated (which actually means measuring
* the length of its limbs, and estimating its torso, to be used in its skeletal
* representation), and another calibration was requested, to either make do with
* what we have (false), or forget the previous measurements and perform calibration
* again.
*
* <b>Remarks</b>
*
* This method is typically called from inside an event handler for the 'Pose Detected'
* event, signaling that a pose was detected in the FOV. Once a valid pose has been
* detected the application will want to start calibrating the user.
*
* It can also be called outside of that, in implementations that don't require
* a pose.
*/
inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
{
return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
}
/**
* @brief Aborts an existing calibration process currently being executed for a specified user.
*
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* Raises the 'Calibration Complete' event.
*/
inline XnStatus AbortCalibration(XnUserID user)
{
return xnAbortSkeletonCalibration(GetHandle(), user);
}
/**
* @brief Saves the skeleton's current calibration data to a file.
*
* @param [in] user ID of the user.
* @param [in] strFileName Name of the file for saving the calibration data.
*
* <b>Remarks</b>
*
* The application is the one that should match the user, however it sees fit. For
* example, if a calibration was saved as C:\\john_smith.bin, and then later another
* application recognizes John Smith (let's say, through face recognition), the
* calibration data can be loaded, instead of performing the entire calibration
* process.
*
* This is a very useful tool for developers. They can save their own calibration,
* and test their application without calibrating each time (going into pose, spend
* time on calibration).
*/
inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
{
return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
}
/**
* @brief Loads skeleton calibration data from a file to a skeleton.
*
* @param [in] user ID of the user.
* @param [in] strFileName File to load the calibration data from.
*/
inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
{
return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
}
/**
* @brief Saves the calibration data of a specified user. The calibration data includes the lengths of the human user's limbs.
*
* @param [in] user ID of the user.
* @param [in] nSlot Slot to use for saving the calibration data
*
* <b>Remarks</b>
*
* The slots mechanism allows saving the calibration to memory instead of to files.
* When used, a calibration is saved to a slot, and may be reloaded from it.
*/
inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
{
return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
}
/**
* @brief Loads calibration data of a specified user. The calibration data includes the lengths of the human user's limbs.
*
* @param [in] user ID of the user.
* @param [in] nSlot Slot to use for saving the calibration data
*/
inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
{
return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
}
/**
* @brief Clears a specified slot of any saved calibration data.
*
* @param [in] nSlot Slot specifier.
*/
inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
{
return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
}
/**
* @brief Returns whether a specific slot already holds calibration data.
*
* @param [in] nSlot Slot specifier.
*/
inline XnBool IsCalibrationData(XnUInt32 nSlot) const
{
return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
}
/**
* @brief Starts tracking a skeleton.
*
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* This method is used for tracking the motion of the skeleton, representing a human
* user body, within a real-life (3D) scene for analysis, interpretation, and use
* by the application.
*
* While the skeleton is being tracked, the application can call the @ref GetSkeletonJointPosition()
* method to get data about one of the joint positions.
*/
inline XnStatus StartTracking(XnUserID user)
{
return xnStartSkeletonTracking(GetHandle(), user);
}
/**
* @brief Stops tracking a skeleton.
* @param [in] user ID of the user.
*/
inline XnStatus StopTracking(XnUserID user)
{
return xnStopSkeletonTracking(GetHandle(), user);
}
/**
* @brief Discards a skeleton's calibration.
* @param [in] user ID of the user.
*
* <b>Remarks</b>
*
* Utility method for resetting a user to its initial state. For use in development.
*/
inline XnStatus Reset(XnUserID user)
{
return xnResetSkeleton(GetHandle(), user);
}
/**
* @brief Returns whether a specific pose is required for
* calibration. This setting is applicable to all users.
*
* <b>Remarks</b>
*
* This is a setting made by the developer of the SkeletonCapability plug-in.
*/
inline XnBool NeedPoseForCalibration() const
{
return xnNeedPoseForSkeletonCalibration(GetHandle());
}
/**
* @brief Gets the name of the pose that is required for calibration. The
* pose and its name reside in the plug-in module that provides the
* SkeletonCapability. The pose's name and details are defined by the
* developer of the module.
*
* @param [out] strPose Name of the pose required for calibration
* <b>Remarks</b>
*
* This method is to be used only if the @ref NeedPoseForCalibration() method returns
* TRUE, and only then will this method returns a name.
*/
inline XnStatus GetCalibrationPose(XnChar* strPose) const
{
return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
}
/**
* @brief Sets the smoothing factor for all users generated by this @ref xn::UserGenerator node.
* @param [in] fSmoothingFactor Smoothing factor<br>
* Range: 0 to 1<br>
*
* <b>Remarks</b>
*
* The human body is identified from its physical depth. Since the human body is
* not absolutely steady, the human body being calibrated may be too jittery to
* easily obtain its position. This method provides an algorithm to smooth the jitter.
* You provide the desired smoothing factor as a parameter.
*/
inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
{
return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
}
/**
* Signals that a specific user's SkeletonCapability object is now starting the
* calibration process.
*
* Example of a callback function to handle the 'Calibration Start' event:
*
@code
OnCalibrationStart(xn::SkeletonCapability& skeleton, XnUserID user, void* pCookie)
@endcode
*
* @param [in] skeleton SkeletonCapability object that raised the event.
* @param [in] user The id of the user that's being calibrated.
* @param [in] pCookie A user-provided cookie that was given when registering to
* this event.
*
* <b>Remarks</b>
*
* The application itself initiates calibration by calling the @ref RequestCalibration() method.
* When a SkeletonCapability object actually starts to perform the calibration,
* it raises this event.
*/
typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
/**
* Signals that a specific user's SkeletonCapability object has now completed the
* calibration process.
*
* Example of a callback function to handle the 'Calibration Complete' event:
@code
OnCalibrationEnd(xn::SkeletonCapability &skeleton, XnUserID user,
XnCalibrationStatus calibrationError, void *pCookie)
@endcode
*
* <b>Parameters: </b>
*
* hNode [in] Node that raised the event.
* user [in] ID of the user for which calibration was attempted.
* bSuccess [in] Indication of whether or not the calibration attempt succeeded.
* pCookie [in] User-provided cookie that was given when registering to this event.
*/
typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
/**
* @brief Registers an event handler for the 'Calibration Start' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* See @ref skeleton_calib for information about calibration.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
CalibrationStartCookie* pCalibrationCookie;
XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
pCalibrationCookie->handler = handler;
pCalibrationCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pCalibrationCookie);
return nRetVal;
}
hCallback = pCalibrationCookie;
return XN_STATUS_OK;
}
/**
* @brief Unregisters a handler from the 'Calibration Start' event.
*
* @param [in] hCallback Handle received from registration.
*
* <b>Remarks</b>
*
* Due to historical reasons, this function has an XnStatus return value. In practice,
* it will always succeed. The user can safely ignore the return value.
*/
inline XnStatus UnregisterFromCalibrationStart(XnCallbackHandle hCallback)
{
CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
xnOSFree(pCalibrationCookie);
return XN_STATUS_OK;
}
/**
* Signals that a specific user's skeleton is calibrating, and its current status.
*
* Example of a callback function to handle the 'Calibration Progress' event:
@code
OnCalibrationProgress(xn::SkeletonCapability &skeleton, XnUserID user,
XnCalibrationStatus calibrationError, void *pCookie)
@endcode
*
* @param [in] skeleton SkeletonCapability object that raised the event.
* @param [in] user ID of the user holding SkeletonCapability object.
* @param [in] calibrationError Status of the calibration. Values are defined by
* XnCalibrationStatus.
* @param [in] pCookie User's cookie, to be delivered to the callback.
*
* <b>Remarks</b>
*
* After the 'Calibration Start' event, the 'Calibration in Progress' event is raised
* every frame until 'Calibration Complete' is raised. It informs the application
* as to the current state of the calibration process.
*/
typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
/**
* @brief Registers an event handler for the 'Calibration In Progress' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToCalibrationInProgress(CalibrationInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
CalibrationInProgressCookie* pSkeletonCookie;
XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
pSkeletonCookie->handler = handler;
pSkeletonCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pSkeletonCookie);
return (nRetVal);
}
hCallback = pSkeletonCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Calibration In Progress' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromCalibrationInProgress(XnCallbackHandle hCallback)
{
CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
xnOSFree(pSkeletonCookie);
}
/**
* @brief Signals that a specific user's skeleton has now completed the calibration
* process, and provides a result status.
*
* Following is an example of a callback header to handle the 'Calibration Complete'
* event:
@code
OnCalibrationComplete(xn::SkeletonCapability &skeleton, XnUserID user,
XnCalibrationStatus calibrationError, void *pCookie)
@endcode
*
* @param [in] skeleton SkeletonCapability object that raised the event.
* @param [in] user ID of the user holding SkeletonCapability object.
* @param [in] calibrationError Status of the calibration. Values are defined by
* XnCalibrationStatus.
* @param [in] pCookie User's cookie, to be delivered to the callback.
*/
typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
/**
* @brief Registers an event handler for the 'Calibration Complete' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToCalibrationComplete(CalibrationComplete handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
CalibrationCompleteCookie* pSkeletonCookie;
XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
pSkeletonCookie->handler = handler;
pSkeletonCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pSkeletonCookie);
return (nRetVal);
}
hCallback = pSkeletonCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Calibration Complete' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromCalibrationComplete(XnCallbackHandle hCallback)
{
CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
xnOSFree(pSkeletonCookie);
}
/** @cond */
XN_API_DEPRECATED("Use the overload with one argument - the bState parameter is useless")
inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const
{
return xnIsJointActive(GetHandle(), eJoint);
}
inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
SkeletonCookie* pSkeletonCookie;
XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
pSkeletonCookie->startHandler = CalibrationStartCB;
pSkeletonCookie->endHandler = CalibrationEndCB;
pSkeletonCookie->pUserCookie = pCookie;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
#pragma warning (pop)
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pSkeletonCookie);
return (nRetVal);
}
hCallback = pSkeletonCookie;
return (XN_STATUS_OK);
}
inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
{
SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
#pragma warning (pop)
xnOSFree(pSkeletonCookie);
}
/** @endcond */
private:
typedef struct SkeletonCookie
{
CalibrationStart startHandler;
CalibrationEnd endHandler;
void* pUserCookie;
XnCallbackHandle hCallback;
} SkeletonCookie;
static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
{
SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
SkeletonCapability cap(hNode);
if (pSkeletonCookie->startHandler != NULL)
{
pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
}
}
static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
{
SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
SkeletonCapability cap(hNode);
if (pSkeletonCookie->endHandler != NULL)
{
pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
}
}
typedef struct CalibrationStartCookie
{
CalibrationStart handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} CalibrationStartCookie;
static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
{
CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
SkeletonCapability cap(hNode);
if (pCalibrationCookie->handler != NULL)
{
pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
}
}
typedef struct CalibrationInProgressCookie
{
CalibrationInProgress handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} CalibrationInProgressCookie;
static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
{
CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
SkeletonCapability cap(hNode);
if (pSkeletonCookie->handler != NULL)
{
pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
}
}
typedef struct CalibrationCompleteCookie
{
CalibrationComplete handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} CalibrationCompleteCookie;
static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
{
CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
SkeletonCapability cap(hNode);
if (pSkeletonCookie->handler != NULL)
{
pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
}
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> Provides a 'Pose Detection' functionality for a @ref xn::UserGenerator
* node. This capability lets the node recognize when the user is posed in a specific
* position.
*
* <b>Usage:</b> Do not instantiate directly. Instead, use @ref UserGenerator::GetPoseDetectionCap()
* to obtain an instance.
*
* <b>Data output:</b> Raises events.
*
* <b>Remarks:</b>
*
* A pose is a specific full body posture involving all the limbs. The PoseDetectionCapability
* object scans the FOV to detect users performing poses. The PoseDetectionCapability
* then generates the pose data.
*
* When and if the @ref PoseDetectionCapability object detects a pose it raises the
* 'Pose Detected' event.
*/
class PoseDetectionCapability : public Capability
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
PoseDetectionCapability(const NodeWrapper& node) : Capability(node) {}
/**
* <b>'Pose Detection' event</b>
*
* This event is raised to signal that a specific user has entered a pose.
*
* @param [in] pose Reference to the specific @ref xn::UserGenerator node
* that raised the event.
* @param [in] strPose Name of the specific pose defined for this event handler.
* (The PoseDetectionCapability can define more than a single pose that can be detected.)
* @param [in] user ID of the user that entered the pose.
* @param [in] pCookie Returns any information ("cookie") that the application
* placed in this parameter at the time of registering the event..
*/
typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
/**
* @brief Get the number of poses supported by this capability.
*
* <b>Remarks</b>
*
* The number of supported poses is defined by the developer of the capability and
* is common to all @ref xn::UserGenerator nodes using this capability on this OpenNI
* deployment.
*/
inline XnUInt32 GetNumberOfPoses() const
{
return xnGetNumberOfPoses(GetHandle());
}
/**
* @brief Gets the names of all poses supported by this capability.
* @param [out] pstrPoses Pre-allocated memory for the names of the supported poses.
* @param [in] nNameLength Memory size for each pose name.
* @param [in,out] nPoses In input - size of the preallocated memory, in output
* - the number of pose names.
*
* <b>Remarks</b>
*
* The names of the poses are preset in advance by the developer of this capability.
*/
inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
{
return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
}
inline XnBool IsPoseSupported(const XnChar* strPose)
{
return xnIsPoseSupported(GetHandle(), strPose);
}
inline XnStatus GetPoseStatus(XnUserID userID, const XnChar* poseName, XnUInt64& poseTime, XnPoseDetectionStatus& eStatus, XnPoseDetectionState& eState)
{
return xnGetPoseStatus(GetHandle(), userID, poseName, &poseTime, &eStatus, &eState);
}
/**
* @brief Starts attempting to detect a pose for a specific user.
*
* @param [in] strPose Name of the requested pose. Call the GetAvailablePoses()
* method to get the names of poses supported by the PoseDetectionCapability.
* @param [in] user ID of a user to detect a pose for.
*
* <b>Remarks</b>
*
* This method will typically be used after a new user has been recognized in the
* FOV. This is typically the next stage in the process of calibrating the new user -
* @see skeleton_calib.
* When and if the @ref PoseDetectionCapability object detects a pose it raises
* the 'Pose Detected' event.
*/
inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
{
return xnStartPoseDetection(GetHandle(), strPose, user);
}
/**
* @brief Stops attempting to detect a pose (for a specific user).
*
* @param [in] user ID of a user.
*
* <b>Remarks</b>
*
* The application will typically call this method when it has already received
* a 'Pose Detected' event. Once a pose has been detected it is no longer necessary
* to try to detect poses.
*/
inline XnStatus StopPoseDetection(XnUserID user)
{
return xnStopPoseDetection(GetHandle(), user);
}
/** @copybrief xnStopSinglePoseDetection
* For full details and usage, see @ref xnStopSinglePoseDetection
*/
inline XnStatus StopSinglePoseDetection(XnUserID user, const XnChar* strPose)
{
return xnStopSinglePoseDetection(GetHandle(), user, strPose);
}
/**
* @brief Registers an event handler for the 'Pose Detected' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
PoseDetectionCookie* pPoseCookie;
XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
pPoseCookie->handler = handler;
pPoseCookie->pPoseCookie = pCookie;
nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pPoseCookie);
return nRetVal;
}
hCallback = pPoseCookie;
return XN_STATUS_OK;
}
/**
* @brief Registers an event handler for the 'Out Of Pose' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
PoseDetectionCookie* pPoseCookie;
XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
pPoseCookie->handler = handler;
pPoseCookie->pPoseCookie = pCookie;
nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pPoseCookie);
return nRetVal;
}
hCallback = pPoseCookie;
return XN_STATUS_OK;
}
/**
* @brief Unregisters an event handler for the 'Pose Detected' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromPoseDetected(XnCallbackHandle hCallback)
{
PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
xnOSFree(pPoseCookie);
}
/**
* @brief Unregisters an event handler for the 'Out Of Pose' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromOutOfPose(XnCallbackHandle hCallback)
{
PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
xnOSFree(pPoseCookie);
}
/**
* <b>'Pose In Progress' event</b>:
*
* Raised at each frame time from the time StartPoseDetection was called until the
* pose is detected. This event returns the current status of pose detection of
* a user.
*
* @param [in] pose Reference to the specific @ref UserGenerator node that raised
* the event.
* @param [in] strPose Name of the specific pose defined for this event handler.
* (The PoseDetectionCapability can define more than a single pose that can be detected.
* @param [in] user ID of the user that entered the pose.
* @param [in] poseError Current status of the pose detection.
* Defined statuses:
* XN_POSE_DETECTION_STATUS_OK
* XN_POSE_DETECTION_STATUS_NO_USER
* XN_POSE_DETECTION_STATUS_TOP_FOV
* XN_POSE_DETECTION_STATUS_SIDE_FOV
* XN_POSE_DETECTION_STATUS_ERROR
* @param [in] pCookie Returns any information ("cookie") that the application
* placed in this parameter at the time of registering the event.
*/
typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
/**
* @brief Registers an event handler for the 'Pose In Progress' event.
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*
* <b>Remarks</b>
*
* This event is raised at each frame time from the time StartPoseDetection() method
* was called until the pose is actually detected.
*
* See the @ref PoseDetection callback type declaration for how to write the callback
* (event handler).
*/
inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
PoseInProgressCookie* pPoseCookie;
XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
pPoseCookie->handler = handler;
pPoseCookie->pPoseCookie = pCookie;
nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pPoseCookie);
return (nRetVal);
}
hCallback = pPoseCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'Pose In Progress' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromPoseInProgress(XnCallbackHandle hCallback)
{
PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
xnOSFree(pPoseCookie);
}
/** @cond */
inline XnStatus XN_API_DEPRECATED("Use GetAllAvailablePoses() instead") GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
{
return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
}
inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
PoseCookie* pPoseCookie;
XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
pPoseCookie->startHandler = PoseStartCB;
pPoseCookie->endHandler = PoseEndCB;
pPoseCookie->pPoseCookie = pCookie;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
#pragma warning (pop)
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pPoseCookie);
return (nRetVal);
}
hCallback = pPoseCookie;
return (XN_STATUS_OK);
}
inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
{
PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
#pragma warning (pop)
xnOSFree(pPoseCookie);
}
/** @endcond */
private:
typedef struct PoseCookie
{
PoseDetection startHandler;
PoseDetection endHandler;
void* pPoseCookie;
XnCallbackHandle hCallback;
} PoseCookie;
static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
{
PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
PoseDetectionCapability cap(hNode);
if (pPoseCookie->startHandler != NULL)
{
pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
}
}
static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
{
PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
PoseDetectionCapability cap(hNode);
if (pPoseCookie->endHandler != NULL)
{
pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
}
}
typedef struct PoseDetectionCookie
{
PoseDetection handler;
void* pPoseCookie;
XnCallbackHandle hCallback;
} PoseDetectionCookie;
static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
{
PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
PoseDetectionCapability cap(hNode);
if (pPoseDetectionCookie->handler != NULL)
{
pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
}
}
typedef struct PoseInProgressCookie
{
PoseInProgress handler;
void* pPoseCookie;
XnCallbackHandle hCallback;
} PoseInProgressCookie;
static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
{
PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
PoseDetectionCapability cap(hNode);
if (pPoseCookie->handler != NULL)
{
pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
}
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> The UserGenerator node generates data describing users that it recognizes
* in the scene, identifying each user individually and thus allowing actions to be
* done on specific users.
*
* <b>Usage:</b> Instantiate the class and call Create() to create a user generator node.
*
* <b>Data output:</b>
* - CoM from UserGenerator local data
* - User pixels from @ref SceneMetaData
*
* <b>Capabilities:</b>
* - @ref SkeletonCapability
* - @ref PoseDetectionCapability
*
* <b>Remarks:</b>
*
* The UserGenerator node provides access to the recognized users through user IDs it
* returns. The user IDs are unique user identification numbers. The application uses
* these user IDs to pass them to various methods of this node to access the specific
* data of the specified user. For example:
*
* @ref xn::UserGenerator::GetUserPixels() gets the pixel map of a specific user, and
* @ref xn::UserGenerator::GetCoM() gets the location of the center of mass of a specific
* user.
*
* Typically, an application will require only a single UserGenerator node. However,
* there are cases where more than one UserGenerator node could be required. For example,
* where there are two sensors it may be convenient to build a production graph with
* two UserGenerator nodes, one node for each depth output.
*
* <b>Main Features:</b>
*
* - User CoM: Provides the location of the center of mass of a specific user.
* - Number of users: Provides the number of users currently detected in the scene.
* - Users list: Provides a list of the IDs of currently recognized users in the scene.
* - User pixels: Provides the pixels that represent a specific user.
* - Events: Provides events about users in the scene:
* - A new user is identified ('New User')
* - An existing user exits temporarily ('User Exit')
* - An exited user returns ('User Reenter')
* - An existing user exits permanently ('Lost User')
*
* @note Registering to the 'New User' and 'Lost User' events is done by calling @ref RegisterUserCallbacks().
* Registering to the 'User Exit' and 'User Reenter' events is done by calling @ref RegisterToUserExit() and @ref RegisterToUserReEnter().
*
* @section user_events Events
*
* <b>New User' event</b>
*
* Signals that a new user has now been recognized in the scene. A new user is a
* user that was not previously recognized in the scene, and is now recognized in
* the scene.
*
* <b>'Lost User' event</b>
*
* Signals that a user has been lost from the list of previously recognized users
* in the scene.
*
* The exact meaning of a lost user is decided by the developer of the user generator.
* However, a typical implementation would define that a lost user is a previously
* recognized user that then exits the scene and does not return, even after a 'Lost
* User' timeout has elapsed. Thus this event is raised only after some delay after
* the user actually exited the scene.
*
* Using the above approach, the difference then between the 'Lost User' event and
* the 'User Exit' event (see below) would be that the 'User Exit' event is raised
* every time a recognized user leaves the scene, but a 'Lost User' event is raised
* only after the user has remained absent ("exit-ed") for a certain timeout period
* of time.
*
* If no timeout is used at all, the 'User Exit' and 'User Reenter' events are redundant.
*
* <b>'User Exit' event</b>
*
* Signals that a user now exited from the scene.
*
* The exact meaning of a user that exited is decided by the developer of the
* user generator. However, a typical implementation would define that a user that
* exited the scene is a previously recognized user that then leaves the scene.
* but returns within a specified time, before the 'Lost User' timeout has elapsed.
* In such a case the UserGenerator object still remembers the user and so when
* the user comes back, everything known about it is restored. See the 'Lost User'
* event above for more explanation of the difference between the 'User Exit' event
* and the 'Lost User' event in a typical implementation.
*
* <b>'User Reenter' event</b>
*
* Signals that a user has now reentered to the scene after exiting. A user that
* reenters the scene after exiting is a recognized user that exited, but now is
* returning within a specified permitted time span, before the 'Lost User' timeout
* has elapsed. In such a case the UserGenerator node still remembers the user and
* so when the user returns, everything known about it is restored.
*
* <b>Event Sequence</b>
*
* The following event sequences are typical:
*
* A:
* -# 'New User'
* -# 'User Exit'
* -# 'Lost User'
*
* B:
* -# 'New User'
* -# 'User Exit'
* -# 'User Reenter'
* -# 'User Exit'
* -# 'Lost User'
*/
class UserGenerator : public Generator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
/**
* @brief Creates a UserGenerator node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks:</b>
*
* See @ref create_method for a detailed description of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Event handler signature for all UserGenerator events.
*
* Example of a handler prototype (for the 'New User' event in this case):
@code
void XN_CALLBACK_TYPE OnNewUser(xn::UserGenerator& generator, XnUserID nId, void* pCookie)
@endcode
*
* @param [in] generator UserGenerator node that raised the event.
* @param [in] user ID of the user.
* @param [in] pCookie User's cookie, to be delivered to the callback.
*/
typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
/**
* @brief Gets the number of users currently identified in the scene.
*
* <b>Remarks:</b>
*
* The result of this method is required as input for the GetUsers() method.
*/
inline XnUInt16 GetNumberOfUsers() const
{
return xnGetNumberOfUsers(GetHandle());
}
/**
* @brief Gets an array of user IDs of all the recognized users in the scene at the current time.
*
* @param [out] aUsers Preallocated memory for the method to enter the user IDs.
* @param [in,out] nUsers Number of users.
*
* @c nUsers is used both as an in parameter and an out one in this method:
* [in] Size of the aUsers array (in units of users).
* To get the value of nUsers (i.e., the size of array that you want - see
* parameter below), you use the GetNumberOfUsers() method.
* For example, if you want an array of size 4 - to contain a maximum of 4 users -
* you pass 4 as the value of this parameter.
*
* [out] On completion, the method returns the number of users that were recognized.
* E.g., if there is actually only one user, the output will be 1, although the
* caller passed a value of 4 (as above) for to allocate an array of size 4.
*
* <b>Remarks:</b>
*
* The output user IDs from this method can be used as input to the @ref xn::UserGenerator::GetCoM()
* method for getting the center of mass of each user.
*/
inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
{
return xnGetUsers(GetHandle(), aUsers, &nUsers);
}
/**
* @brief Gets the position of a user's center of mass. This is the single point for
* representing the user.
*
* @param [in] user Specifies a user ID.
* @param [out] com The user's center of mass in 3-D coordinates.
*
* The center of mass is a useful point to represent the user. When you don't have
* any other reference point (e.g., you don't have the position of a specific joint,
* or of the head, or any other such point), this is an adequate point with which
* to start to represent the user.
*
* <b>Remarks:</b>
*
* The returned @ref XnPoint3D value is the center of mass of all the shown pixels
* that belong to that user, but not necessarily the real center of mass of the
* human user.
* The application can use this method to request the center of mass for each user.
*/
inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
{
return xnGetUserCoM(GetHandle(), user, &com);
}
/**
* @brief Gets the pixel map of the specified user in the scene and saves it in the @ref xn::SceneMetaData object.
* The pixels that form part of the user's body are labeled with user's ID. Other values are irrelevant.
*
* @param [in] user The ID of the user the pixel map should be returned for.
* @param [out] smd Struct to be filled with the pixel map.
*
* <b>Remarks:</b>
*
* A usage example for this method in gaming is for coloring the avatar on the screen.
*
* The special value 0 (zero) can be used in the @c user parameter, telling the generator to return a label map
* containing all users, where each pixel is either marked as 0 (background pixel) or with the user ID to which
* it belongs.
*/
inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd) const
{
return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
}
/**
* @brief Registers event handlers for the 'New User' and 'Lost User' events.
*
* @param [in] NewUserCB Callback function to be invoked when the 'New User' event is raised.
* @param [in] LostUserCB Callback function to be invoked when the 'Lost User' event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
UserCookie* pUserCookie;
XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
pUserCookie->newHandler = NewUserCB;
pUserCookie->lostHandler = LostUserCB;
pUserCookie->pUserCookie = pCookie;
nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pUserCookie);
return (nRetVal);
}
hCallback = pUserCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters event handlers for the 'New User' and 'Lost User' events.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
{
UserCookie* pUserCookie = (UserCookie*)hCallback;
xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
xnOSFree(pUserCookie);
}
/**
* @brief Gets a @ref SkeletonCapability object for accessing Skeleton functionality.
*
* <b>Remarks:</b>
*
* Once the @ref SkeletonCapability object has been obtained, the application can
* work with a skeleton.
*
* It is the application's responsibility to check first if Skeleton capability
* is supported by calling the @ref IsCapabilitySupported() method..
*/
inline const SkeletonCapability GetSkeletonCap() const
{
return SkeletonCapability(GetHandle());
}
/**
* @brief Gets a @ref SkeletonCapability object for accessing Skeleton functionality.
*
* <b>Remarks:</b>
*
* Once the @ref SkeletonCapability object has been obtained, the application can
* work with a skeleton.
*
* It is the application's responsibility to check first if Skeleton capability
* is supported by calling the @ref IsCapabilitySupported() method..
*/
inline SkeletonCapability GetSkeletonCap()
{
return SkeletonCapability(GetHandle());
}
/**
* @brief Gets a @ref xn::PoseDetectionCapability object for accessing Pose Detection
* functionality
*
* <b>Remarks:</b>
*
* It is the application responsibility to check first if @ref XN_CAPABILITY_POSE_DETECTION
* is supported
* by calling @ref xn::ProductionNode::IsCapabilitySupported().
*/
inline const PoseDetectionCapability GetPoseDetectionCap() const
{
return PoseDetectionCapability(GetHandle());
}
/**
* @brief Gets a @ref xn::PoseDetectionCapability object for accessing Pose Detection
* functionality
*
* <b>Remarks:</b>
*
* It is the application responsibility to check first if @ref XN_CAPABILITY_POSE_DETECTION
* is supported
* by calling @ref xn::ProductionNode::IsCapabilitySupported().
*/
inline PoseDetectionCapability GetPoseDetectionCap()
{
return PoseDetectionCapability(GetHandle());
}
/**
* @brief Registers an event handler for the 'User Exit' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
UserSingleCookie* pUserCookie;
XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
pUserCookie->handler = handler;
pUserCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pUserCookie);
return (nRetVal);
}
hCallback = pUserCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'User Exit' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromUserExit(XnCallbackHandle hCallback)
{
UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
xnOSFree(pUserCookie);
}
/**
* @brief Registers an event handler for the 'User Reenter' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
UserSingleCookie* pUserCookie;
XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
pUserCookie->handler = handler;
pUserCookie->pUserCookie = pCookie;
nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
if (nRetVal != XN_STATUS_OK)
{
xnOSFree(pUserCookie);
return (nRetVal);
}
hCallback = pUserCookie;
return (XN_STATUS_OK);
}
/**
* @brief Unregisters an event handler for the 'User Reenter' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromUserReEnter(XnCallbackHandle hCallback)
{
UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
xnOSFree(pUserCookie);
}
private:
typedef struct UserCookie
{
UserHandler newHandler;
UserHandler lostHandler;
void* pUserCookie;
XnCallbackHandle hCallback;
} UserCookie;
static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
{
UserCookie* pUserCookie = (UserCookie*)pCookie;
UserGenerator gen(hNode);
if (pUserCookie->newHandler != NULL)
{
pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
}
}
static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
{
UserCookie* pUserCookie = (UserCookie*)pCookie;
UserGenerator gen(hNode);
if (pUserCookie->lostHandler != NULL)
{
pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
}
}
typedef struct UserSingleCookie
{
UserHandler handler;
void* pUserCookie;
XnCallbackHandle hCallback;
} UserSingleCookie;
static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
{
UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
UserGenerator gen(hNode);
if (pUserCookie->handler != NULL)
{
pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
}
}
};
/**
* @ingroup cppref_prd_func
* <b>Purpose:</b> An audio generator node generates audio data.
*
* <b>Event: 'Wave Output Mode Change'</b>
*
* Signals that the node's current configuration's Wave Output Mode has been changed
* to some other wave output mode.
*
* Use @ref RegisterToWaveOutputModeChanges() and @ref UnregisterFromWaveOutputModeChanges() for using this event.
*
* This event is raised by calling SetWaveOutputMode().
*/
class AudioGenerator : public Generator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
/**
* @brief Creates an AudioGenerator node from available @ref node_alternative "production node alternatives".
*
* <b>Remarks</b>
*
* See @ref create_method for a detailed description of this method.
*/
inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
/**
* @brief Gets the audio generator node's latest @ref glos_frame_object "frame object", saving
* it in the @ref xn::AudioMetaData object. This @ref glos_frame_object "frame object" is a
* snapshot of the generated label map data and its associated configuration information at a
* certain point in time. This saved @ref glos_frame_object "frame object" provides fast
* and easy access to the audio generator node's data and configuration information.
*
* @param [out] metaData Structure to be filled with the frame object.
*
* <b>Remarks:</b>
*
* This method is central in the use of the AudioGenerator node. Once the AudioGenerator
* node is generating data, after each @ref conc_updating_data "'Update Data'" call,
* the application calls this method to get the node's frame object, which contains
* the data and all its associated properties.
*/
inline void GetMetaData(AudioMetaData& metaData) const
{
xnGetAudioMetaData(GetHandle(), metaData.GetUnderlying());
}
/**
* @copybrief xnGetAudioBuffer
* For full details and usage, see @ref xnGetAudioBuffer
*/
inline const XnUChar* GetAudioBuffer() const
{
return xnGetAudioBuffer(GetHandle());
}
/**
* @brief Gets the node's number of supported wave output modes.
*/
inline XnUInt32 GetSupportedWaveOutputModesCount() const
{
return xnGetSupportedWaveOutputModesCount(GetHandle());
}
/**
* @brief Returns a list of the wave output modes that the @ref AudioGenerator node supports.
* @param [out] aSupportedModes Buffer to be filled with the list of wave output modes.
* @param [in,out] nCount [in] Size of the array.
[out] Number of modes returned.
*/
inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
{
return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
}
/**
* @brief Sets the current wave output mode of the AudioGenerator node. This output mode
* is used for generating the next audio packet.
*
* @param [in] OutputMode Mode to set as the current wave output mode.
*
* <b>Remarks</b>
*
* The wave output mode is contained in the @ref xn::XnWaveOutputMode struct. It
* comprises: bits per sample, channel, and sample rate.
*/
inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
{
return xnSetWaveOutputMode(GetHandle(), &OutputMode);
}
/**
* @brief Gets the current AudioGenerator node's wave output mode. This output mode
* is used for generating the next audio packet.
*
* @param [out] OutputMode Current wave output mode.
*
* <b>Remarks</b>
*
* The wave output mode is contained in the XnWaveOutputMode struct. Each wave output
* mode comprises settings for bits per sample, channel, and sample rate, as follows:
*/
inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
{
return xnGetWaveOutputMode(GetHandle(), &OutputMode);
}
/**
* @brief Registers an event handler for the 'Wave Output Mode Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
}
/**
* @brief Unregisters an event handler for the 'Wave Output Mode Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
{
_UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
}
};
/**
* @ingroup cppref_prd_func
* Represents a Mock Audio Generator node
*/
class MockAudioGenerator : public AudioGenerator
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
/**
* Creates a mock audio generator
*
* @param [in] context The context in which the node should be generated
* @param [in] strName Optional. The name of the new node.
*/
XnStatus Create(Context& context, const XnChar* strName = NULL);
/**
* Creates a mock audio generator, copying the initial state from another audio
* generator.
*
* @param [in] other The audio generator to copy state from
* @param [in] strName Optional. The name of the new node.
*/
XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
/**
* @copybrief xnMockAudioSetData
* For full details and usage, see @ref xnMockAudioSetData
*/
inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
{
return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
}
/**
* Sets the data of the mock node from a meta data object, overriding frame ID and
* timestamp
*
* @param [in] audioMD Object to take data from
* @param [in] nFrameID Frame ID
* @param [in] nTimestamp Timestamp
*/
inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
{
return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
}
/**
* Sets the data of the mock node from a meta data object
*
* @param [in] audioMD Object to take data from
*/
inline XnStatus SetData(const AudioMetaData& audioMD)
{
return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
}
};
/**
* @ingroup cppref_prd_func
*/
class MockRawGenerator : public Generator
{
public:
MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
inline XnStatus Create(Context& context, const XnChar* strName = NULL);
inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
{
return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
}
};
/**
* @ingroup cppref_prd_func
* Represents a Codec node.
*/
class Codec : public ProductionNode
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
/**
* @copybrief xnCreateCodec
* For full details and usage, see @ref xnCreateCodec
*/
inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
/**
* @copybrief xnGetCodecID
* For full details and usage, see @ref xnGetCodecID
*/
inline XnCodecID GetCodecID() const
{
return xnGetCodecID(GetHandle());
}
/**
* @copybrief xnEncodeData
* For full details and usage, see @ref xnEncodeData
*/
inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
{
return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
}
/**
* @copybrief xnDecodeData
* For full details and usage, see @ref xnDecodeData
*/
inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
{
return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
}
};
/**
* @ingroup cppref_prd_func
*
* <b>Purpose:</b> The ScriptNode object loads an XML script from a file or string,
* and then runs the XML script to build a production graph. It also references every
* node created from that script, so it wouldn't be destroyed.
*
* <b>Remarks:</b>
*
* A typical usage of a script node is:
* - Create the script node, using the @ref Create() method.
* - Load XML script from file or string, using @ref LoadScriptFromFile() or @ref LoadScriptFromString().
* - Execute the script, using @ref Run().
*
* Note that the context's @ref xn::Context::RunXmlScriptFromFile "RunXmlScriptFromFile()" or
* @ref xn::Context::RunXmlScript "RunXmlScript()" methods can be used to perform
* all above steps.
* All production nodes in the production graph use reference count to determine their life time,
* but if an application executed a script, it can't know upfront which nodes will be created
* by this script, and so, can't take reference to them, so those nodes might be destroyed
* immediately. The script node, apart from executing the script, also keeps reference to
* all the nodes created by the script. This means that if the script node is destroyed,
* every production node that was created by the script, and is unreferenced by the application
* will also be destroyed. For this reason, it is recommended for application using XML scripts
* to keep a reference to the script node as long as they keep a reference to the context itself.
*
* A single ScriptNode object is responsible for building the entire production graph,
* irrespective of however many node definitions there are in the XML script and how
* many production nodes are created.
*
* For additional information about XML scripts, see @ref xmlscripts.
*/
class ScriptNode : public ProductionNode
{
public:
/**
* Ctor
*
* @param [in] hNode Node handle
*/
inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
inline XnStatus Create(Context& context, const XnChar* strFormat);
inline const XnChar* GetSupportedFormat()
{
return xnScriptNodeGetSupportedFormat(GetHandle());
}
/**
* @brief Loads an XML script file into the ScriptNode object.
*
* @param [in] strFileName Name of file containing an XML script.
*/
inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
{
return xnLoadScriptFromFile(GetHandle(), strFileName);
}
/**
* @brief Loads an XML script string into the ScriptNode object.
*
* @param [in] strScript String containing an XML script.
*/
inline XnStatus LoadScriptFromString(const XnChar* strScript)
{
return xnLoadScriptFromString(GetHandle(), strScript);
}
/**
* @brief Runs the ScriptNode object's XML script to build a production graph.
*
* @param [out] pErrors List of enumeration errors produced during method execution.
*
* <b>Remarks</b>
*
* This method causes the whole production graph to enter Generating state. To read
* data you have to run one of the @ref conc_updating_data "'Update Data'" methods
* of the Context or of the node itself.
*/
inline XnStatus Run(EnumerationErrors* pErrors);
};
//---------------------------------------------------------------------------
// EnumerationErrors
//---------------------------------------------------------------------------
/**
* @ingroup cppref_graph_mgmt
* <b>Purpose:</b> An EnumerationError object returns a full list of modules that failed
* to enumerate specifying exactly why each module failed.
*
* <b>Usage:</b> Instantiate and pass to enumeration methods.
*
* <b>Remarks:</b>
*
* Sometimes an application enumerates for a specific node, and receives zero results.
* An obvious reason for this failure is that no module implementing the node type was
* installed. Another possible reason is that a module may be installed but has no license.
* Yet another possible reason is that a required hardware device is currently disconnected.
*
* Applications can use the EnumerationErrors class to acquire a full list of modules
* that failed to enumerate specifying for each exactly why each module failed.
*
* The methods provided by the EnumerationErrors class let the application search enumeration
* lists for specific types of nodes.
*/
class EnumerationErrors
{
public:
/**
* Ctor
*/
inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
/**
* Ctor
*
* @param [in] pErrors underlying C object to wrap
* @param [in] bOwn TRUE to own the object (i.e. free it upon destruction), FALSE
* otherwise.
*/
inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
/**
* Dtor
*/
~EnumerationErrors() { Free(); }
/**
* An iterator over enumeration errors
*/
class Iterator
{
public:
friend class EnumerationErrors;
/**
* Checks if the other iterator points to the same location
*
* @param [in] other another iterator
*/
XnBool operator==(const Iterator& other) const
{
return m_it == other.m_it;
}
/**
* Checks if the other iterator points to a different location
*
* @param [in] other another iterator
*/
XnBool operator!=(const Iterator& other) const
{
return m_it != other.m_it;
}
/**
* Moves the iterator to the next location. If end of list was reached, iterator
* will be equal to @ref EnumerationErrors::End().
*/
inline Iterator& operator++()
{
m_it = xnEnumerationErrorsGetNext(m_it);
return *this;
}
/**
* Returns an iterator to the next location. If end of list was reached, iterator
* will be equal to @ref EnumerationErrors::End().
*/
inline Iterator operator++(int)
{
return Iterator(xnEnumerationErrorsGetNext(m_it));
}
/**
* @brief Returns the description data of the failing node the iterator points to.
*
* <b>Remarks</b>
*
* The description data returned in the @ref XnProductionNodeDescription struct
* includes the node name, the vendor, and the version.
*/
inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
/**
* @brief Returns the failure error code of the failing node the iterator points to.
* For a string representation of this error, call @ref xnGetStatusString().
*/
inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
private:
inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
XnEnumerationErrorsIterator m_it;
};
/**
* @brief Gets an iterator to the first item in an enumeration errors list.
*
* <b>Remarks</b>
*
* To access the contents of the error item, either use the @ref ToString() method
* of this class or the methods of the @ref EnumerationErrors::Iterator class.
*/
inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); }
/**
* @brief Returns an iterator referring to the past-the-end element in an enumeration errors list.
* This iterator does not point to an actual item.
*
* <b>Remarks</b>
*
* Use this as the sentinel for flagging the end of a list when searching.
*/
inline Iterator End() const { return Iterator(NULL); }
/**
* @brief Returns a string representation of the Enumeration Errors object. The string
* contains a full list of the modules that failed the most recent enumeration operation.
* For each failed module, the Enumeration Errors object specifies why exactly the module failed.
*
* @param [in] csBuffer Character buffer to be filled.
* @param [in] nSize Size of the character buffer.
*/
inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
{
return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
}
/**
* @copybrief xnEnumerationErrorsFree
* For full details and usage, see @ref xnEnumerationErrorsFree
*/
inline void Free()
{
if (m_bAllocated)
{
xnEnumerationErrorsFree(m_pErrors);
m_pErrors = NULL;
m_bAllocated = FALSE;
}
}
/**
* Gets the underlying C object
*/
inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
private:
XnEnumerationErrors* m_pErrors;
XnBool m_bAllocated;
};
//---------------------------------------------------------------------------
// Context
//---------------------------------------------------------------------------
/**
* @ingroup cppref_graph_mgmt
*
* A context is a workspace where the application builds an OpenNI production graph.
* It contains methods for managing the production graph.
*
* In order to use any of the OpenNI functionality you must first construct a Context
* object and initialize it. Prior to this, the application cannot do anything with
* OpenNI.
*
* For a comprehensive overview to the Context class and its members, see @ref conc_context
* "Overview to Contexts".
*
* @section context_global_error_event Event: 'Global Error State Change'
*
* Signals that the error state of any of the nodes has changed.
*
* This event can be used by the application to get a signal as soon as any error occurs
* in one of the production nodes. The global error state aggregates error state from all
* the production nodes in the context.
*
* Use @ref RegisterToErrorStateChange() and @ref UnregisterFromErrorStateChange() for using this event.
*
* @section context_node_creation_event Event: 'Node Creation'
*
* Signals that a new node was created in the context production graph.
*
* Use @ref RegisterToNodeCreation() and @ref UnregisterFromNodeCreation() for using this event.
*
* @section context_node_destruction_event Event: 'Node Destruction'
*
* Signals that a node was removed from the context production graph, and destroyed.
*
* Use @ref RegisterToNodeDestruction() and @ref UnregisterFromNodeDestruction() for using this event.
*/
class Context
{
public:
/**
* Callback prototype for the @ref context_node_creation_event "'Node Creation'" event handler.
*
* @param [in] context The context that raised this event.
* @param [in] createdNode The id of the hand that disappeared.
* @param [in] pCookie A user-provided cookie that was given when registering to
* this event.
*
* Example for such a handler:
@code
void XN_CALLBACK_TYPE OnNodeCreation(Context& context, ProductionNode& createdNode, void* pCookie)
{}
@endcode
*/
typedef void (XN_CALLBACK_TYPE* NodeCreationHandler)(Context& context, ProductionNode& createdNode, void* pCookie);
/**
* Callback prototype for the @ref context_node_destruction_event "'Node Destruction'" event handler.
*
* @param [in] context The context that raised this event.
* @param [in] strDestroyedNodeName The name of the node that was destroyed.
* @param [in] pCookie A user-provided cookie that was given when registering to
* this event.
*
* Example for such a handler:
@code
void XN_CALLBACK_TYPE OnNodeDestruction(Context& context, const XnChar* strDestroyedNodeName, void* pCookie)
{}
@endcode
*/
typedef void (XN_CALLBACK_TYPE* NodeDestructionHandler)(Context& context, const XnChar* strDestroyedNodeName, void* pCookie);
/**
* Ctor
*/
inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
/**
* Ctor
*
* @param [in] pContext Underlying C object
*/
inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
{
SetHandle(pContext);
}
/**
* Copy Ctor
*
* @param [in] other Another context. Note that the context will only be destroyed
* when the original object is destroyed.
*/
inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
{
SetHandle(other.m_pContext);
}
/**
* Dtor
*/
~Context()
{
SetHandle(NULL);
}
inline Context& operator=(const Context& other)
{
SetHandle(other.m_pContext);
return *this;
}
/**
* Gets the underlying C object
*/
inline XnContext* GetUnderlyingObject() const { return m_pContext; }
/**
* Checks if two context objects are references to the same context.
*
* @param [in] other Another object
*/
inline XnBool operator==(const Context& other)
{
return (GetUnderlyingObject() == other.GetUnderlyingObject());
}
/**
* Checks if two context objects are <i>not</i> references to the same context.
*
* @param [in] other Another object
*/
inline XnBool operator!=(const Context& other)
{
return (GetUnderlyingObject() != other.GetUnderlyingObject());
}
/**
* @brief Builds the context's general software environment.
*
* This method initializes runtime variables and data structures, and examines all
* registered plug-ins to learn the purpose and specific capabilities of each. In
* particular, during initialization the context initialization examines all registered
* plug-ins to learn the purpose and specific capabilities of each. For example,
* one plug-in is for creating a skeleton node, and another plug-in is for creating
* a depth node. Thus an entire database is built of plug-ins that can be queried
* according to vendor, model, and capabilities of each.
*
* Once you have completed the initialization you can create nodes that are based
* on the plug-ins that OpenNI has discovered by this initialization process.
*/
inline XnStatus Init()
{
XnContext* pContext = NULL;
XnStatus nRetVal = xnInit(&pContext);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(pContext);
m_bAllocated = TRUE;
return (XN_STATUS_OK);
}
/**
* @brief Runs an XML script string to build a production graph.
*
* @param [in] strScript String containing an XML script.
* @param [out] scriptNode @ref xn::ScriptNode object as the root to all the nodes
* created from the XML file. When no longer needed, the node can
* be released, causing all the created nodes to decrement their reference counts.
* @param [in,out] pErrors Optional. To be filled with enumeration errors.
*
* <B>Remarks:</B>
*
* For a full description of the XML structure, see @ref xmlscripts.
* Compare this method with initialization methods that run an XML script from a
* file.
*/
inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hScriptNode;
nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
XN_IS_STATUS_OK(nRetVal);
scriptNode.TakeOwnership(hScriptNode);
return (XN_STATUS_OK);
}
/**
* @brief Runs an XML script file to build a production graph.
*
* @param [in] strFileName Name of file containing an XML script.
* @param [out] scriptNode scriptNode object as the root to all the nodes created
* from the XML file. When no longer needed, the node can
* be released, causing all the created nodes to decrement
* their reference counts.
* @param [in,out] pErrors Optional. To be filled with enumeration errors.
*
* <B>Remarks:</B>
*
* The XML script file describes all the nodes you want to create. For each node
* description in the XML file, this method creates a @ref xn::ProductionNode object.
*/
inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hScriptNode;
nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
XN_IS_STATUS_OK(nRetVal);
scriptNode.TakeOwnership(hScriptNode);
return (XN_STATUS_OK);
}
/**
* @brief Shorthand combination of two other initialization methods - @ref Init() and then @ref RunXmlScriptFromFile() -
* to initialize the context object and then create a production graph.
*
* @param [in] strFileName Name of file containing an XML script.
* @param [out] scriptNode ScriptNode object as the root to all the nodes created
* from the XML file. When no longer needed, the node can be
* released, causing all the created nodes to decrement their reference counts.
* @param [out] pErrors Optional. To be filled with enumeration errors.
*
* <B>Remarks:</B>
*
* The XML script file describes all the nodes you want to create. For each node
* description in the XML file, this method creates a @ref xn::ProductionNode object.
*/
inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
{
XnContext* pContext = NULL;
XnNodeHandle hScriptNode;
XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
XN_IS_STATUS_OK(nRetVal);
scriptNode.TakeOwnership(hScriptNode);
TakeOwnership(pContext);
m_bAllocated = TRUE;
return (XN_STATUS_OK);
}
/**
* @brief Recreates a production graph from a recorded ONI file and then replays the data
* generation exactly as it was recorded.
*
* @param [in] strFileName Name of the recorded file to be run.
* @param [out] playerNode Returns a @ref xn::Player object through which
* playback can be controlled, e.g., seeking and setting playback speed.
*
* <B>Remarks:</B>
*
* OpenNI provides great flexibility of recording. You can decide you want to record
* only the final output, e.g., just a skeleton in movement; or record both the
* output skeleton and the depth input; or record only the depth input and then
* recreate the skeleton at run-time after reading the recorded raw depth data.
* You can also choose which nodes to record.
*/
inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hPlayer;
nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
XN_IS_STATUS_OK(nRetVal);
playerNode.TakeOwnership(hPlayer);
return (XN_STATUS_OK);
}
/**
* @copybrief xnCreateMockNode
* For full details and usage, see @ref xnCreateMockNode
*/
inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hMockNode;
nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
XN_IS_STATUS_OK(nRetVal);
mockNode.TakeOwnership(hMockNode);
return (XN_STATUS_OK);
}
/**
* @copybrief xnCreateMockNodeBasedOn
* For full details and usage, see @ref xnCreateMockNodeBasedOn
*/
inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hMockNode;
nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
XN_IS_STATUS_OK(nRetVal);
mockNode.TakeOwnership(hMockNode);
return (XN_STATUS_OK);
}
/**
* @copybrief xnCreateCodec
* For full details and usage, see @ref xnCreateCodec
*/
inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hCodec;
nRetVal = xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
XN_IS_STATUS_OK(nRetVal);
codec.TakeOwnership(hCodec);
return (XN_STATUS_OK);
}
/**
* @copybrief xnContextAddRef
* For full details and usage, see @ref xnContextAddRef
*/
inline XnStatus AddRef()
{
return xnContextAddRef(m_pContext);
}
/**
* @copybrief xnContextRelease
* For full details and usage, see @ref xnContextRelease
*/
inline void Release()
{
SetHandle(NULL);
}
/**
* @copybrief xnAddLicense
* For full details and usage, see @ref xnAddLicense
*/
inline XnStatus AddLicense(const XnLicense& License)
{
return xnAddLicense(m_pContext, &License);
}
/**
* @copybrief xnEnumerateLicenses
* For full details and usage, see @ref xnEnumerateLicenses
*/
inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
{
return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
}
/**
* @copybrief xnFreeLicensesList
* For full details and usage, see @ref xnFreeLicensesList
*/
inline static void FreeLicensesList(XnLicense aLicenses[])
{
xnFreeLicensesList(aLicenses);
}
/**
* @brief Enumerates all available production nodes for a specific node type (e.g., the application wants to create a
* depth generator node) and returns a full list of matching production nodes.
*
* @param [in] Type Requested node type.
* @param [in] pQuery Optional. A query object that can be used to filter results.
* @param [out] TreesList List of possible production nodes.
* @param [out] pErrors Optional. To contain enumeration errors.
*
* <B>Remarks:</B>
*
* The application chooses one of the nodes from the node list returned by this method and uses it as input
* to the @ref xn::Context::CreateProductionTree() method to create a new production node.
*
* Using this method to help create a production node offers the greatest flexibility since it returns a
* complete list of matching production nodes and so the application can then choose the most suitable node.
*
* By contrast, using @ref xn::Context::CreateAnyProductionTree() "CreateAnyProductionTree()" or a node's <b>Create()</b>
* method creates a node from the first matching node that satisfies the query.
*/
XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
{
XnStatus nRetVal = XN_STATUS_OK;
const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
XnNodeInfoList* pList = NULL;
nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TreesList.ReplaceUnderlyingObject(pList);
return (XN_STATUS_OK);
}
/**
* @brief Enumerates for production nodes of a specific node type, and creates the first
* production node found of that type.
*
* @param [in] type Requested node type.
* @param [in] pQuery Optional. A query object that can be used to filter results.
* @param [out] node Handle to the newly created node.
* @param [in,out] pErrors Optional. To contain enumeration errors.
*
* <B>Remarks:</B>
*
* This method is a 'shortcut' version of using the @ref EnumerateProductionTrees()
* method and then passing the first result to @ref CreateProductionTree().
* Thus, this method is exactly like the <b>Create()</b> method for nodes.
*
* Other ways of creating a production graph let the application retrieve a complete
* list of alternatives and then choose the most appropriate alternative.
*
* This method is the method used by the above XML script methods to create the
* ProductionNode objects. The XML method runs the XML script, and for each node
* description the XML method runs this function to create that node.
*
* Using this function is called 'creating a node from the context'. You can also
* create a node by invoking the <b>Create</b> method of the node itself, e.g.,
* the @ref xn::HandsGenerator::Create "Create()" method of a @ref xn::HandsGenerator
* "HandsGenerator" node.
*
* By default, this method does not enable the production nodes to start generating
* data immediately on creation.
*
* @sa @ref create_method for more detail.
*/
XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
XnNodeHandle hNode;
nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
node.TakeOwnership(hNode);
return (XN_STATUS_OK);
}
/**
* @brief Creates a production node from the information supplied in a @ref xn::NodeInfo object.
*
* @param [in] Tree Node properties for creating the new node.
* @param [out] node Reference to the new @ref xn::ProductionNode object.
*
* <B>Remarks:</B>
*
* The application gets the NodeInfo object by choosing it from the list returned
* by the @ref xn::Context::EnumerateProductionTrees() method.
*
* If the new production node requires additional nodes for its input, and those
* nodes do not yet exist, then this method creates those additional nodes also
* and associates them with the "original" new production node.
*
*/
XnStatus CreateProductionTree(NodeInfo& Tree, ProductionNode& node)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hNode;
nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
XN_IS_STATUS_OK(nRetVal);
node.TakeOwnership(hNode);
return (XN_STATUS_OK);
}
/**
* @brief Returns a list of all the context's existing created nodes.
*
* @param [out] list List of the context's existing created nodes.
*
* You can use the @ref xn::NodeInfoList::FilterList() method to filter the returned
* list of existing nodes.
*/
XnStatus EnumerateExistingNodes(NodeInfoList& list) const
{
XnNodeInfoList* pList;
XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
XN_IS_STATUS_OK(nRetVal);
list.ReplaceUnderlyingObject(pList);
return (XN_STATUS_OK);
}
/**
* @brief Returns a list of the context's existing created nodes filtered by type.
*
* @param [in] list List of the context's existing created nodes.
* @param [in] type Type to enumerate for.
*
* <B>Remarks</B>
*
* Returns the list after filtering them by type, so it returns a list of the created
* nodes of the specific type only.
*
* An example of a typical case of returning a list of two nodes of the same type
* is where there are two sensors in a 3D set-up and you need to retrieve the corresponding
* two depth nodes to generate data from them.
*
* You can use the @ref xn::NodeInfoList::FilterList() method to filter the returned
* list of existing nodes.
*/
XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
{
XnNodeInfoList* pList;
XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
XN_IS_STATUS_OK(nRetVal);
list.ReplaceUnderlyingObject(pList);
return (XN_STATUS_OK);
}
/**
* @brief Searches for an existing created node of a specified type and returns a reference to it.
*
* @param [in] type Type of node to search for.
* @param [out] node Reference to an existing created node that was found.
*
* <B>Remarks</B>
*
* This method returns only the first node it finds; this method does not return
* the entire list of matching nodes. Compare this with the @ref xn::Context::EnumerateExistingNodes()
* method, which returns the entire list of matching nodes.
* A typical usage is that the application already created all the nodes from XML.
* Then, when it needs to start generating data from a particular node, e.g., the
* skeleton data, it will call FindExistingNode specifying the skeleton type, and
* it will get it and start using it.
*
* This method does not provide a query parameter (compare with @ref xn::Context::EnumerateExistingNodes).
*/
XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hNode;
nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
XN_IS_STATUS_OK(nRetVal);
node.TakeOwnership(hNode);
return (XN_STATUS_OK);
}
/**
* @copybrief xnGetNodeHandleByName
* For full details and usage, see @ref xnGetNodeHandleByName
*/
XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hNode;
nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
XN_IS_STATUS_OK(nRetVal);
node.TakeOwnership(hNode);
return (XN_STATUS_OK);
}
/**
* @copybrief xnGetNodeHandleByName
* For full details and usage, see @ref xnGetNodeHandleByName
*/
XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hNode;
nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
XN_IS_STATUS_OK(nRetVal);
xnProductionNodeRelease(hNode);
nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
return (XN_STATUS_OK);
}
/**
* @brief Ensures all created @ref dict_gen_node "generator nodes" are generating data.
*
*/
inline XnStatus StartGeneratingAll()
{
return xnStartGeneratingAll(m_pContext);
}
/**
* @brief Ensures all @ref dict_gen_node "generator nodes" are not generating data.
*/
inline XnStatus StopGeneratingAll()
{
return xnStopGeneratingAll(m_pContext);
}
/**
* @brief Enables/disables the GlobalMirror flag.
*
* @param [in] bMirror New mirroring state.
*
* <B>Remarks:</B>
*
* See @ref conc_global_mirror for understanding of the 'Global Mirror' concept.
*/
inline XnStatus SetGlobalMirror(XnBool bMirror)
{
return xnSetGlobalMirror(m_pContext, bMirror);
}
/**
* @brief Gets the current state of the GlobalMirror flag.
*
*/
inline XnBool GetGlobalMirror()
{
return xnGetGlobalMirror(m_pContext);
}
/**
* @copybrief xnGetGlobalErrorState
* For full details and usage, see @ref xnGetGlobalErrorState
*/
inline XnStatus GetGlobalErrorState()
{
return xnGetGlobalErrorState(m_pContext);
}
/**
* @brief Registers an event handler for the 'Global Error State Change' event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
}
/**
* @brief Unregisters an event handler for the 'Global Error State Change' event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events .
*/
inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
{
xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
}
/**
* @brief Registers an event handler for the 'Node Creation' event. see @ref context_node_creation_event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToNodeCreation(NodeCreationHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
NodeCreationCookie* pCreationCookie;
XN_VALIDATE_ALLOC(pCreationCookie, NodeCreationCookie);
pCreationCookie->pFunc = handler;
pCreationCookie->pCookie = pCookie;
nRetVal = xnRegisterToNodeCreation(m_pContext, NodeCreationCallback, pCreationCookie, &pCreationCookie->hUnderlyingCallback);
XN_IS_STATUS_OK(nRetVal);
hCallback = pCreationCookie;
return XN_STATUS_OK;
}
/**
* @brief Unregisters an event handler for the 'Node Creation' event. see @ref context_node_creation_event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events.
*/
inline void UnregisterFromNodeCreation(XnCallbackHandle hCallback)
{
NodeCreationCookie* pCreationCookie = (NodeCreationCookie*)hCallback;
xnUnregisterFromNodeCreation(m_pContext, pCreationCookie->hUnderlyingCallback);
xnOSFree(pCreationCookie);
}
/**
* @brief Registers an event handler for the 'Node Destruction' event. see @ref context_node_destruction_event.
*
* @param [in] handler Callback function to be invoked when the event is raised.
* @param [in] pCookie User's cookie, to be delivered to the callback.
* @param [out] hCallback Handle to the callback to be used for unregistering it.
*
* For full details and usage of the parameters, see @ref reg_to_events.
*/
inline XnStatus RegisterToNodeDestruction(NodeDestructionHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
NodeDestructionCookie* pDestructionCookie;
XN_VALIDATE_ALLOC(pDestructionCookie, NodeDestructionCookie);
pDestructionCookie->pFunc = handler;
pDestructionCookie->pCookie = pCookie;
nRetVal = xnRegisterToNodeDestruction(m_pContext, NodeDestructionCallback, pDestructionCookie, &pDestructionCookie->hUnderlyingCallback);
XN_IS_STATUS_OK(nRetVal);
hCallback = pDestructionCookie;
return XN_STATUS_OK;
}
/**
* @brief Unregisters an event handler for the 'Node Destruction' event. see @ref context_node_destruction_event.
*
* @param [in] hCallback Handle received from registration.
*
* For full details and usage of the parameter, see @ref unreg_from_events.
*/
inline void UnregisterFromNodeDestruction(XnCallbackHandle hCallback)
{
NodeDestructionCookie* pDestructionCookie = (NodeDestructionCookie*)hCallback;
xnUnregisterFromNodeDestruction(m_pContext, pDestructionCookie->hUnderlyingCallback);
xnOSFree(pDestructionCookie);
}
/**
* @brief Updates all generator nodes in the context to their latest available data,
* first waiting for all nodes to have new data available.
*
* <b>Remarks</b>
*
* This method requests from OpenNI to cause all nodes in the context's Production
* Graph that have new data available to update their application buffers with the
* new data, each node updating its own application buffer.
*
* Before OpenNI causes the data updates, it waits until @b all the nodes have notified
* that they have new data available. On receiving all the 'new data available'
* notifications, OpenNI then causes all nodes with new data available to update
* their application buffers with their new data. At this stage the generator nodes
* have "generated" new data. This method then stops waiting and returns a success
* status. The application can now read the newly generated data.
*
* @note Using this method is not recommended for most applications since it requires
* <i>all</i> the nodes to have new data. Consider instead using @ref WaitAnyUpdateAll()
* or @ref WaitOneUpdateAll(). Typical applications use the WaitAnyUpdateAll()
* method.
*
* An error situation is defined as: after a preset timeout, not all nodes have
* yet notified OpenNI they have new data available. On error, the method stops
* waiting and returns an error status. None of the nodes update their application
* buffers.
*
* See @ref conc_updating_data__summary_of_wait_fns for an overview to the @ref
* conc_updating_data "'WaitXUpdateAll'" methods and how to read the data from the
* nodes.
*
* @retval XN_STATUS_WAIT_DATA_TIMEOUT No new data available within 2 seconds.
*/
inline XnStatus WaitAndUpdateAll()
{
return xnWaitAndUpdateAll(m_pContext);
}
/**
* @brief Updates all generator nodes in the context to their latest available data,
* first waiting for any of the nodes to have new data available.
*
* @note Typical applications use this method. Consider using this method for your
* application.
*
* <b>Remarks</b>
*
* This method requests from OpenNI to cause all nodes with new data available in
* the context's Production Graph to update their application buffers with the new
* data, each node updating its own application buffer.
*
* Before OpenNI causes the data updates, it waits for any of the nodes to have
* notified that it has new data available. On receiving a 'new data available'
* notification, OpenNI then causes all nodes with new data available to update
* their application buffers with their new data. At this stage the generator nodes
* have "generated" new data. This method then stops waiting and returns a success
* status. The application can now read the newly generated data.
*
* A node that does not have new data available does not update its application
* buffer.
*
* An error situation is defined as: after a preset timeout, none of the nodes have
* yet notified OpenNI they have new data available. On error, the method stops
* waiting and returns an error status. None of the nodes update their application
* buffers.
*
* See @ref conc_updating_data__summary_of_wait_fns for an overview to the @ref
* conc_updating_data "'WaitXUpdateAll'" methods and how to read the data from the
* nodes.
*
* @retval XN_STATUS_WAIT_DATA_TIMEOUT No new data available within 2 seconds.
*/
inline XnStatus WaitAnyUpdateAll()
{
return xnWaitAnyUpdateAll(m_pContext);
}
/**
* @brief Updates all generator nodes in the context to their latest available data, first waiting for a specified node to have new data available.
*
* <b>Remarks</b>
*
* This method requests from OpenNI to cause all nodes in the context's Production
* Graph with new data available to update their application buffers with the new
* data, each node updating its own application buffer.
*
* Before OpenNI causes the data updates, it waits for a specified node to notify
* that it has new data available. On receiving the 'new data available' notification,
* OpenNI then causes all nodes with new data available to update their application
* buffers with their new data. At this stage the generator nodes have "generated"
* new data. This method then stops waiting and returns a success status. The application
* can now read the newly generated data.
*
* A node that does not have new data available does not update its application
* buffer.
*
* An error situation is defined as: after a preset timeout, none of the nodes have
* yet notified OpenNI they have has new data available. On error, the method stops
* waiting and returns an error status. None of the nodes update their application
* buffers.
*
* See @ref conc_updating_data__summary_of_wait_fns for an overview to the @ref
* conc_updating_data "'WaitXUpdateAll'" methods and how to read the data from the
* nodes.
*
* @retval XN_STATUS_WAIT_DATA_TIMEOUT No new data available within 2 seconds.
*/
inline XnStatus WaitOneUpdateAll(ProductionNode& node)
{
return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
}
/**
* @brief Immediately updates all generator nodes in the context to their latest available data, without waiting for notification that any node has new data available.
*
* <b>Remarks</b>
*
* This method requests from OpenNI to cause all nodes in the context's Production
* Graph with new data available to update their application buffers with the new
* data, each node updating its own application buffer.
*
* OpenNI causes all nodes with new data available to update their application buffers
* with their new data. At this stage the generator nodes have "generated" new data.
* This method returns a success status. The application can now read the newly
* generated data.
*
* A node that does not have new data available does not update its application
* buffer.
*
* See @ref conc_updating_data__summary_of_wait_fns for an overview to the @ref
* conc_updating_data "'WaitXUpdateAll'" methods and how to read the data from the
* nodes.
*/
inline XnStatus WaitNoneUpdateAll()
{
return xnWaitNoneUpdateAll(m_pContext);
}
/**
* @copybrief xnAutoEnumerateOverSingleInput
* For full details and usage, see @ref xnAutoEnumerateOverSingleInput
*/
inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
{
return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
}
/**
* Replaces the underlying C object pointed to by this object.
*/
inline void SetHandle(XnContext* pContext)
{
if (m_pContext == pContext)
{
return;
}
if (m_pContext != NULL)
{
if (m_bUsingDeprecatedAPI && m_bAllocated)
{
// Backwards compatibility: call shutdown instead of release, to make old programs get the
// exact same behavior they used to have.
xnForceShutdown(m_pContext);
}
else
{
xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
xnContextRelease(m_pContext);
}
}
if (pContext != NULL)
{
XnStatus nRetVal = xnContextAddRef(pContext);
XN_ASSERT(nRetVal == XN_STATUS_OK);
XN_REFERENCE_VARIABLE(nRetVal);
nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
XN_ASSERT(nRetVal == XN_STATUS_OK);
}
m_pContext = pContext;
}
inline void TakeOwnership(XnContext* pContext)
{
SetHandle(pContext);
if (pContext != NULL)
{
xnContextRelease(pContext);
}
}
/** @cond */
inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
{
m_bUsingDeprecatedAPI = TRUE;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
#pragma warning (pop)
}
inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
{
m_bUsingDeprecatedAPI = TRUE;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
#pragma warning (pop)
}
inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
{
XnContext* pContext = NULL;
m_bUsingDeprecatedAPI = TRUE;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
#pragma warning (pop)
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(pContext);
m_bAllocated = TRUE;
return (XN_STATUS_OK);
}
inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
{
m_bUsingDeprecatedAPI = TRUE;
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
return xnContextOpenFileRecording(m_pContext, strFileName);
#pragma warning (pop)
}
inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
{
if (m_pContext != NULL)
{
#pragma warning (push)
#pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
xnShutdown(m_pContext);
#pragma warning (pop)
m_pContext = NULL;
}
}
XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
{
XnStatus nRetVal = XN_STATUS_OK;
XnNodeHandle hNode;
nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
XN_IS_STATUS_OK(nRetVal);
Tree.m_bOwnerOfNode = TRUE;
return (XN_STATUS_OK);
}
/** @endcond */
private:
typedef struct NodeCreationCookie
{
NodeCreationHandler pFunc;
void* pCookie;
XnCallbackHandle hUnderlyingCallback;
} NodeCreationCookie;
typedef struct NodeDestructionCookie
{
NodeDestructionHandler pFunc;
void* pCookie;
XnCallbackHandle hUnderlyingCallback;
} NodeDestructionCookie;
static void XN_CALLBACK_TYPE NodeCreationCallback(XnContext* pContext, XnNodeHandle hCreatedNode, void* pCookie)
{
NodeCreationCookie* pNodeCreationCookie = (NodeCreationCookie*)pCookie;
Context context(pContext);
ProductionNode createdNode(hCreatedNode);
pNodeCreationCookie->pFunc(context, createdNode, pNodeCreationCookie->pCookie);
}
static void XN_CALLBACK_TYPE NodeDestructionCallback(XnContext* pContext, const XnChar* strDestroyedNodeName, void* pCookie)
{
NodeDestructionCookie* pNodeCreationCookie = (NodeDestructionCookie*)pCookie;
Context context(pContext);
pNodeCreationCookie->pFunc(context, strDestroyedNodeName, pNodeCreationCookie->pCookie);
}
static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
{
Context* pThis = (Context*)pCookie;
pThis->m_pContext = NULL;
}
XnContext* m_pContext;
XnBool m_bUsingDeprecatedAPI;
XnBool m_bAllocated;
XnCallbackHandle m_hShuttingDownCallback;
};
/**
* @ingroup cppref_misc
* A utility class for resolution info
*/
class Resolution
{
public:
/**
* Creates a @ref Resolution object.
*
* @param [in] res Resolution
*/
inline Resolution(XnResolution res) : m_Res(res)
{
m_nXRes = xnResolutionGetXRes(res);
m_nYRes = xnResolutionGetYRes(res);
m_strName = xnResolutionGetName(res);
}
/**
* Creates a @ref Resolution object out of X and Y resolutions.
*
* @param [in] xRes X resolution
* @param [in] yRes Y resolution
*/
inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
{
m_Res = xnResolutionGetFromXYRes(xRes, yRes);
m_strName = xnResolutionGetName(m_Res);
}
/**
* Creates a @ref Resolution object out of its name
*
* @param [in] strName name of the resolution
*/
inline Resolution(const XnChar* strName)
{
m_Res = xnResolutionGetFromName(strName);
m_nXRes = xnResolutionGetXRes(m_Res);
m_nYRes = xnResolutionGetYRes(m_Res);
m_strName = xnResolutionGetName(m_Res);
}
/**
* Gets the resolution
*/
inline XnResolution GetResolution() const { return m_Res; }
/**
* Gets the X resolution
*/
inline XnUInt32 GetXResolution() const { return m_nXRes; }
/**
* Gets the Y resolution
*/
inline XnUInt32 GetYResolution() const { return m_nYRes; }
/**
* Gets the name of the resolution
*/
inline const XnChar* GetName() const { return m_strName; }
private:
XnResolution m_Res;
XnUInt32 m_nXRes;
XnUInt32 m_nYRes;
const XnChar* m_strName;
};
//---------------------------------------------------------------------------
// Functions Implementation
//---------------------------------------------------------------------------
inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
{
return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
}
inline void ProductionNode::GetContext(Context& context) const
{
context.TakeOwnership(xnGetRefContextFromNodeHandle(GetHandle()));
}
inline Context ProductionNode::GetContext() const
{
XnContext* pContext = xnGetRefContextFromNodeHandle(GetHandle());
Context result(pContext);
xnContextRelease(pContext);
return result;
}
inline NodeInfoList& NodeInfo::GetNeededNodes() const
{
if (m_pNeededNodes == NULL)
{
XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
m_pNeededNodes = XN_NEW(NodeInfoList, pList);
}
return *m_pNeededNodes;
}
inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
{
if (m_pNeededNodes != NULL)
{
XN_DELETE(m_pNeededNodes);
}
m_bOwnerOfNode = FALSE;
m_pInfo = pInfo;
m_pNeededNodes = NULL;
}
inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other) const
{
return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
}
inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
{
return xnFrameSyncWith(GetHandle(), other.GetHandle());
}
inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
{
return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
}
inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other) const
{
return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
}
inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
{
if (m_pInfo == NULL)
{
return XN_STATUS_INVALID_OPERATION;
}
XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
node.TakeOwnership(hNode);
if (m_bOwnerOfNode)
{
xnProductionNodeRelease(hNode);
}
return (XN_STATUS_OK);
}
//---------------------------------------------------------------------------
// Node creation functions
//---------------------------------------------------------------------------
inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
{
Context context;
other.GetContext(context);
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
{
Context context;
other.GetContext(context);
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
{
Context context;
other.GetContext(context);
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
//You're creating a scene!
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
{
Context context;
other.GetContext(context);
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
inline XnStatus ScriptNode::Run(EnumerationErrors* pErrors)
{
return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
}
inline XnStatus ScriptNode::Create(Context& context, const XnChar* strFormat)
{
XnNodeHandle hNode;
XnStatus nRetVal = xnCreateScriptNode(context.GetUnderlyingObject(), strFormat, &hNode);
XN_IS_STATUS_OK(nRetVal);
TakeOwnership(hNode);
return (XN_STATUS_OK);
}
//---------------------------------------------------------------------------
// Global Helper Functions
//---------------------------------------------------------------------------
inline void XN_API_DEPRECATED("Use xn::Version::Current() instead") GetVersion(XnVersion& Version)
{
xnGetVersion(&Version);
}
//---------------------------------------------------------------------------
// Internal Helper Classes and Functions
//---------------------------------------------------------------------------
class StateChangedCallbackTranslator
{
public:
StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
{
return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
}
void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
{
xnFunc(hNode, m_hCallback);
}
static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
StateChangedCallbackTranslator* pTrans;
XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
nRetVal = pTrans->Register(xnFunc, hNode);
if (nRetVal != XN_STATUS_OK)
{
XN_DELETE(pTrans);
return (nRetVal);
}
hCallback = pTrans;
return (XN_STATUS_OK);
}
static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
{
StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
pTrans->Unregister(xnFunc, hNode);
XN_DELETE(pTrans);
return XN_STATUS_OK;
}
private:
friend class GeneralIntCapability;
typedef struct StateChangeCookie
{
StateChangedHandler userHandler;
void* pUserCookie;
XnCallbackHandle hCallback;
} StateChangeCookie;
static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
{
StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
ProductionNode node(hNode);
pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
}
StateChangedHandler m_UserHandler;
void* m_pUserCookie;
XnCallbackHandle m_hCallback;
};
static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
}
static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
{
StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
}
inline XnStatus GeneralIntCapability::RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
XnStatus nRetVal = XN_STATUS_OK;
StateChangedCallbackTranslator* pTrans;
XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
if (nRetVal != XN_STATUS_OK)
{
XN_DELETE(pTrans);
return (nRetVal);
}
hCallback = pTrans;
return (XN_STATUS_OK);
}
inline void GeneralIntCapability::UnregisterFromValueChange(XnCallbackHandle hCallback)
{
StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
XN_DELETE(pTrans);
}
};
#endif // __XN_CPP_WRAPPER_H__
|