PolycodeKinect.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 6000
  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. protected:
  36. uint16_t t_gamma[2048];
  37. int freenect_angle;
  38. freenect_video_format current_format;
  39. freenect_video_format requested_format;
  40. };
  41. class PolycodeKinect : EventHandler {
  42. public:
  43. PolycodeKinect(bool calculatePoints);
  44. ~PolycodeKinect();
  45. Texture *getRGBTexture();
  46. Texture *getCloseDepthTexture();
  47. void tiltUp();
  48. void tiltDown();
  49. void Level();
  50. void handleEvent(Event *event);
  51. Vector3 points[MAX_KINECT_POINTS];
  52. Color colors[MAX_KINECT_POINTS];
  53. protected:
  54. Timer *updateTimer;
  55. bool calculatePoints;
  56. bool calculateColors;
  57. uint8_t *rgbPtr;
  58. Texture *rgbTexture;
  59. Texture *closeDepthTexture;
  60. PolycodeRunner *runner;
  61. };