camera_augment_helper_v2_impl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H
  2. #define DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H
  3. #include "module/camera_augment_helper_v2.h"
  4. #include "module/viewport_downloader.hpp"
  5. struct camera_augment_helper_v2::impl {
  6. std::string transform_var; // sophiar
  7. std::optional<glm::mat4> tracked_transform; // transform matrix from sophiar
  8. bool is_missing = false;
  9. bool ignore_missing = false;
  10. augment_manager_v2 *manager = nullptr;
  11. using sophiar_conn_type = create_config::sophiar_conn_type;
  12. sophiar_conn_type *sophiar_conn = nullptr;
  13. using io_context = boost::asio::io_context;
  14. io_context *ctx = nullptr;
  15. // for all
  16. float fov = 60.0f; // field of view
  17. float near = 10.0f;
  18. float far = 1000.0f; // clip range (mm)
  19. glm::mat4 transform; // standard camera transform
  20. struct fixed_info_type {
  21. glm::vec3 extra_offset = glm::vec3();
  22. glm::vec3 extra_rotation = glm::vec3();
  23. glm::mat4 extra_transform() const;
  24. } fixed_info;
  25. struct freedom_info_type {
  26. glm::vec3 eye = glm::vec3();
  27. glm::vec3 center = glm::vec3(0.0f, 0.0f, 100.0f); // focus
  28. glm::vec3 view_up = glm::vec3(0.0f, -1.0f, 0.0f);
  29. float angle_speed = 5.0f; // degree
  30. float linear_speed = 20.0f; // mm
  31. impl *pimpl = nullptr;
  32. void reset();
  33. glm::vec3 view_dir() const;
  34. float view_dis() const;
  35. void translate(glm::vec3 offset);
  36. void forward(float dis);
  37. void move_right(float dis);
  38. void move_up(float dis);
  39. void center_forward(float dis);
  40. void roll(float deg);
  41. void yaw(float deg);
  42. void pitch(float deg);
  43. glm::mat4 to_transform();
  44. } freedom_info;
  45. struct {
  46. impl *parent;
  47. glm::mat4 transform;
  48. } relative_info;
  49. enum {
  50. MODE_FIXED,
  51. MODE_RELATIVE,
  52. MODE_FREEDOM
  53. } mode;
  54. // for off-screen rendering
  55. smart_frame_buffer::create_config fbo_conf = {};
  56. smart_frame_buffer fbo;
  57. std::unique_ptr<viewport_downloader> img_downloader;
  58. // for interaction
  59. using conn_type = boost::signals2::connection;
  60. conn_type pre_render_conn;
  61. bool is_interactive = false;
  62. camera_info last_camera;
  63. cv::Size last_vp_size;
  64. bool enable_cursor_guide = false;
  65. std::optional<glm::vec3> cursor_pos; // in world coordinate
  66. mesh_ptr cursor_symbol;
  67. explicit impl(const create_config &conf);
  68. ~impl();
  69. void update_tracked_transform();
  70. void update_freedom();
  71. void update_fixed();
  72. void update_relative();
  73. void update_transform();
  74. void update_camera();
  75. void render();
  76. void render_image(output_config conf);
  77. void show_freedom();
  78. void show_fixed();
  79. void show();
  80. void update_cursor_coordinate();
  81. void cursor_guide_slot(const scene_ptr &info);
  82. void pre_render_slot(const scene_ptr &info);
  83. void set_interactive(bool flag);
  84. };
  85. #endif //DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H