20 namespace depth_quality
27 samples(
std::
move(samples)), timestamp(timestamp), frame_number(frame_number) {}
45 _recording(false), _viewer_model(viewer_model)
50 std::lock_guard<std::mutex>
lock(_m);
51 _metric_data.push_back(data);
56 std::lock_guard<std::mutex>
lock(_m);
59 record_frames(frames);
62 _samples.push_back({ sample, _model_timer.get_elapsed_ms(), frames.get_frame_number() });
67 std::lock_guard<std::mutex>
lock(_m);
78 std::lock_guard<std::mutex>
lock(_m);
87 std::ofstream
out(filename);
90 out << adv.serialize_json();
110 void serialize_to_csv()
const;
124 class metric_plot :
public std::enable_shared_from_this<metric_plot>
135 std::shared_ptr<metric_plot>
set(
range r,
float from,
float to)
139 return shared_from_this();
144 for (
int i = 0;
i < MAX_RANGE;
i++)
146 if (ranges[
i].
x < val && val <= ranges[
i].
y)
154 const bool with_plane_fit)
155 : _idx(0), _first_idx(0),_vals(), _min(min), _max(max), _id(
"##" + name),
156 _label(name +
" = "),
_name(name),
157 _units(units), _description(description),
159 _requires_plane_fit(with_plane_fit),
160 _trending_up(
std::
chrono::milliseconds(700)),
161 _trending_down(
std::
chrono::milliseconds(700)),
162 _persistent_visibility(
std::
chrono::milliseconds(2000))
164 for (
int i = 0;
i < MAX_RANGE;
i++) ranges[
i] = { 0.f, 0.f };
170 std::lock_guard<std::mutex>
lock(_m);
172 _timestamps[_idx] = _model_timer.get_elapsed_ms();
173 _idx = (_idx + 1) % SIZE;
174 if (_first_idx== _idx)
175 _first_idx = (_first_idx + 1) % SIZE;
182 std::lock_guard<std::mutex>
lock(_m);
183 _persistent_visibility.add_value(is_visible);
188 std::lock_guard<std::mutex>
lock(_m);
189 if (enable != _enabled)
191 _persistent_visibility.reset();
201 bool has_trend(
bool positive);
204 const static size_t SIZE = 200;
233 std::lock_guard<std::mutex>
lock(_m);
234 return _latest_metrics.plane_corners;
239 std::lock_guard<std::mutex>
lock(_m);
240 _depth_intrinsic = intrinsic;
241 _depth_scale_units = scale_units;
247 std::lock_guard<std::mutex>
lock(_m);
249 _roi_percentage = roi_percent;
254 std::lock_guard<std::mutex>
lock(_m);
260 std::lock_guard<std::mutex>
lock(_m);
261 return _latest_metrics;
272 std::lock_guard<std::mutex>
lock(_m);
273 _ground_truth_mm = gt;
279 std::lock_guard<std::mutex>
lock(_m);
281 for (
auto&& plot : _plots)
285 bool val = plot->requires_plane_fit() ? found :
true;
293 std::lock_guard<std::mutex>
lock(_m);
295 _ground_truth_mm = 0;
299 std::lock_guard<std::mutex>
lock(_m);
300 return std::make_tuple(_ground_truth_mm, _plane_fit);
307 while (_frame_queue.poll_for_frame(&f));
312 _camera_info = camera_info;
316 return _recorder.is_recording();
320 _recorder.start_record(
this);
324 _recorder.stop_record(dev);
342 std::vector<std::shared_ptr<metric_plot>>
_plots;
345 mutable std::mutex
_m;
351 using metric = std::shared_ptr<metric_plot>;
362 void update_configuration();
368 void draw_guides(
ux_window& win,
const rect& viewer_rect,
bool distance_guide,
bool orientation_guide);
370 std::shared_ptr<metric_plot> make_metric(
393 bool _first_frame =
true;
395 bool _device_in_use =
false;
397 float _roi_percent = 0.4f;
398 int _roi_combo_index = 2;
413 bool _use_ground_truth =
false;
414 int _ground_truth = 0;
void start_record(metrics_model *metrics)
static const textual_icon lock
void visible(bool is_visible)
GLuint const GLchar * name
utilities::time::stopwatch _model_timer
void add_metric(const metric_definition &data)
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
bool requires_plane_fit() const
void update_roi_attributes(const region_of_interest &roi, float roi_percent)
std::array< float3, 4 > get_plane()
void begin_process_frame(rs2::frame f)
void disable_ground_truth()
metric_plot(const std::string &name, float min, float max, const std::string &units, const std::string &description, const bool with_plane_fit)
region_of_interest get_roi()
void stop_record(device_model *dev)
snapshot_metrics get_last_metrics()
std::array< float, SIZE > _vals
GLsizei const GLchar *const * string
GLsizei GLsizei GLfloat distance
std::thread _worker_thread
rs2_intrinsics _depth_intrinsic
void set_plane_fit(bool found)
metrics_recorder _recorder
const bool _requires_plane_fit
metrics_recorder(viewer_model &viewer_model)
temporal_event _persistent_visibility
void update_stream_attributes(const rs2_intrinsics &intrinsic, float scale_units, float baseline)
const char * file_dialog_open(file_dialog_mode flags, const char *filters, const char *default_path, const char *default_name)
temporal_event _trending_down
unsigned long long frame_number
void stop_record(device_model *dev)
std::shared_ptr< metric_plot > metric
std::array< double, SIZE > _timestamps
std::function< void(const std::vector< rs2::float3 > &points, const plane p, const rs2::region_of_interest roi, const float baseline_mm, const float focal_length_pixels, const int ground_thruth_mm, const bool plane_fit, const float plane_fit_to_ground_truth_mm, const float distance_mm, bool record, std::vector< single_metric_data > &samples)> callback_type
float _stereo_baseline_mm
viewer_model & _viewer_model
void set_ground_truth(int gt)
std::vector< single_metric_data > samples
void add_metric(std::shared_ptr< metric_plot > metric)
std::string _filename_base
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
void add_value(float val)
std::vector< sample > _samples
void add_sample(rs2::frameset &frames, std::vector< single_metric_data > sample)
snapshot_metrics _latest_metrics
sample(std::vector< single_metric_data > samples, double timestamp, unsigned long long frame_number)
std::vector< metric_definition > _metric_data
std::tuple< int, bool > get_inputs() const
range get_range(float val) const
void update_device_data(const std::string &camera_info)
temporal_event _trending_up
utilities::time::stopwatch _model_timer
std::vector< std::shared_ptr< metric_plot > > _plots
std::string to_string(T value)