Guest User

Untitled

a guest
Feb 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <XnCppWrapper.h>
  2. using namespace xn;
  3. Context commonContext;
  4. NodeInfoList imageList, depthList;
  5.  
  6. XnStatus rc;
  7. rc = commonContext.Init();
  8. rc |= commonContext.EnumerateProductionTrees (XN_NODE_TYPE_IMAGE, NULL, imageList);
  9. rc |= commonContext.EnumerateProductionTrees (XN_NODE_TYPE_DEPTH, NULL, depthList);
  10.  
  11. NodeInfoList::Iterator iit = imageList.Begin(), dit = depthList.Begin();
  12.  
  13. // apre il Kinect #id
  14. int temp = id;
  15. while (temp--) {
  16. if (iit == imageList.End() || dit == depthList.End()) {
  17. std::cout << "Not enough devices!" << std::endl;
  18. return 1;
  19. }
  20. iit++; dit++;
  21. }
  22.  
  23. NodeInfo dn(*iit), in(*dit);
  24. rc |= commonContext.CreateProductionTree(dn);
  25. rc |= commonContext.CreateProductionTree(in);
  26.  
  27. ImageGenerator image;
  28. DepthGenerator depth
  29. rc |= dn.GetInstance(image);
  30.  
  31. rc |= in.GetInstance(depth);
  32.  
  33. XnMapOutputMode mode;
  34. mode.nFPS = 30;
  35. mode.nXRes = XRes = 640;
  36. mode.nYRes = YRes = 480;
  37. image.SetMapOutputMode(mode);
  38. depth.SetMapOutputMode(mode);
  39.  
  40. // allineamento depth -> RGB
  41. depth.GetAlternativeViewPointCap().SetViewPoint(image);
  42.  
  43.  
  44. // cattura
  45. while(true) {
  46. commonContext.WaitAndUpdateAll();
  47.  
  48. uint64_t timestamp = depth.GetTimestamp();
  49.  
  50. ushort* depth_buffer = (ushort*)depth.GetDepthMap();
  51.  
  52. uchar* image_buffer = (uchar*)image.GetImageMap();
  53. }
  54.  
  55. // chiusura
  56.  
  57. commonContext.Shutdown();
Add Comment
Please, Sign In to add comment