Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1. // OrbbecTest.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. #include <astra\astra.hpp>
  7. #include <cstdio>
  8. #include <iostream>
  9.  
  10.  
  11. std::string jointNames[]
  12. {
  13.     "Head",
  14.     "ShoulderSpine",
  15.     "LeftShoulder",
  16.     "LeftElbow",
  17.     "LeftHand",
  18.     "RightShoulder",
  19.     "RightElbow",
  20.     "RightHand",
  21.     "MidSpine",
  22.     "BaseSpine",
  23.     "LeftHip",
  24.     "LeftKnee",
  25.     "LeftFoot",
  26.     "RightHip",
  27.     "RightKnee",
  28.     "RightFoot",
  29.     "LeftWrist",
  30.     "RightWrist",
  31.     "Neck"
  32. };
  33.  
  34.  
  35. int main(int argc, char** argv)
  36. {
  37.     astra::initialize();
  38.     std::cout << "Astra initialized." << std::endl;
  39.  
  40.     astra::StreamSet streamSet;
  41.     astra::StreamReader reader = streamSet.create_reader();
  42.     std::cout << "Created stream reader." << std::endl;
  43.  
  44.     reader.stream<astra::BodyStream>().start();
  45.     std::cout << "Started body stream reader." << std::endl;
  46.  
  47.     const int maxFramesToProcess = 500;
  48.     int count = 0;
  49.  
  50.     do {
  51.         std::cout << "Getting frame" << std::endl;
  52.         astra::Frame frame = reader.get_latest_frame();
  53.         std::cout << "Received frame." << std::endl;
  54.         const auto bodyFrame = frame.get<astra::BodyFrame>();
  55.  
  56.         const int frameIndex = bodyFrame.frame_index();
  57.         astra::BodyList bodies = bodyFrame.bodies();
  58.         std::cout << "Tracked " + bodies.size() << std::endl;
  59.  
  60.         for (int i = 0; i < bodies.size(); i++)
  61.         {
  62.            
  63.             const astra::Body *bodyArray = bodyFrame.bodies().data();
  64.             astra::Body currentBody = bodyArray[i];
  65.             astra::JointList jointList = currentBody.joints();
  66.             const astra::Joint *jr = jointList.data();
  67.             int numOfJoints = jointList.size();
  68.             for (int j = 0; j < numOfJoints; j++)
  69.             {
  70.                 astra_vector3f_t position = jr[j].world_position();
  71.                 std::cout << "Person " << i << std::endl
  72.                     << "\tJoint " << jointNames[(int)jr[j].type()]
  73.                     << ": X = " << position.x
  74.                     << "; Y = " << position.y
  75.                     << "; Z = " << position.z
  76.                     << std::endl;
  77.             }
  78.         }
  79.  
  80.         count++;
  81.     } while (count < maxFramesToProcess);
  82.  
  83.     std::cout << "Press any key to continue...";
  84.     std::cin.get();
  85.  
  86.     astra::terminate();
  87.  
  88.     std::cout << "hit enter to exit program" << std::endl;
  89.     std::cin.get();
  90.  
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement