UVCDevice.h 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // start streaming
  19. void startStreaming();
  20. // stop streaming
  21. void stopStreaming();
  22. // close
  23. void close();
  24. // get frame
  25. void getFrame();
  26. private:
  27. int index;
  28. uvc_device_t *dev;
  29. uvc_device_handle_t *devh;
  30. uvc_stream_ctrl_t ctrl;
  31. int width{3840};
  32. int height{2160};
  33. int fps{25};
  34. uvc_frame_format frame_format;
  35. uvc_frame_callback_t *cb;
  36. // store the frame data
  37. };