image_viewer.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef DEPTHGUIDE_IMAGE_VIEWER_H
  2. #define DEPTHGUIDE_IMAGE_VIEWER_H
  3. #include "core/object_manager.h"
  4. #include "render/render_utility.h"
  5. #include <boost/container/static_vector.hpp>
  6. #include <memory>
  7. enum image_viewer_mode {
  8. VIEW_COLOR_ONLY,
  9. VIEW_DEPTH_ONLY,
  10. VIEW_COLOR_DEPTH,
  11. VIEW_STEREO,
  12. VIEW_CUSTOM
  13. };
  14. class image_viewer {
  15. public:
  16. struct create_config {
  17. static constexpr auto max_custom_size = 2;
  18. image_viewer_mode mode = VIEW_COLOR_DEPTH;
  19. bool flip_y = false;
  20. smart_cuda_stream *stream = nullptr;
  21. union {
  22. struct {
  23. color_format fmt;
  24. obj_name_type name;
  25. } color;
  26. struct {
  27. obj_name_type name;
  28. } depth;
  29. struct {
  30. color_format c_fmt;
  31. obj_name_type c_name, d_name;
  32. } color_depth;
  33. struct {
  34. color_format c_fmt;
  35. obj_name_type left_name, right_name;
  36. } stereo;
  37. } extra = {};
  38. struct {
  39. struct item_type {
  40. using render_func_type = std::function<void()>;
  41. std::string name;
  42. render_func_type render_func;
  43. };
  44. using item_list_type =
  45. boost::container::static_vector<item_type, max_custom_size>;
  46. item_list_type item_list;
  47. } custom;
  48. };
  49. explicit image_viewer(create_config conf);
  50. ~image_viewer();
  51. void show();
  52. void render();
  53. private:
  54. struct impl;
  55. std::unique_ptr<impl> pimpl;
  56. };
  57. #endif //DEPTHGUIDE_IMAGE_VIEWER_H