PolycodeKinect.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * PolycodeKinect.h
  3. * PolycodeKinectTest
  4. *
  5. * Created by Ivan Safrin on 12/2/10.
  6. * Copyright 2010 Local Projects. All rights reserved.
  7. *
  8. */
  9. #pragma once
  10. #include "Polycode.h"
  11. #include "libfreenect.h"
  12. using namespace Polycode;
  13. void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp);
  14. void rgb_cb(freenect_device *dev, void *rgb, uint32_t timestamp);
  15. #define MAX_KINECT_POINTS 8000
  16. class PolycodeRunner : public Threaded {
  17. public:
  18. PolycodeRunner();
  19. ~PolycodeRunner();
  20. void runThread();
  21. void updateThread() {}
  22. void rgbCallback(freenect_device *dev, void *rgb, uint32_t timestamp);
  23. void depthCallback(freenect_device *dev, void *v_depth, uint32_t timestamp);
  24. // static void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp);
  25. // static void rgb_cb(freenect_device *dev, void *rgb, uint32_t timestamp);
  26. int initKinect();
  27. void tiltUp();
  28. void tiltDown();
  29. void Level();
  30. CoreMutex *drawMutex;
  31. uint8_t *depth_mid, *depth_front;
  32. uint8_t *rgb_back, *rgb_mid, *rgb_front;
  33. freenect_context *f_ctx;
  34. freenect_device *f_dev;
  35. int depthMap[FREENECT_FRAME_PIX];
  36. protected:
  37. uint16_t t_gamma[2048];
  38. int freenect_angle;
  39. freenect_video_format current_format;
  40. freenect_video_format requested_format;
  41. };
  42. class PolycodeKinect : EventHandler {
  43. public:
  44. PolycodeKinect(bool calculatePoints, int depthStart, int depthEnd, int pixelSkip);
  45. ~PolycodeKinect();
  46. Texture *getRGBTexture();
  47. Texture *getCloseDepthTexture();
  48. void tiltUp();
  49. void tiltDown();
  50. void Level();
  51. void handleEvent(Event *event);
  52. Vector3 points[MAX_KINECT_POINTS];
  53. Color colors[MAX_KINECT_POINTS];
  54. protected:
  55. int depthStart;
  56. int depthEnd;
  57. int pixelSkip;
  58. Timer *updateTimer;
  59. bool calculatePoints;
  60. bool calculateColors;
  61. uint8_t *rgbPtr;
  62. Texture *rgbTexture;
  63. Texture *closeDepthTexture;
  64. PolycodeRunner *runner;
  65. };