12 #define GLFW_INCLUDE_GLU 20 #include <unordered_map> 22 #include "../third-party/json.hpp" 70 return ImVec4(color.
x * t, color.
y * t, color.
z * t, color.
w * t);
79 return{ c.
x, c.
y, c.
z, a * c.
w };
107 _icon{ unicode_icon[0], unicode_icon[1], unicode_icon[2], unicode_icon[3] }
110 operator const char*()
const 120 return os << static_cast<const char*>(
i);
141 namespace calibration
172 static const char*
last_ip {
"viewer_model.last_ip" };
181 static const char*
width {
"window.width" };
182 static const char*
height {
"window.height" };
185 namespace performance
191 static const char*
show_fps {
"performance.show_fps" };
192 static const char*
vsync {
"performance.vsync" };
199 static const char*
mesh {
"ply.mesh" };
211 namespace textual_icons
276 std::vector<std::pair<T, std::string>> pairs(vec.size());
277 for (
size_t i = 0;
i < vec.size();
i++) pairs[
i] = std::make_pair(vec[
i], names[i]);
280 [](
const std::pair<T, std::string>&
lhs,
281 const std::pair<T, std::string>& rhs) {
282 return lhs.first < rhs.first;
285 for (
size_t i = 0; i < vec.size(); i++)
287 vec[
i] = pairs[
i].first;
288 names[
i] = pairs[
i].second;
296 if (
it == vec.end()) vec.push_back(value);
315 void update_read_only_status(
std::string& error_message);
318 bool draw_option(
bool update_read_only_options,
bool is_streaming,
324 bool* invalidate_flag =
nullptr;
325 bool supported =
false;
326 bool read_only =
false;
331 std::function<bool(option_model&, std::string&, notifications_model&)> custom_draw_method =
nullptr;
332 bool edit_mode =
false;
335 bool is_all_integers()
const;
336 bool is_enum()
const;
337 bool is_checkbox()
const;
346 std::lock_guard<std::mutex>
lock(_lookup_mutex);
353 std::lock_guard<std::mutex>
lock(_lookup_mutex);
354 for (
auto&&
kvp : _queues)
366 int selected_res_id = 0;
367 int selected_shared_fps_id = 0;
376 std::shared_ptr<rs2::processing_block> pb,
bool enable =
true);
387 std::lock_guard<std::mutex>
lock(_mutex);
388 auto shared_syncer = std::make_shared<rs2::asynchronous_syncer>();
391 _syncers.push_back({shared_syncer,q});
398 return shared_syncer;
404 std::lock_guard<std::mutex>
lock(_mutex);
405 _syncers.erase(std::remove_if(_syncers.begin(), _syncers.end(),
408 return pair.first.get() == s.get();
409 }), _syncers.end()) ;
415 std::lock_guard<std::mutex>
lock(_mutex);
417 std::vector<rs2::frameset>
result;
418 for(
auto&&
s = _syncers.begin();
s!=_syncers.end() && _active;
s++)
421 if(
s->second.try_wait_for_frame(&f,1))
432 _active.exchange(
false);
437 _active.exchange(
true);
450 using face = std::array<float3, 4>;
460 state_pressed = init_pressed;
461 tooltip[unpressed] = tooltip_default;
462 tooltip[pressed] = tooltip_pressed;
463 icon[unpressed] = icon_default;
464 icon[pressed] = icon_pressed;
480 bool state_pressed =
false;
494 void draw_trajectory(
bool is_trajectory_button_pressed);
502 const float len_x = 0.1f;
503 const float len_y = 0.03f;
504 const float len_z = 0.01f;
516 float3 v4{ -len_x / 2, len_y / 2, len_z / 2 };
517 float3 v5{ -len_x / 2, len_y / 2, -len_z / 2 };
518 float3 v6{ len_x / 2, len_y / 2, -len_z / 2 };
519 float3 v7{ -len_x / 2, -len_y / 2, -len_z / 2 };
520 float3 v8{ len_x / 2, -len_y / 2, -len_z / 2 };
529 { { 0.5f, 0.5f, 0.5f } },
530 { { 0.7f, 0.7f, 0.7f } },
531 { { 1.0f, 0.7f, 0.7f } },
532 { { 0.7f, 0.7f, 0.7f } },
533 { { 0.4f, 0.4f, 0.4f } },
534 { { 0.7f, 0.7f, 0.7f } }
537 colored_cube camera_box{ { { f1,
colors[0] },{ f2,colors[1] },{
f3,colors[2] },{
f4,colors[3] },{
f5,colors[4] },{ f6,colors[5] } } };
548 static void populate_options(std::map<int, option_model>& opt_container,
551 std::shared_ptr<options>
options,
552 bool* options_invalidated,
558 bool is_there_common_fps() ;
559 bool supports_on_chip_calib();
560 bool draw_stream_selection(
std::string& error_message);
561 bool is_selected_combination_supported();
562 std::vector<stream_profile> get_selected_profiles();
563 std::vector<stream_profile> get_supported_profiles();
564 void stop(std::shared_ptr<notifications_model> not_model);
565 void play(
const std::vector<stream_profile>&
profiles,
viewer_model& viewer, std::shared_ptr<rs2::asynchronous_syncer>);
568 void draw_options(
const std::vector<rs2_option>& drawing_order,
569 bool update_read_only_options,
std::string& error_message,
571 uint64_t num_supported_non_default_options()
const;
575 if(options_metadata.find(opt)!=options_metadata.end())
576 return options_metadata[opt].draw_option(update_read_only_options, streaming, error_message, model);
580 bool is_paused()
const;
584 bool can_enable_zero_order();
585 void verify_zero_order_conditions();
587 void update_ui(std::vector<stream_profile> profiles_vec);
588 void get_sorted_profiles(std::vector<stream_profile>& profiles);
590 template<
typename T,
typename V>
600 auto max_default = values.begin();
601 for (
auto it = values.begin();
it != values.end();
it++)
606 *index = (int)(
it - values.begin());
609 if (*max_default < *
it)
614 *index = (int)(max_default - values.begin());
620 std::shared_ptr<sensor>
s;
629 std::map<int, std::vector<std::string>>
formats;
640 bool show_single_fps_list =
false;
647 bool _options_invalidated =
false;
650 bool streaming =
false;
651 bool allow_change_resolution_while_streaming =
false;
652 bool allow_change_fps_while_streaming =
false;
653 rect normalized_zoom{0, 0, 1, 1};
655 bool auto_exposure_enabled =
false;
659 bool roi_checked =
false;
662 std::atomic<bool> _is_being_recorded{
false };
664 bool draw_streams_selector =
true;
665 bool draw_fps_selector =
true;
668 bool show_algo_roi =
false;
677 bool post_processing_enabled =
true;
681 const float SHORT_RANGE_MIN_DISTANCE = 0.05f;
682 const float SHORT_RANGE_MAX_DISTANCE = 4.0f;
694 std::shared_ptr<texture_buffer> upload_frame(
frame&&
f);
695 bool is_stream_visible();
698 rect get_normalized_zoom(
const rect& stream_rect,
const mouse_info& g,
bool is_middle_clicked,
float zoom_val);
700 bool is_stream_alive();
704 void show_stream_pose(
ImFont* font,
const rect& stream_rect,
const rs2_pose& pose_data,
710 bool draw_reflectivity(
int x,
int y,
rs2::depth_sensor ds,
const std::map<int, stream_model> &streams, std::stringstream &ss,
bool same_line =
false);
726 float roi_percentage = 0.4f;
728 bool capturing_roi =
false;
729 std::shared_ptr<subdevice_model>
dev;
731 float _min_timeout = 167.0f;
733 bool _mid_click =
false;
735 rect _normalized_zoom{0, 0, 1, 1};
736 int color_map_idx = 1;
741 bool show_metadata =
false;
744 int _prev_mouse_pos_x = 0;
745 int _prev_mouse_pos_y = 0;
768 void resume_record();
771 void check_for_bundled_fw_update(
const rs2::context&
ctx, std::shared_ptr<notifications_model> not_model);
775 void draw_controls(
float panel_width,
float panel_height,
780 std::vector<std::function<
void()>>& draw_later,
781 bool load_json_if_streaming =
false,
783 bool draw_device_outline =
true);
784 void handle_hardware_events(
const std::string& serialized_data);
785 void begin_update(std::vector<uint8_t>
data,
797 bool is_streaming()
const;
798 bool metadata_supported =
false;
799 bool get_curr_advanced_controls =
true;
802 bool is_recording =
false;
804 int playback_speed_index = 2;
805 bool _playback_repeat =
true;
806 bool _should_replay =
false;
807 bool show_device_info =
false;
808 bool _allow_remove =
true;
809 bool show_depth_only =
false;
810 bool show_stream_selection =
true;
811 std::vector<std::pair<std::string, std::string>>
infos;
818 bool show_trigger_camera_accuracy_health_popup =
false;
819 bool show_reset_camera_accuracy_health_popup =
false;
834 float draw_device_panel(
float panel_width,
839 float draw_preset_panel(
float panel_width,
843 bool update_read_only_options,
844 bool load_json_if_streaming,
846 bool prompt_toggle_advanced_mode(
bool enable_advanced_mode,
const std::string& message_text,
847 std::vector<std::string>& restarting_device_info,
852 void load_viewer_configurations(
const std::string& json_str);
854 void handle_online_sw_update(
855 std::shared_ptr < notifications_model > nm,
856 std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile );
858 bool handle_online_fw_update(
860 std::shared_ptr< notifications_model > nm,
861 std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile );
866 bool pause_required =
false;
883 depth_stream_active(
false),
884 resulting_queue_max_size(20),
885 resulting_queue(static_cast<unsigned int>(resulting_queue_max_size)),
887 render_thread_active(
false),
893 pc_gen = std::make_shared<processing_block_model>(
nullptr,
"Pointcloud Engine",
pc, [=](
rs2::frame f) {
return pc->calculate(
f); },
s);
909 return render_thread_active.load();
915 if (resulting_queue.poll_for_frame(&f))
927 while(resulting_queue.poll_for_frame(&
f));
936 std::shared_ptr<pointcloud>
get_pc()
const {
return pc; }
937 std::shared_ptr<processing_block_model>
get_pc_model()
const {
return pc_gen; }
950 std::shared_ptr<subdevice_model> get_frame_origin(
const rs2::frame&
f);
955 std::shared_ptr<pointcloud>
pc;
957 std::shared_ptr<processing_block_model>
pc_gen;
std::vector< std::shared_ptr< notification_model > > related_notifications
static const textual_icon lock
static const ImVec4 transparent
static const textual_icon video_camera
static const ImVec4 white
std::map< int, bool > stream_enabled
void store_ui_selection()
static const textual_icon floppy
std::shared_ptr< recorder > _recorder
static const textual_icon bar_chart
rs2_sensor_mode resolution_from_width_height(int width, int height)
GLboolean GLboolean GLboolean b
static const textual_icon connectdevelop
std::atomic< bool > _active
static const ImVec4 light_red
std::vector< rs2::frameset > try_wait_for_frames()
static const textual_icon circle
std::map< int, int > selected_fps_id
std::map< int, std::vector< rs2_format > > format_values
static const char * is_measuring
static const textual_icon unlock
rs2::disparity_transform disp_to_depth
std::vector< std::string > shared_fpses
bool motion_data_to_csv(const std::string &filename, rs2::frame frame)
GLuint const GLchar * name
static const ImVec4 almost_white_bg
static const ImVec4 header_window_bg
std::map< int, int > selected_format_id
bool pose_data_to_csv(const std::string &filename, rs2::frame frame)
std::shared_ptr< rs2::asynchronous_syncer > dev_syncer
static const char * position_y
std::shared_ptr< atomic_objects_in_frame > _detected_objects
std::shared_ptr< rs2::depth_huffman_decoder > depth_decoder
The header of the GLFW 3 API.
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
std::queue< event_information > _changes
static const textual_icon check_square_o
std::atomic< bool > depth_stream_active
std::atomic< bool > _pause
static const char * target_width_r
bool frame_metadata_to_csv(const std::string &filename, rs2::frame frame)
static const char * last_ip
static const ImVec4 greenish
option_model create_option_mode(rs2_option opt, std::shared_ptr< options > options, const std::string &opt_base_label, bool *options_invalidated, std::string &error_message)
static const ImVec4 title_color
void remove_syncer(std::shared_ptr< rs2::asynchronous_syncer > s)
static const textual_icon caret_down
static const textual_icon info_circle
bool status_dialog(const std::string &title, const std::string &process_topic_text, const std::string &process_status_text, bool enable_close, ux_window &window)
static const textual_icon question_mark
static const ImVec4 light_grey
static const char * recommend_calibration
constexpr const char * server_versions_db_url
a class to store JSON values
void draw_seek_bar(rs2::playback &playback, int *seek_pos, float2 &location, float width)
void draw_rect(const rect &r, int line_width)
static const ImVec4 light_blue
GLsizei const GLchar *const * path
std::vector< int > shared_fps_values
std::shared_ptr< subdevice_model > dev
ImVec4 operator*(const ImVec4 &color, float t)
static const textual_icon repeat
static const char * post_processing
std::function< void(frame_interface *)> on_frame
std::shared_ptr< updates_model > _updates
std::shared_ptr< texture_buffer > texture
static const char * saved_pos
rs2::frame_queue resulting_queue
static const textual_icon throphy
void imgui_easy_theming(ImFont *&font_14, ImFont *&font_18, ImFont *&monofont)
std::unique_ptr< reflectivity > _reflectivity
static const textual_icon braille
static const ImVec4 dark_window_background
void hyperlink(ux_window &window, const char *title, const char *link)
GLsizei const GLchar *const * string
static const char * log_filename
constexpr textual_icon(const char(&unicode_icon)[4])
static const textual_icon plus_circle
std::shared_ptr< gl::uploader > uploader
bool get_default_selection_index(const std::vector< T > &values, const T &def, int *index)
calibration_model _calib_model
static const char * hwlogger_xml
static const textual_icon stop
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
std::shared_ptr< processing_block_model > pc_gen
::realsense_legacy_msgs::pose_< std::allocator< void > > pose
std::ostream & operator<<(std::ostream &os, const textual_icon &i)
static const textual_icon shopping_cart
std::map< int, std::string > stream_display_names
void prepare_config_file()
GLboolean GLboolean GLboolean GLboolean a
std::atomic< bool > render_thread_active
std::shared_ptr< syncer_model > syncer
void open_issue(std::string body)
static const textual_icon usb_type
std::vector< std::string > restarting_device_info
bool is_rendering() const
std::shared_ptr< atomic_objects_in_frame > detected_objects
void restore_ui_selection()
void update(rs2::update_device fwu_dev, std::vector< uint8_t > fw_image)
std::vector< std::shared_ptr< processing_block_model > > const_effects
bool draw_combo_box(const std::string &id, const std::vector< std::string > &device_names, int &new_index)
static const textual_icon grid
static const char * metric_system
rs2::frameset get_points()
std::vector< float2 > boundary
static const float FEET_TO_METER
static const char * saved_size
static const textual_icon refresh
static const char * show_stream_details
static const ImVec4 orange
static const char * continue_with_current_fw
std::vector< tracked_point > trajectory
static const ImVec4 regular_blue
static const textual_icon download
std::shared_ptr< pointcloud > pc
~post_processing_filters()
temporal_event _stream_not_alive
static const textual_icon play
void record_trajectory(bool on)
static const textual_icon link
void push_back_if_not_exists(std::vector< T > &vec, T value)
std::vector< std::pair< std::string, std::string > > infos
static const textual_icon step_forward
static const ImVec4 scrollbar_bg
std::vector< std::string > get_device_info(const device &dev, bool include_location)
std::vector< rs2_option > supported_options
static const textual_icon see_less
rect get_original_stream_bounds() const
static const textual_icon upload
GLint GLsizei GLsizei height
static const textual_icon edit
static const char * sw_updates_url
std::map< int, std::vector< std::string > > fpses_per_stream
static const textual_icon square
std::shared_ptr< pointcloud > get_pc() const
std::set< std::string > advanced_mode_settings_file_names
std::chrono::high_resolution_clock::time_point last_frame
static const textual_icon mail
static const char * compression_mode
static const ImVec4 sensor_bg
void sort_together(std::vector< T > &vec, std::vector< std::string > &names)
bool save_frame_meta_data(const std::string &filename, rs2::frame frame)
static const char * output_open
void export_frame(const std::string &fname, std::unique_ptr< rs2::filter > exporter, notifications_model &ns, frame data, bool notify)
unsigned __int64 uint64_t
static const textual_icon check
GLfloat GLfloat GLfloat GLfloat v3
std::shared_ptr< options > endpoint
stream_profile original_profile
ImVec4 from_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a, bool consistent_color=false)
static const textual_icon minus
static const char * last_calib_notice
static const char * use_normals
std::shared_ptr< sensor > s
advanced_mode_control amc
static const textual_icon file_movie
static const ImVec4 sensor_header_light_blue
bool is_cah_model_enabled() const
bool yes_no_dialog(const std::string &title, const std::string &message_text, bool &approved, ux_window &window, const std::string &error_message, bool disabled, const std::string &disabled_reason)
std::vector< std::pair< std::shared_ptr< rs2::asynchronous_syncer >, rs2::frame_queue > > _syncers
static const ImVec4 device_info_color
static const char * target_height_r
void outline_rect(const rect &r)
bool draw_option(rs2_option opt, bool update_read_only_options, std::string &error_message, notifications_model &model)
post_processing_filters(viewer_model &viewer)
std::shared_ptr< processing_block_model > get_pc_model() const
static const ImVec4 button_color
#define RS2_DEFAULT_TIMEOUT
rs2::depth_huffman_decoder depth_decoder
std::unique_ptr< cah_model > _accuracy_health_model
static const ImVec4 dark_grey
void log_to_file(rs2_log_severity min_severity, const char *file_path=nullptr)
std::string selected_file_preset
void update_texture(frame f)
static const ImVec4 header_color
static const ImVec4 dark_red
std::unordered_map< int, frame_queue > _queues
std::vector< std::pair< int, int > > res_values
rect get_stream_bounds() const
rs2_stream
Streams are different types of data provided by RealSense devices.
static const textual_icon exit
static const textual_icon dotdotdot
static const textual_icon window_restore
std::array< std::pair< face, color >, 6 > colored_cube
static const ImVec4 black
std::chrono::duration< uint64_t, std::nano > nanoseconds
std::map< int, rect > streams_layout
static const textual_icon times
std::shared_ptr< processing_block_model > zero_order_artifact_fix
std::map< int, option_model > options_metadata
ImVec4 operator+(const ImVec4 &c, float v)
rs2_sensor_mode
For setting the camera_mode option.
void save_processing_block_to_config_file(const char *name, std::shared_ptr< rs2::processing_block > pb, bool enable)
std::string pretty_time(std::chrono::nanoseconds duration)
static const textual_icon toggle_off
std::shared_ptr< atomic_objects_in_frame > get_detected_objects() const
GLsizei const GLfloat * values
static const textual_icon toggle_on
std::map< int, bool > prev_stream_enabled
void log_to_console(rs2_log_severity min_severity)
GLdouble GLdouble GLint GLint GLdouble v1
std::pair< std::string, std::string > get_device_name(const device &dev)
std::array< char, 5 > _icon
3D vector in Euclidean coordinate space
ImVec4 blend(const ImVec4 &c, float a)
std::vector< std::shared_ptr< subdevice_model > > live_subdevices
static const char * is_fullscreen
std::vector< std::pair< std::string, std::string > > get_devices_names(const device_list &list)
GLdouble GLdouble GLdouble q
static const textual_icon window_maximize
static const textual_icon fix_up
static const char * settings_tab
subdevice_ui_selection ui
static const char * log_severity
static const char * search_term
static const textual_icon step_backward
static const char * continue_with_ui_not_aligned
std::vector< std::shared_ptr< processing_block_model > > post_processing
static const ImVec4 scrollbar_grab
static const char * enable_writing
GLuint GLsizei const GLchar * label
rs2::processing_block processing_block
static const textual_icon cube
const GLuint GLenum const void * binary
std::function< void(std::function< void()> load)> json_loading_func
static const char * maximized
static const ImVec4 yellowish
static const textual_icon camera
static const char * ground_truth_r
static const textual_icon bars
std::shared_ptr< std::thread > render_thread
region_of_interest algo_roi
static const textual_icon metadata
utilities::number::stabilized_value< float > _stabilized_reflectivity
bool save_frame_raw_data(const std::string &filename, rs2::frame frame)
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
static const char * position_x
std::vector< std::unique_ptr< device_model > > device_models_list
GLsizei GLsizei GLchar * source
std::shared_ptr< rs2::yuy_decoder > yuy2rgb
static const char * shading_mode
std::vector< std::shared_ptr< subdevice_model > > subdevices
bool _trajectory_tracking
std::map< int, std::vector< int > > fps_values_per_stream
utilities::time::periodic_timer _update_readonly_options_timer
static const char * encoding
static const ImVec4 redish
static const textual_icon square_o
std::map< int, rs2::frame_queue > frames_queue
static const char * sw_updates_official_server
std::array< float, 3 > color
static const char * is_3d_view
static const char * show_map_ruler
static const textual_icon pause
static const textual_icon exclamation_triangle
static const ImVec4 yellow
std::map< int, std::vector< std::string > > formats
static const textual_icon measure
std::vector< stream_profile > profiles
std::vector< std::string > resolutions
static const char * recommend_updates
static const textual_icon cubes
std::shared_ptr< rs2::asynchronous_syncer > create_syncer()
static const char * sdk_version
static const char * default_path
static const ImVec4 dark_sensor_bg
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
std::shared_ptr< sw_update::dev_updates_profile::update_profile > _updates_profile
rs2::frame last_tex_frame
subdevice_ui_selection last_valid_ui
static const char * file_save_mode
static const char * allow_rc_firmware
const size_t resulting_queue_max_size
std::shared_ptr< rs2::colorizer > depth_colorizer
std::array< float3, 4 > face
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.