UVCDevice.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../libuvc/libuvc.h"
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <sys/time.h>
  5. class UVCDevice
  6. {
  7. public:
  8. // Constructor
  9. UVCDevice() = default;
  10. // Destructor
  11. ~UVCDevice() = default;
  12. // init
  13. void init(int index,uvc_context_t *ctx, uvc_device_t *dev);
  14. // set stream parameters
  15. void setStreamParameters(int width, int height, int fps, uvc_frame_format frame_format);
  16. void setCallBack(uvc_frame_callback_t *cb);
  17. uvc_device_handle_t *getDevh() { return devh; }
  18. void setTotalIndex(int total_index) { this->total_index = total_index; }
  19. int getTotalIndex() { return total_index; }
  20. // start streaming
  21. void startStreaming();
  22. // stop streaming
  23. void stopStreaming();
  24. // close
  25. void close();
  26. // get frame
  27. void getFrame();
  28. private:
  29. int index;
  30. uvc_device_t *dev;
  31. uvc_device_handle_t *devh;
  32. uvc_stream_ctrl_t ctrl;
  33. int width{3840};
  34. int height{2160};
  35. int fps{25};
  36. uvc_frame_format frame_format;
  37. uvc_frame_callback_t *cb;
  38. int total_index{0};
  39. // store the frame data
  40. };