Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.48 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <astra/astra.hpp>
  3. #include <iostream>
  4. #include <cstring>
  5. #include <string>
  6.  
  7. using std::cout;
  8. using std::endl;
  9.  
  10. class sfLine : public sf::Drawable
  11. {
  12. public:
  13. sfLine(const sf::Vector2f& point1, const sf::Vector2f& point2, sf::Color color, float thickness)
  14. : color_(color)
  15. {
  16. const sf::Vector2f direction = point2 - point1;
  17. const sf::Vector2f unitDirection = direction / std::sqrt(direction.x*direction.x + direction.y*direction.y);
  18. const sf::Vector2f normal(-unitDirection.y, unitDirection.x);
  19.  
  20. const sf::Vector2f offset = (thickness / 2.f) * normal;
  21.  
  22. vertices_[0].position = point1 + offset;
  23. vertices_[1].position = point2 + offset;
  24. vertices_[2].position = point2 - offset;
  25. vertices_[3].position = point1 - offset;
  26.  
  27. for (int i = 0; i<4; ++i)
  28. vertices_[i].color = color;
  29. }
  30.  
  31. void draw(sf::RenderTarget &target, sf::RenderStates states) const
  32. {
  33. target.draw(vertices_, 4, sf::Quads, states);
  34. }
  35.  
  36. private:
  37. sf::Vertex vertices_[4];
  38. sf::Color color_;
  39. };
  40.  
  41. class BodyVisualizer : public astra::FrameListener
  42. {
  43. public:
  44. static sf::Color get_body_color(std::uint8_t bodyId)
  45. {
  46. if (bodyId == 0)
  47. {
  48. // Handle no body separately - transparent
  49. return sf::Color(0x00, 0x00, 0x00, 0x00);
  50. }
  51. // Case 0 below could mean bodyId == 25 or
  52. // above due to the "% 24".
  53. switch (bodyId % 24) {
  54. case 0:
  55. return sf::Color(0x00, 0x88, 0x00, 0xFF);
  56. case 1:
  57. return sf::Color(0x00, 0x00, 0xFF, 0xFF);
  58. case 2:
  59. return sf::Color(0x88, 0x00, 0x00, 0xFF);
  60. case 3:
  61. return sf::Color(0x00, 0xFF, 0x00, 0xFF);
  62. case 4:
  63. return sf::Color(0x00, 0x00, 0x88, 0xFF);
  64. case 5:
  65. return sf::Color(0xFF, 0x00, 0x00, 0xFF);
  66.  
  67. case 6:
  68. return sf::Color(0xFF, 0x88, 0x00, 0xFF);
  69. case 7:
  70. return sf::Color(0xFF, 0x00, 0xFF, 0xFF);
  71. case 8:
  72. return sf::Color(0x88, 0x00, 0xFF, 0xFF);
  73. case 9:
  74. return sf::Color(0x00, 0xFF, 0xFF, 0xFF);
  75. case 10:
  76. return sf::Color(0x00, 0xFF, 0x88, 0xFF);
  77. case 11:
  78. return sf::Color(0xFF, 0xFF, 0x00, 0xFF);
  79.  
  80. case 12:
  81. return sf::Color(0x00, 0x88, 0x88, 0xFF);
  82. case 13:
  83. return sf::Color(0x00, 0x88, 0xFF, 0xFF);
  84. case 14:
  85. return sf::Color(0x88, 0x88, 0x00, 0xFF);
  86. case 15:
  87. return sf::Color(0x88, 0xFF, 0x00, 0xFF);
  88. case 16:
  89. return sf::Color(0x88, 0x00, 0x88, 0xFF);
  90. case 17:
  91. return sf::Color(0xFF, 0x00, 0x88, 0xFF);
  92.  
  93. case 18:
  94. return sf::Color(0xFF, 0x88, 0x88, 0xFF);
  95. case 19:
  96. return sf::Color(0xFF, 0x88, 0xFF, 0xFF);
  97. case 20:
  98. return sf::Color(0x88, 0x88, 0xFF, 0xFF);
  99. case 21:
  100. return sf::Color(0x88, 0xFF, 0xFF, 0xFF);
  101. case 22:
  102. return sf::Color(0x88, 0xFF, 0x88, 0xFF);
  103. case 23:
  104. return sf::Color(0xFF, 0xFF, 0x88, 0xFF);
  105. default:
  106. return sf::Color(0xAA, 0xAA, 0xAA, 0xFF);
  107. }
  108. }
  109.  
  110. void init_depth_texture(int width, int height)
  111. {
  112. if (displayBuffer_ == nullptr || width != depthWidth_ || height != depthHeight_)
  113. {
  114. depthWidth_ = width;
  115. depthHeight_ = height;
  116. int byteLength = depthWidth_ * depthHeight_ * 4;
  117.  
  118. displayBuffer_ = BufferPtr(new uint8_t[byteLength]);
  119. std::memset(displayBuffer_.get(), 0, byteLength);
  120.  
  121. texture_.create(depthWidth_, depthHeight_);
  122. sprite_.setTexture(texture_, true);
  123. sprite_.setPosition(0, 0);
  124. }
  125. }
  126.  
  127. void init_overlay_texture(int width, int height)
  128. {
  129. if (overlayBuffer_ == nullptr || width != overlayWidth_ || height != overlayHeight_)
  130. {
  131. overlayWidth_ = width;
  132. overlayHeight_ = height;
  133. int byteLength = overlayWidth_ * overlayHeight_ * 4;
  134.  
  135. overlayBuffer_ = BufferPtr(new uint8_t[byteLength]);
  136. std::fill(&overlayBuffer_[0], &overlayBuffer_[0] + byteLength, 0);
  137.  
  138. overlayTexture_.create(overlayWidth_, overlayHeight_);
  139. overlaySprite_.setTexture(overlayTexture_, true);
  140. overlaySprite_.setPosition(0, 0);
  141. }
  142. }
  143.  
  144. void check_fps()
  145. {
  146. double fpsFactor = 0.02;
  147.  
  148. std::clock_t newTimepoint= std::clock();
  149. long double frameDuration = (newTimepoint - lastTimepoint_) / static_cast<long double>(CLOCKS_PER_SEC);
  150.  
  151. frameDuration_ = frameDuration * fpsFactor + frameDuration_ * (1 - fpsFactor);
  152. lastTimepoint_ = newTimepoint;
  153. double fps = 1.0 / frameDuration_;
  154.  
  155. printf("FPS: %3.1f (%3.4Lf ms)\n", fps, frameDuration_ * 1000);
  156. }
  157.  
  158. void processDepth(astra::Frame& frame)
  159. {
  160. const astra::DepthFrame depthFrame = frame.get<astra::DepthFrame>();
  161.  
  162. if (!depthFrame.is_valid()) { return; }
  163.  
  164. int width = depthFrame.width();
  165. int height = depthFrame.height();
  166.  
  167. init_depth_texture(width, height);
  168.  
  169. const int16_t* depthPtr = depthFrame.data();
  170. for(int y = 0; y < height; y++)
  171. {
  172. for(int x = 0; x < width; x++)
  173. {
  174. int index = (x + y * width);
  175. int index4 = index * 4;
  176.  
  177. int16_t depth = depthPtr[index];
  178. uint8_t value = depth % 255;
  179.  
  180. displayBuffer_[index4] = value;
  181. displayBuffer_[index4 + 1] = value;
  182. displayBuffer_[index4 + 2] = value;
  183. displayBuffer_[index4 + 3] = 255;
  184. }
  185. }
  186.  
  187. texture_.update(displayBuffer_.get());
  188. }
  189.  
  190. void processBodies(astra::Frame& frame)
  191. {
  192. astra::BodyFrame bodyFrame = frame.get<astra::BodyFrame>();
  193.  
  194. jointPositions_.clear();
  195. circles_.clear();
  196. circleShadows_.clear();
  197. boneLines_.clear();
  198. boneShadows_.clear();
  199.  
  200. if (!bodyFrame.is_valid() || bodyFrame.info().width() == 0 || bodyFrame.info().height() == 0)
  201. {
  202. clear_overlay();
  203. return;
  204. }
  205.  
  206. const float jointScale = bodyFrame.info().width() / 120.f;
  207.  
  208. const auto& bodies = bodyFrame.bodies();
  209.  
  210. for (auto& body : bodies)
  211. {
  212. printf("Processing frame #%d body %d left hand: %u\n",
  213. bodyFrame.frame_index(), body.id(), unsigned(body.hand_poses().left_hand()));
  214.  
  215.  
  216.  
  217.  
  218. for(auto& joint : body.joints())
  219. {
  220. jointPositions_.push_back(joint.depth_position());
  221.  
  222.  
  223.  
  224. }
  225.  
  226. update_body(body, jointScale);
  227. }
  228.  
  229. const auto& floor = bodyFrame.floor_info(); //floor
  230. if (floor.floor_detected())
  231. {
  232. const auto& p = floor.floor_plane();
  233. std::cout << "Floor plane: ["
  234. << p.a() << ", " << p.b() << ", " << p.c() << ", " << p.d()
  235. << "]" << std::endl;
  236.  
  237. }
  238.  
  239. const auto& bodyMask = bodyFrame.body_mask();
  240. const auto& floorMask = floor.floor_mask();
  241.  
  242. update_overlay(bodyMask, floorMask);
  243. }
  244.  
  245.  
  246.  
  247. void update_body(astra::Body body,
  248. const float jointScale)
  249. {
  250. const auto& joints = body.joints(); ////////////////////////
  251. //////////////////////////////////////////////
  252. for (const auto& joint : joints)
  253. {
  254. // jointType is one of joints which exists for each joint type
  255. astra::JointType jointType = joint.type();
  256. astra::JointStatus jointStatus = joint.status();
  257.  
  258. const auto& depthPos = joint.depth_position();
  259. const auto& worldPos = joint.world_position();
  260.  
  261. // orientation is a 3x3 rotation matrix where the column vectors also
  262. // represent the orthogonal basis vectors for the x, y, and z axes.
  263. const auto& orientation = joint.orientation();
  264.  
  265. //printf("Body orientation", orientation.x_axis());
  266.  
  267. const auto& xAxis = orientation.x_axis(); // same as orientation->m00, m10, m20
  268. const auto& yAxis = orientation.y_axis(); // same as orientation->m01, m11, m21
  269. const auto& zAxis = orientation.z_axis(); // same as orientation->m02, m12, m22
  270.  
  271. if ((int)jointType == 0) // Head
  272. {
  273. std::cout << "Positions X (LEFT RIGHT) are : " << (int)worldPos.x << endl; //CODING FOR XYZ
  274. std::cout << "Positions Y (HEIGHT) are : " << (int)worldPos.y << endl; //
  275. std::cout << "Positions Z (DISTANCE BTW HUMAN & CAM) are : " << (int)worldPos.z << endl; //
  276. system("CLS"); ////// clearing done here!
  277.  
  278. }
  279. }
  280.  
  281.  
  282. if (joints.empty())
  283. {
  284. return;
  285. }
  286.  
  287. for (const auto& joint : joints)
  288. {
  289. astra::JointType type = joint.type();
  290. const auto& pos = joint.depth_position();
  291.  
  292. if (joint.status() == astra::JointStatus::NotTracked)
  293. {
  294. continue;
  295. }
  296.  
  297. auto radius = jointRadius_ * jointScale; // pixels
  298. sf::Color circleShadowColor(0, 0, 0, 255);
  299.  
  300. auto color = sf::Color(0x00, 0xFF, 0x00, 0xFF);
  301.  
  302. if ((type == astra::JointType::LeftHand && astra::HandPose::Grip==body.hand_poses().left_hand()) ||
  303. (type == astra::JointType::RightHand && astra::HandPose::Grip==body.hand_poses().right_hand()))
  304. {
  305. radius *= 1.5f;
  306. circleShadowColor = sf::Color(255, 255, 255, 255);
  307. color = sf::Color(0x00, 0xAA, 0xFF, 0xFF);
  308. }
  309.  
  310.  
  311. const auto shadowRadius = radius + shadowRadius_ * jointScale;
  312. const auto radiusDelta = shadowRadius - radius;
  313.  
  314. sf::CircleShape circle(radius);
  315.  
  316. circle.setFillColor(sf::Color(color.r, color.g, color.b, 255));
  317. circle.setPosition(pos.x - radius, pos.y - radius);
  318. circles_.push_back(circle);
  319.  
  320. sf::CircleShape shadow(shadowRadius);
  321. shadow.setFillColor(circleShadowColor);
  322. shadow.setPosition(circle.getPosition() - sf::Vector2f(radiusDelta, radiusDelta));
  323. circleShadows_.push_back(shadow);
  324. }
  325.  
  326. update_bone(joints, jointScale, astra::JointType::Head, astra::JointType::Neck);
  327. update_bone(joints, jointScale, astra::JointType::Neck, astra::JointType::ShoulderSpine);
  328.  
  329. update_bone(joints, jointScale, astra::JointType::ShoulderSpine, astra::JointType::LeftShoulder);
  330. update_bone(joints, jointScale, astra::JointType::LeftShoulder, astra::JointType::LeftElbow);
  331. update_bone(joints, jointScale, astra::JointType::LeftElbow, astra::JointType::LeftWrist);
  332. update_bone(joints, jointScale, astra::JointType::LeftWrist, astra::JointType::LeftHand);
  333.  
  334. update_bone(joints, jointScale, astra::JointType::ShoulderSpine, astra::JointType::RightShoulder);
  335. update_bone(joints, jointScale, astra::JointType::RightShoulder, astra::JointType::RightElbow);
  336. update_bone(joints, jointScale, astra::JointType::RightElbow, astra::JointType::RightWrist);
  337. update_bone(joints, jointScale, astra::JointType::RightWrist, astra::JointType::RightHand);
  338.  
  339. update_bone(joints, jointScale, astra::JointType::ShoulderSpine, astra::JointType::MidSpine);
  340. update_bone(joints, jointScale, astra::JointType::MidSpine, astra::JointType::BaseSpine);
  341.  
  342. update_bone(joints, jointScale, astra::JointType::BaseSpine, astra::JointType::LeftHip);
  343. update_bone(joints, jointScale, astra::JointType::LeftHip, astra::JointType::LeftKnee);
  344. update_bone(joints, jointScale, astra::JointType::LeftKnee, astra::JointType::LeftFoot);
  345.  
  346. update_bone(joints, jointScale, astra::JointType::BaseSpine, astra::JointType::RightHip);
  347. update_bone(joints, jointScale, astra::JointType::RightHip, astra::JointType::RightKnee);
  348. update_bone(joints, jointScale, astra::JointType::RightKnee, astra::JointType::RightFoot);
  349. }
  350.  
  351. void update_bone(const astra::JointList& joints,
  352. const float jointScale,astra::JointType j1,
  353. astra::JointType j2)
  354. {
  355. const auto& joint1 = joints[int(j1)];
  356. const auto& joint2 = joints[int(j2)];
  357.  
  358. if (joint1.status() == astra::JointStatus::NotTracked ||
  359. joint2.status() == astra::JointStatus::NotTracked)
  360. {
  361. //don't render bones between untracked joints
  362. return;
  363.  
  364.  
  365. }
  366.  
  367. //actually depth position, not world position
  368. const auto& jp1 = joint1.depth_position();
  369. const auto& jp2 = joint2.depth_position();
  370.  
  371. auto p1 = sf::Vector2f(jp1.x, jp1.y);
  372. auto p2 = sf::Vector2f(jp2.x, jp2.y);
  373.  
  374. sf::Color color(255, 255, 255, 255);
  375. float thickness = lineThickness_ * jointScale;
  376. if (joint1.status() == astra::JointStatus::LowConfidence ||
  377. joint2.status() == astra::JointStatus::LowConfidence)
  378. {
  379. color = sf::Color(128, 128, 128, 255);
  380. thickness *= 0.5f;
  381. }
  382.  
  383. boneLines_.push_back(sfLine(p1,
  384. p2,
  385. color,
  386. thickness));
  387. const float shadowLineThickness = thickness + shadowRadius_ * jointScale * 2.f;
  388. boneShadows_.push_back(sfLine(p1,
  389. p2,
  390. sf::Color(0, 0, 0, 255),
  391. shadowLineThickness));
  392. }
  393.  
  394. void update_overlay(const astra::BodyMask& bodyMask,
  395. const astra::FloorMask& floorMask)
  396. {
  397. const auto* bodyData = bodyMask.data();
  398. const auto* floorData = floorMask.data();
  399. const int width = bodyMask.width();
  400. const int height = bodyMask.height();
  401.  
  402. init_overlay_texture(width, height);
  403.  
  404. const int length = width * height;
  405.  
  406. for (int i = 0; i < length; i++)
  407. {
  408. const auto bodyId = bodyData[i];
  409. const auto isFloor = floorData[i];
  410.  
  411. sf::Color color(0x0, 0x0, 0x0, 0x0);
  412.  
  413. if (bodyId != 0)
  414. {
  415. color = get_body_color(bodyId);
  416. }
  417. else if (isFloor != 0)
  418. {
  419. color = sf::Color(0x0, 0x0, 0xFF, 0x88);
  420. }
  421.  
  422. const int rgbaOffset = i * 4;
  423. overlayBuffer_[rgbaOffset] = color.r;
  424. overlayBuffer_[rgbaOffset + 1] = color.g;
  425. overlayBuffer_[rgbaOffset + 2] = color.b;
  426. overlayBuffer_[rgbaOffset + 3] = color.a;
  427. }
  428.  
  429. overlayTexture_.update(overlayBuffer_.get());
  430. }
  431.  
  432. void clear_overlay()
  433. {
  434. int byteLength = overlayWidth_ * overlayHeight_ * 4;
  435. std::fill(&overlayBuffer_[0], &overlayBuffer_[0] + byteLength, 0);
  436.  
  437. overlayTexture_.update(overlayBuffer_.get());
  438. }
  439.  
  440. virtual void on_frame_ready(astra::StreamReader& reader,
  441. astra::Frame& frame) override
  442. {
  443. processDepth(frame);
  444. processBodies(frame);
  445.  
  446. check_fps();
  447. }
  448.  
  449. void draw_bodies(sf::RenderWindow& window)
  450. {
  451. const float scaleX = window.getView().getSize().x / overlayWidth_;
  452. const float scaleY = window.getView().getSize().y / overlayHeight_;
  453.  
  454. sf::RenderStates states;
  455. sf::Transform transform;
  456. transform.scale(scaleX, scaleY);
  457. states.transform *= transform;
  458.  
  459. for (const auto& bone : boneShadows_)
  460. window.draw(bone, states);
  461.  
  462. for (const auto& c : circleShadows_)
  463. window.draw(c, states);
  464.  
  465. for (const auto& bone : boneLines_)
  466. window.draw(bone, states);
  467.  
  468. for (auto& c : circles_)
  469. window.draw(c, states);
  470.  
  471. }
  472.  
  473. void draw_to(sf::RenderWindow& window)
  474. {
  475. if (displayBuffer_ != nullptr)
  476. {
  477. const float scaleX = window.getView().getSize().x / depthWidth_;
  478. const float scaleY = window.getView().getSize().y / depthHeight_;
  479. sprite_.setScale(scaleX, scaleY);
  480.  
  481. window.draw(sprite_); // depth
  482. }
  483.  
  484. if (overlayBuffer_ != nullptr)
  485. {
  486. const float scaleX = window.getView().getSize().x / overlayWidth_;
  487. const float scaleY = window.getView().getSize().y / overlayHeight_;
  488. overlaySprite_.setScale(scaleX, scaleY);
  489. window.draw(overlaySprite_); //bodymask and floormask
  490. }
  491.  
  492. draw_bodies(window);
  493. }
  494.  
  495. private:
  496. long double frameDuration_{ 0 };
  497. std::clock_t lastTimepoint_ { 0 };
  498. sf::Texture texture_;
  499. sf::Sprite sprite_;
  500.  
  501. using BufferPtr = std::unique_ptr < uint8_t[] >;
  502. BufferPtr displayBuffer_{ nullptr };
  503.  
  504. std::vector<astra::Vector2f> jointPositions_;
  505.  
  506. int depthWidth_{0};
  507. int depthHeight_{0};
  508. int overlayWidth_{0};
  509. int overlayHeight_{0};
  510.  
  511. std::vector<sfLine> boneLines_;
  512. std::vector<sfLine> boneShadows_;
  513. std::vector<sf::CircleShape> circles_;
  514. std::vector<sf::CircleShape> circleShadows_;
  515.  
  516. float lineThickness_{ 0.5f }; // pixels
  517. float jointRadius_{ 1.0f }; // pixels
  518. float shadowRadius_{ 0.5f }; // pixels
  519.  
  520. BufferPtr overlayBuffer_{ nullptr };
  521. sf::Texture overlayTexture_;
  522. sf::Sprite overlaySprite_;
  523.  
  524. };
  525.  
  526. astra::DepthStream configure_depth(astra::StreamReader& reader)
  527. {
  528. auto depthStream = reader.stream<astra::DepthStream>();
  529.  
  530. //We don't have to set the mode to start the stream, but if you want to here is how:
  531. astra::ImageStreamMode depthMode;
  532.  
  533. depthMode.set_width(640);
  534. depthMode.set_height(480);
  535. depthMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_DEPTH_MM);
  536. depthMode.set_fps(30);
  537.  
  538. depthStream.set_mode(depthMode);
  539.  
  540. return depthStream;
  541. }
  542.  
  543. int main(int argc, char** argv)
  544. {
  545. astra::initialize();
  546.  
  547. const char* licenseString = "<INSERT LICENSE KEY HERE>";
  548. orbbec_body_tracking_set_license(licenseString);
  549.  
  550. sf::RenderWindow window(sf::VideoMode(1280, 960), "Simple Body Viewer");
  551.  
  552. #ifdef _WIN32
  553. auto fullscreenStyle = sf::Style::None;
  554. #else
  555. auto fullscreenStyle = sf::Style::Fullscreen;
  556. #endif
  557.  
  558. const sf::VideoMode fullScreenMode = sf::VideoMode::getFullscreenModes()[0];
  559. const sf::VideoMode windowedMode(1280, 960);
  560. bool isFullScreen = false;
  561.  
  562. astra::StreamSet sensor;
  563. astra::StreamReader reader = sensor.create_reader();
  564.  
  565. BodyVisualizer listener; // listener is an instance of BodyVisualizer class
  566.  
  567. auto depthStream = configure_depth(reader);
  568. depthStream.start();
  569.  
  570. auto bodyStream = reader.stream<astra::BodyStream>();
  571. bodyStream.start();
  572. reader.add_listener(listener);
  573.  
  574. astra::SkeletonProfile profile = bodyStream.get_skeleton_profile();
  575.  
  576. // HandPoses includes Joints and Segmentation
  577. astra::BodyTrackingFeatureFlags features = astra::BodyTrackingFeatureFlags::HandPoses;
  578.  
  579. while (window.isOpen())
  580. {
  581. astra_update();
  582. sf::Event event;
  583.  
  584. while (window.pollEvent(event))
  585. {
  586. switch (event.type)
  587. {
  588. case sf::Event::Closed:
  589. window.close();
  590. break;
  591. case sf::Event::KeyPressed:
  592. {
  593. if (event.key.code == sf::Keyboard::C && event.key.control)
  594. {
  595. window.close();
  596. }
  597. switch (event.key.code)
  598. {
  599. case sf::Keyboard::Escape:
  600. window.close();
  601. break;
  602. case sf::Keyboard::F:
  603. if (isFullScreen)
  604. {
  605. window.create(windowedMode, "Simple Body Viewer", sf::Style::Default);
  606. }
  607. else
  608. {
  609. window.create(fullScreenMode, "Simple Body Viewer", fullscreenStyle);
  610. }
  611. isFullScreen = !isFullScreen;
  612. break;
  613. case sf::Keyboard::R:
  614. depthStream.enable_registration(!depthStream.registration_enabled());
  615. break;
  616. case sf::Keyboard::M:
  617. depthStream.enable_mirroring(!depthStream.mirroring_enabled());
  618. break;
  619. case sf::Keyboard::P:
  620. if (profile == astra::SkeletonProfile::Full)
  621. {
  622. profile = astra::SkeletonProfile::Basic;
  623. printf("Skeleton Profile: basic\n");
  624. }
  625. else
  626. {
  627. profile = astra::SkeletonProfile::Full;
  628. printf("Skeleton Profile: full\n");
  629. }
  630. bodyStream.set_skeleton_profile(profile);
  631. break;
  632. case sf::Keyboard::T:
  633. if (features == astra::BodyTrackingFeatureFlags::Segmentation)
  634. {
  635. // Joints includes Segmentation
  636. features = astra::BodyTrackingFeatureFlags::Joints;
  637. printf("Default Body Features: Seg+Body\n");
  638. }
  639. else if (features == astra::BodyTrackingFeatureFlags::Joints)
  640. {
  641. // HandPoses includes Joints and Segmentation
  642. features = astra::BodyTrackingFeatureFlags::HandPoses;
  643.  
  644.  
  645.  
  646. printf("Default Body Features: Seg+Body+Hand\n");
  647. }
  648. else
  649. {
  650. // HandPoses includes Joints and Segmentation
  651. features = astra::BodyTrackingFeatureFlags::Segmentation;
  652. printf("Default Body Features: Seg\n");
  653. }
  654. bodyStream.set_default_body_features(features);
  655. break;
  656. default:
  657. break;
  658. }
  659. break;
  660. }
  661. default:
  662. break;
  663. }
  664. }
  665.  
  666. // clear the window with black color
  667. window.clear(sf::Color::Black);
  668.  
  669. listener.draw_to(window);
  670. window.display();
  671. }
  672.  
  673. astra::terminate();
  674.  
  675. return 0;
  676. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement