11 #include <condition_variable> 15 #include "../tools/depth-quality/depth-metrics.h" 31 bool frame_arrived =
false;
40 if (
now -
stream.second.last_frame > std::chrono::milliseconds(200))
41 frame_arrived =
false;
43 else frame_arrived =
false;
45 std::this_thread::sleep_for(std::chrono::milliseconds(10));
55 bool frame_arrived =
false;
57 while (!frame_arrived)
65 if (
now -
stream.second.last_frame < std::chrono::milliseconds(100))
75 std::this_thread::sleep_for(std::chrono::milliseconds(10));
82 bool frame_arrived =
false;
90 if (
format.second[0] ==
"Y8")
104 if (
format.second[0] ==
"Z16")
113 _sub->stream_enabled.clear();
116 _sub->ui.selected_format_id.clear();
117 _sub->ui.selected_format_id[
_uid] = 0;
120 for (
int i = 0;
i <
_sub->shared_fps_values.size();
i++)
122 if (
_sub->shared_fps_values[
i] == fps)
123 _sub->ui.selected_shared_fps_id =
i;
127 for (
int i = 0;
i <
_sub->res_values.size();
i++)
130 if (
kvp.first == w &&
kvp.second == h)
131 _sub->ui.selected_res_id =
i;
135 if (!
_sub->is_selected_combination_supported())
137 for (
int i = 0;
i <
_sub->shared_fps_values.size();
i++)
140 _sub->ui.selected_shared_fps_id =
i;
141 if (
_sub->is_selected_combination_supported())
break;
145 if (!
_sub->is_selected_combination_supported())
147 for (
int i = 0;
i <
_sub->res_values.size();
i++)
150 if (
kvp.first == 640 &&
kvp.second == 480)
151 _sub->ui.selected_res_id =
i;
172 while (!frame_arrived && count++ < 200)
180 if (
now -
stream.second.last_frame < std::chrono::milliseconds(100))
181 frame_arrived =
true;
184 std::this_thread::sleep_for(std::chrono::milliseconds(10));
189 return frame_arrived;
202 std::this_thread::sleep_for(std::chrono::milliseconds(600));
210 throw std::runtime_error(
to_string() <<
"Failed to start streaming (" << w <<
", " << h <<
", " << fps <<
")!");
216 using namespace depth_quality;
222 (
int)(
f.get_width() * 0.55f), (
int)(
f.get_height() * 0.55f) };
223 std::vector<single_metric_data>
v;
225 std::vector<float> fill_rates;
226 std::vector<float> rmses;
231 const std::vector<rs2::float3>&
points,
234 const float baseline_mm,
235 const float focal_length_pixels,
236 const int ground_thruth_mm,
237 const bool plane_fit,
238 const float plane_fit_to_ground_truth_mm,
239 const float distance_mm,
241 std::vector<single_metric_data>&
samples)
243 static const float TO_MM = 1000.f;
244 static const float TO_PERCENT = 100.f;
247 auto fill_rate = points.size() / float((roi.max_x - roi.min_x)*(roi.max_y - roi.min_y)) * TO_PERCENT;
248 fill_rates.push_back(fill_rate);
250 if (!plane_fit)
return;
252 std::vector<rs2::float3> points_set =
points;
253 std::vector<float> distances;
256 distances.reserve(points.size());
261 for (
auto point : points_set)
267 distances.push_back(dist2plane * TO_MM);
272 size_t outliers = points_set.size() / 50;
273 points_set.erase(points_set.begin(), points_set.begin() + outliers);
274 points_set.resize(points_set.size() - outliers);
277 double plane_fit_err_sqr_sum = std::inner_product(distances.begin(), distances.end(), distances.begin(), 0.);
278 auto rms_error_val =
static_cast<float>(std::sqrt(plane_fit_err_sqr_sum / distances.size()));
279 auto rms_error_val_per = TO_PERCENT * (rms_error_val / distance_mm);
280 rmses.push_back(rms_error_val_per);
283 auto rms_std = 1000.f;
284 auto new_rms_std = rms_std;
291 rms_std = new_rms_std;
295 for (
int i = 0;
i < 31;
i++)
305 auto rmses_sum_sqr = std::inner_product(rmses.begin(), rmses.end(), rmses.begin(), 0.);
306 new_rms_std =
static_cast<float>(std::sqrt(rmses_sum_sqr / rmses.size()));
307 }
while ((new_rms_std < rms_std * 0.8f && new_rms_std > 10.
f) &&
count++ < 10);
309 std::sort(fill_rates.begin(), fill_rates.end());
312 float median_fill_rate, median_rms;
313 if (fill_rates.empty())
314 median_fill_rate = 0;
316 median_fill_rate = fill_rates[fill_rates.size() / 2];
320 median_rms = rmses[rmses.size() / 2];
324 return { median_fill_rate, median_rms };
331 if (!
dp)
throw std::runtime_error(
"Device does not support debug protocol!");
333 auto res =
dp.send_and_receive_raw_data(cmd);
335 if (
res.size() <
sizeof(
int32_t))
throw std::runtime_error(
to_string() <<
"Not enough data from " << name <<
"!");
337 if (return_code < 0)
throw std::runtime_error(
to_string() <<
"Firmware error (" << return_code <<
") from " << name <<
"!");
352 int occ_timeout_ms = 9000;
357 occ_timeout_ms = 12000;
363 std::this_thread::sleep_for(std::chrono::milliseconds(3000));
389 std::stringstream ss;
392 ss <<
"{\n \"calib type\":" << 1 <<
404 ss <<
"{\n \"calib type\":" << 0 <<
405 ",\n \"speed\":" <<
speed <<
410 ",\n \"accuracy\":" <<
accuracy <<
"}";
414 ss <<
"{\n \"calib type\":" << 2 <<
423 ",\n \"speed\":" <<
speed <<
428 ",\n \"accuracy\":" <<
accuracy <<
"}";
436 _new_calib = calib_dev.run_on_chip_calibration(json, &
_health, [&](
const float progress) {
_progress = int(progress);}, occ_timeout_ms);
440 int h_both =
static_cast<int>(
_health);
441 int h_1 = (h_both & 0x00000FFF);
442 int h_2 = (h_both & 0x00FFF000) >> 12;
443 int sign = (h_both & 0x0F000000) >> 24;
459 std::shared_ptr<rect_calculator> gt_calculator;
460 bool created =
false;
466 float rect_sides[4] = { 0 };
472 while (counter < limit)
482 gt_calculator = std::make_shared<rect_calculator>();
488 ret = gt_calculator->calculate(f.
get(), rect_sides);
502 fail(
"Please adjust the camera position \nand make sure the specific target is \nin the middle of the camera image!");
507 if (rect_sides[0] > 0)
508 gt[0] = target_fw / rect_sides[0];
510 if (rect_sides[1] > 0)
511 gt[1] = target_fw / rect_sides[1];
513 if (rect_sides[2] > 0)
514 gt[2] = target_fh / rect_sides[2];
516 if (rect_sides[3] > 0)
517 gt[3] = target_fh / rect_sides[3];
519 if (gt[0] <= 0.1f || gt[1] <= 0.1f || gt[2] <= 0.1f || gt[3] <= 0.1f)
520 fail(
"Bad target rectangle side sizes returned!");
523 for (
int i = 0;
i < 4; ++
i)
530 catch (
const std::runtime_error&
error)
536 fail(
"Getting ground truth failed!");
545 log(
to_string() <<
"Starting focal length calibration");
557 _old_calib = calib_dev.get_calibration_table();
562 _sub->post_processing_enabled =
false;
579 _ui = std::make_shared<subdevice_ui_selection>(
_sub->ui);
580 std::this_thread::sleep_for(std::chrono::milliseconds(600));
595 log(
to_string() <<
"Calibration failed with exception");
654 std::this_thread::sleep_for(std::chrono::milliseconds(200));
681 auto recommend_keep =
false;
684 float health_1 = get_manager().get_health_1();
685 float health_2 = get_manager().get_health_2();
686 bool recommend_keep_1 = fabs(health_1) < 0.25f;
687 bool recommend_keep_2 = fabs(health_2) < 0.15f;
688 recommend_keep = (recommend_keep_1 && recommend_keep_2);
691 recommend_keep = fabs(get_manager().get_health()) < 0.15
f;
693 recommend_keep = fabs(get_manager().get_health()) < 0.25
f;
710 bool intrinsic = get_manager().intrinsic_scan;
711 bool extrinsic = !intrinsic;
718 extrinsic = !intrinsic;
730 intrinsic = !extrinsic;
734 ImGui::SetTooltip(
"%s",
"Calibrate extrinsic parameters between left and right cameras");
737 get_manager().intrinsic_scan = intrinsic;
745 const auto bar_width =
width - 115;
749 ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
753 if (update_state != RS2_CALIB_STATE_COMPLETE)
755 if (update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
757 else if (update_state == RS2_CALIB_STATE_CALIB_IN_PROCESS ||
758 update_state == RS2_CALIB_STATE_CALIB_COMPLETE ||
759 update_state == RS2_CALIB_STATE_SELF_INPUT)
764 ImGui::Text(
"%s",
"On-Chip Focal Length Calibration");
770 else if (update_state == RS2_CALIB_STATE_TARE_INPUT || update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
772 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH || update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_IN_PROCESS || update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_COMPLETE)
773 ImGui::Text(
"%s",
"Get Tare Calibration Ground Truth");
774 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_FAILED)
775 ImGui::Text(
"%s",
"Get Tare Calibration Ground Truth Failed");
779 if (update_state == RS2_CALIB_STATE_TARE_INPUT || update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
781 else if (update_state == RS2_CALIB_STATE_FAILED)
788 if (update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
792 ImGui::Text(
"%s",
"Following devices support On-Chip Calibration:");
800 ImGui::Text(
"%s",
"Run quick calibration Health-Check? (~30 sec)");
802 else if (update_state == RS2_CALIB_STATE_CALIB_IN_PROCESS)
804 enable_dismiss =
false;
805 ImGui::Text(
"%s",
"Camera is being calibrated...\nKeep the camera stationary pointing at a wall");
807 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH)
813 ImGui::SetTooltip(
"%s",
"The width of the rectangle in millimeter inside the specific target");
816 const int MAX_SIZE = 256;
824 memcpy(buff, tw.c_str(), tw.size() + 1);
827 std::stringstream ss;
838 ImGui::SetTooltip(
"%s",
"The height of the rectangle in millimeter inside the specific target");
846 memcpy(buff, th.c_str(), th.size() + 1);
849 std::stringstream ss;
862 if (
ImGui::Button(back_button_name.c_str(), { float(60), 20.f }))
865 update_state = update_state_prev;
872 if (
ImGui::Button(button_name.c_str(), { float(bar_width - 70), 20.f }))
874 get_manager().restore_workspace([
this](std::function<
void()>
a) {
a(); });
875 get_manager().reset();
876 get_manager().retry_times = 0;
878 auto _this = shared_from_this();
879 auto invoke = [_this](std::function<void()>
action) {
882 get_manager().start(invoke);
883 update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_IN_PROCESS;
884 enable_dismiss =
false;
894 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_IN_PROCESS)
896 enable_dismiss =
false;
897 ImGui::Text(
"%s",
"Calculating ground truth is in process...\nKeep camera stationary pointing at the target");
899 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_COMPLETE)
902 update_state = update_state_prev;
906 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_FAILED)
918 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
920 get_manager().restore_workspace([
this](std::function<
void()>
a) {
a(); });
921 get_manager().reset();
922 auto _this = shared_from_this();
923 auto invoke = [_this](std::function<void()>
action) {
926 get_manager().start(invoke);
927 update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_IN_PROCESS;
928 enable_dismiss =
false;
938 else if (update_state == RS2_CALIB_STATE_TARE_INPUT || update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
945 if (update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
946 update_state = RS2_CALIB_STATE_TARE_INPUT;
948 update_state = RS2_CALIB_STATE_TARE_INPUT_ADVANCED;
953 if (update_state == RS2_CALIB_STATE_TARE_INPUT)
960 if (update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
966 ImGui::SetTooltip(
"%s",
"Number of frames to average, Min = 1, Max = 30, Default = 20");
997 ImGui::SetTooltip(
"%s",
"Subpixel accuracy level, Very high = 0 (0.025%), High = 1 (0.05%), Medium = 2 (0.1%), Low = 3 (0.2%), Default = Very high (0.025%)");
1004 std::vector<std::string> vals{
"Very High",
"High",
"Medium",
"Low" };
1005 std::vector<const char*> vals_cstr;
1006 for (
auto&&
s : vals) vals_cstr.push_back(
s.c_str());
1018 id =
to_string() <<
"Apply High-Accuracy Preset##apply_preset_" <<
index;
1022 if (update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
1036 ImGui::SetTooltip(
"%s",
"Distance in millimeter to the flat wall, between 60 and 10000.");
1042 const int MAX_SIZE = 256;
1043 char buff[MAX_SIZE];
1044 memcpy(buff, gt.c_str(), gt.size() + 1);
1049 std::stringstream ss;
1051 ss >> get_manager().ground_truth;
1063 if (update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
1068 if (
ImGui::Button(get_button_name.c_str(), { 42.0f, 20.f }))
1073 update_state_prev = update_state;
1074 update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH;
1083 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
1085 get_manager().restore_workspace([](std::function<
void()>
a) {
a(); });
1086 get_manager().reset();
1087 get_manager().retry_times = 0;
1089 auto _this = shared_from_this();
1090 auto invoke = [_this](std::function<void()>
action) {
1093 get_manager().start(invoke);
1094 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1095 enable_dismiss =
false;
1105 else if (update_state == RS2_CALIB_STATE_SELF_INPUT)
1114 std::vector<const char*> vals_cstr;
1117 std::vector<std::string> vals{
"Fast",
"Slow",
"White Wall" };
1118 for (
auto&&
s : vals) vals_cstr.push_back(
s.c_str());
1127 std::vector<std::string> vals{
"Very Fast",
"Fast",
"Medium",
"Slow",
"White Wall" };
1128 for (
auto&&
s : vals) vals_cstr.push_back(
s.c_str());
1131 ImGui::Combo(
id.c_str(), &get_manager().
speed, vals_cstr.data(), int(vals.size()));
1136 draw_intrinsic_extrinsic(x, y);
1144 bool restore = (get_manager().adjust_both_sides == 1);
1146 get_manager().adjust_both_sides = (restore ? 1 : 0);
1148 ImGui::SetTooltip(
"%s",
"check = adjust both sides, uncheck = adjust right side only");
1172 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
1174 get_manager().restore_workspace([
this](std::function<
void()>
a) {
a(); });
1175 get_manager().reset();
1176 get_manager().retry_times = 0;
1177 auto _this = shared_from_this();
1178 auto invoke = [_this](std::function<void()>
action) {_this->invoke(
action);};
1179 get_manager().start(invoke);
1180 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1181 enable_dismiss =
false;
1189 else if (update_state == RS2_CALIB_STATE_FAILED)
1196 get_manager().restore_workspace([](std::function<
void()>
a){
a(); });
1197 get_manager().reset();
1198 ++get_manager().retry_times;
1199 get_manager().toggle =
true;
1201 auto _this = shared_from_this();
1202 auto invoke = [_this](std::function<void()>
action) {_this->invoke(
action);};
1203 get_manager().start(invoke);
1204 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1205 enable_dismiss =
false;
1223 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
1225 get_manager().restore_workspace([](std::function<
void()>
a) {
a(); });
1226 get_manager().reset();
1227 auto _this = shared_from_this();
1228 auto invoke = [_this](std::function<void()>
action) {
1231 get_manager().start(invoke);
1232 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1233 enable_dismiss =
false;
1242 else if (update_state == RS2_CALIB_STATE_CALIB_COMPLETE)
1244 auto health = get_manager().get_health();
1246 auto recommend_keep = fabs(health) < 0.25f;
1248 recommend_keep = fabs(health) < 0.15f;
1250 float health_1 = -1.0f;
1251 float health_2 = -1.0f;
1252 bool recommend_keep_1 =
false;
1253 bool recommend_keep_2 =
false;
1256 health_1 = get_manager().get_health_1();
1257 health_2 = get_manager().get_health_2();
1258 recommend_keep_1 = fabs(health_1) < 0.25f;
1259 recommend_keep_2 = fabs(health_2) < 0.15f;
1260 recommend_keep = (recommend_keep_1 && recommend_keep_2);
1273 std::stringstream ss_1;
1274 ss_1 << std::fixed << std::setprecision(2) << health_1;
1275 auto health_str = ss_1.str();
1292 if (recommend_keep_1)
1297 else if (fabs(health_1) < 0.75
f)
1311 ImGui::SetTooltip(
"%s",
"OCC Health-Check captures how far camera calibration is from the optimal one\n" 1312 "[0, 0.25) - Good\n" 1313 "[0.25, 0.75) - Can be Improved\n" 1314 "[0.75, ) - Requires Calibration");
1320 std::stringstream ss_2;
1321 ss_2 << std::fixed << std::setprecision(2) << health_2;
1322 health_str = ss_2.str();
1339 if (recommend_keep_2)
1344 else if (fabs(health_2) < 0.75
f)
1358 ImGui::SetTooltip(
"%s",
"OCC-FL Health-Check captures how far camera calibration is from the optimal one\n" 1359 "[0, 0.15) - Good\n" 1360 "[0.15, 0.75) - Can be Improved\n" 1361 "[0.75, ) - Requires Calibration");
1368 std::stringstream ss; ss << std::fixed << std::setprecision(2) << health;
1369 auto health_str = ss.str();
1391 else if (fabs(health) < 0.75
f)
1407 ImGui::SetTooltip(
"%s",
"Calibration Health-Check captures how far camera calibration is from the optimal one\n" 1408 "[0, 0.25) - Good\n" 1409 "[0.25, 0.75) - Can be Improved\n" 1410 "[0.75, ) - Requires Calibration");
1414 ImGui::SetTooltip(
"%s",
"Calibration Health-Check captures how far camera calibration is from the optimal one\n" 1415 "[0, 0.15) - Good\n" 1416 "[0.15, 0.75) - Can be Improved\n" 1417 "[0.75, ) - Requires Calibration");
1422 auto old_fr = get_manager().get_metric(
false).first;
1423 auto new_fr = get_manager().get_metric(
true).first;
1425 auto old_rms = fabs(get_manager().
get_metric(
false).second);
1426 auto new_rms = fabs(get_manager().
get_metric(
true).second);
1428 auto fr_improvement = 100.f * ((new_fr - old_fr) / old_fr);
1429 auto rms_improvement = 100.f * ((old_rms - new_rms) / old_rms);
1449 std::string txt =
to_string() <<
" Fill-Rate: " << std::setprecision(1) << std::fixed << new_fr <<
"%%";
1451 txt =
to_string() <<
" Fill-Rate: " << std::setprecision(1) << std::fixed << old_fr <<
"%%\n";
1466 txt =
to_string() <<
" ( +" << std::fixed << std::setprecision(0) << fr_improvement <<
"%% )";
1471 if (rms_improvement > 1.
f)
1475 txt =
to_string() <<
" Noise Estimate: " << std::setprecision(2) << std::fixed << new_rms << new_units;
1479 txt =
to_string() <<
" Noise Estimate: " << std::setprecision(2) << std::fixed << old_rms << old_units;
1495 txt =
to_string() <<
" ( -" << std::setprecision(0) << std::fixed << rms_improvement <<
"%% )";
1504 ImGui::Text(
"%s",
"Please compare new vs old calibration\nand decide if to keep or discard the result...");
1511 use_new_calib =
true;
1512 get_manager().apply_calib(
true);
1518 use_new_calib =
false;
1519 get_manager().apply_calib(
false);
1531 if (!use_new_calib) button_name =
to_string() <<
"Keep Original" <<
"##original" <<
index;
1534 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
1538 get_manager().keep();
1539 update_state = RS2_CALIB_STATE_COMPLETE;
1541 enable_dismiss =
false;
1542 _progress_bar.last_progress_time = last_interacted =
system_clock::now() + milliseconds(500);
1549 get_manager().restore_workspace([](std::function<
void()>
a) {
a(); });
1573 ImGui::Text(
"%s",
"Camera Calibration Applied Successfully");
1580 if (update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
1587 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }) || update_manager->started())
1589 auto _this = shared_from_this();
1590 auto invoke = [_this](std::function<void()>
action) {
1594 if (!update_manager->started()) update_manager->start(invoke);
1596 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1597 enable_dismiss =
false;
1607 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_IN_PROCESS)
1609 if (update_manager->done())
1611 update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_COMPLETE;
1612 enable_dismiss =
true;
1615 if (update_manager->failed())
1617 update_manager->check_error(_error_message);
1618 update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_FAILED;
1619 enable_dismiss =
true;
1622 draw_progress_bar(win, bar_width);
1624 else if (update_state == RS2_CALIB_STATE_CALIB_IN_PROCESS)
1626 if (update_manager->done())
1628 update_state = RS2_CALIB_STATE_CALIB_COMPLETE;
1629 enable_dismiss =
true;
1630 get_manager().apply_calib(
true);
1631 use_new_calib =
true;
1636 if (update_manager->failed())
1638 update_manager->check_error(_error_message);
1639 update_state = RS2_CALIB_STATE_FAILED;
1640 enable_dismiss =
true;
1645 draw_progress_bar(win, bar_width);
1664 get_manager().update_last_used();
1666 if (!use_new_calib && get_manager().
done())
1667 get_manager().apply_calib(
false);
1669 get_manager().restore_workspace([](std::function<
void()>
a){
a(); });
1671 if (update_state != RS2_CALIB_STATE_TARE_INPUT)
1672 update_state = RS2_CALIB_STATE_INITIAL_PROMPT;
1673 get_manager().reset();
1680 if (update_manager->started() && update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
1681 update_state = RS2_CALIB_STATE_CALIB_IN_PROCESS;
1698 title =
"On-Chip Focal Length Calibration";
1700 title =
"On-Chip Calibration Extended";
1702 title =
"On-Chip Calibration";
1703 if (update_manager->failed()) title +=
" Failed";
1709 std::string progress_str =
to_string() <<
"Progress: " << update_manager->get_progress() <<
"%";
1714 draw_progress_bar(win, 490);
1717 auto s = update_manager->get_log();
1723 if (visible || update_manager->done() || update_manager->failed())
1727 if (update_manager->failed())
1728 update_state = RS2_CALIB_STATE_FAILED;
1756 if (update_state == RS2_CALIB_STATE_COMPLETE)
return 65;
1757 else if (update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
return 120;
1758 else if (update_state == RS2_CALIB_STATE_CALIB_COMPLETE)
1764 else if (update_state == RS2_CALIB_STATE_TARE_INPUT)
return 85;
1765 else if (update_state == RS2_CALIB_STATE_TARE_INPUT_ADVANCED)
return 210;
1766 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH)
return 110;
1767 else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_FAILED)
return 115;
1780 if (update_state == RS2_CALIB_STATE_COMPLETE)
1785 else if (update_state == RS2_CALIB_STATE_FAILED)
1798 std::shared_ptr<on_chip_calib_manager> manager,
bool exp)
1815 static int reset_counter = 0;
1816 if (reset_counter > _reset_limit)
1830 _rec_idx = (++_rec_idx) % _frame_num;
1833 if (_rec_num == _frame_num)
1836 calculate_rect_sides(rect_sides);
1848 for (
int i = 0;
i < 4; ++
i)
1849 rect_sides[
i] = _rec_sides[0][
i];
1851 for (
int j = 1;
j < _frame_num; ++
j)
1853 for (
int i = 0;
i < 4; ++
i)
1854 rect_sides[
i] += _rec_sides[
j][
i];
1857 for (
int i = 0;
i < 4; ++
i)
1858 rect_sides[
i] /= _frame_num;
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
static const ImVec4 transparent
GLenum GLuint GLenum GLsizei const GLchar * message
std::pair< float, float > get_depth_metrics(invoker invoke)
static const ImVec4 white
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F)
virtual void set_color_scheme(float t) const
GLboolean GLboolean GLboolean b
IMGUI_API bool RadioButton(const char *label, bool active)
int calculate(const rs2_frame *frame_ref, float rect_sides[4])
GLenum GLuint GLenum severity
snapshot_metrics analyze_depth_image(const rs2::video_frame &frame, float units, float baseline_mm, const rs2_intrinsics *intrin, rs2::region_of_interest roi, const int ground_truth_mm, bool plane_fit_present, std::vector< single_metric_data > &samples, bool record, callback_type callback)
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
void draw_dismiss(ux_window &win, int x, int y) override
GLuint const GLchar * name
ImVec4 saturate(const ImVec4 &a, float f)
std::shared_ptr< rs2::asynchronous_syncer > dev_syncer
void set_color_scheme(float t) const override
static const char * target_width_r
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
static const ImVec4 light_grey
std::vector< uint8_t > safe_send_command(const std::vector< uint8_t > &cmd, const std::string &name)
int keep_new_value_after_sucessful_scan
void set_calibration_table(const calibration_table &calibration)
static config_file & instance()
a class to store JSON values
static const ImVec4 light_blue
rs2::depth_frame fetch_depth_frame(invoker invoke)
stream_profile get_profile() const
std::map< int, stream_model > streams
std::function< void(frame_interface *)> on_frame
void apply_calib(bool use_new)
static const textual_icon throphy
std::vector< std::pair< float, float > > _metrics
GLdouble GLdouble GLdouble w
std::vector< uint8_t > _old_calib
GLsizei const GLchar *const * string
std::atomic< bool > synchronization_enable
GLfloat GLfloat GLfloat GLfloat h
void stop_viewer(invoker invoke)
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *display_format="%.0f", bool render_bg=false)
std::shared_ptr< notifications_model > not_model
std::shared_ptr< subdevice_ui_selection > _ui
GLboolean GLboolean GLboolean GLboolean a
T get_or_default(const char *key, T def) const
std::function< void(std::function< void()>)> invoker
std::vector< uint8_t > _new_calib
std::pair< float, float > get_metric(bool use_new)
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API void PopStyleVar(int count=1)
void try_start_viewer(int w, int h, int fps, invoker invoke)
static const ImVec4 regular_blue
void draw_expanded(ux_window &win, std::string &error_message) override
virtual void dismiss(bool snooze)
GLint GLsizei GLsizei height
autocalib_notification_model(std::string name, std::shared_ptr< on_chip_calib_manager > manager, bool expaned)
GLint GLint GLsizei GLint GLenum format
void draw_content(ux_window &win, int x, int y, float t, std::string &error_message) override
static const ImVec4 sensor_bg
static const textual_icon check
IMGUI_API void SetCursorPosX(float x)
static const char * last_calib_notice
static const ImVec4 sensor_header_light_blue
IMGUI_API void PushItemWidth(float item_width)
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
static const char * target_height_r
void begin_stream(std::shared_ptr< subdevice_model > d, rs2::stream_profile p)
void log(std::string line)
std::array< float3, 4 > roi_rect
rs2_notification_category category
std::shared_ptr< subdevice_model > _sub
IMGUI_API void EndPopup()
rs2_intrinsics get_intrinsics() const
static const ImVec4 dark_red
ImVec4 alpha(const ImVec4 &v, float a)
void rs2_extract_target_dimensions(const rs2_frame *frame, rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size, rs2_error **error)
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
IMGUI_API bool Combo(const char *label, int *current_item, const char **items, int items_count, int height_in_items=-1, bool show_arrow_down=true)
IMGUI_API void PushFont(ImFont *font)
post_processing_filters ppf
void write_calibration() const
IMGUI_API float GetTextLineHeightWithSpacing()
void draw_intrinsic_extrinsic(int x, int y)
int calc_height() override
void calculate_rect_sides(float rect_sides[4])
void set(const char *key, const char *value)
IMGUI_API void PopItemWidth()
IMGUI_API float GetTextLineHeight()
static const ImVec4 yellowish
static const char * ground_truth_r
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
IMGUI_API bool Checkbox(const char *label, bool *v)
static const char * get_button_name(int button)
bool start_viewer(int w, int h, int fps, invoker invoke)
IMGUI_API void SetCursorScreenPos(const ImVec2 &pos)
static const ImVec4 redish
std::map< int, rs2::frame_queue > frames_queue
void dismiss(bool snooze) override
void restore_workspace(invoker invoke)
IMGUI_API void CloseCurrentPopup()
ImFont * get_large_font() const
IMGUI_API void OpenPopup(const char *str_id)
virtual void draw_dismiss(ux_window &win, int x, int y)
void fail(std::string error)
IMGUI_API void SetCursorPosY(float y)
std::shared_ptr< syncer_model > syncer
IMGUI_API float GetCursorPosY()
IMGUI_API bool IsItemHovered()
bool allow_calib_keep() const
struct rs2_frame rs2_frame
GLdouble GLdouble GLint GLint const GLdouble * points
static const int _frame_num
IMGUI_API void PopStyleColor(int count=1)
std::string to_string(T value)
void process_flow(std::function< void()> cleanup, invoker invoke) override