Skip to content

Commit aa8793a

Browse files
committed
adjustments
1 parent d5b7ff5 commit aa8793a

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

common/calibration-model.cpp

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <realsense_imgui.h>
1010

1111
#include "../src/ds/d400/d400-private.h"
12+
#include "../src/ds/d500/d500-private.h"
1213

1314

1415
using namespace rs2;
@@ -62,77 +63,77 @@ void calibration_model::draw_int( std::string name, uint16_t & x, const uint16_t
6263
ImGui::PopStyleColor();
6364
}
6465

65-
void calibration_model::draw_float4x4(std::string name, float3x3& feild,
66+
void calibration_model::draw_float4x4(std::string name, float3x3& field,
6667
const float3x3& original, bool& changed)
6768
{
6869
ImGui::SetCursorPosX(10);
6970
ImGui::Text("%s:", name.c_str()); ImGui::SameLine();
70-
ImGui::SetCursorPosX(200);
7171

7272
ImGui::PushItemWidth(120);
73+
7374
ImGui::SetCursorPosX(200);
74-
draw_float(name + "_XX", feild.x.x, original.x.x, changed);
75+
draw_float(name + "_XX", field.x.x, original.x.x, changed);
7576
ImGui::SameLine();
76-
draw_float(name + "_XY", feild.x.y, original.x.y, changed);
77+
draw_float(name + "_XY", field.x.y, original.x.y, changed);
7778
ImGui::SameLine();
78-
draw_float(name + "_XZ", feild.x.z, original.x.z, changed);
79+
draw_float(name + "_XZ", field.x.z, original.x.z, changed);
7980

8081
ImGui::SetCursorPosX(200);
81-
draw_float(name + "_YX", feild.y.x, original.y.x, changed);
82+
draw_float(name + "_YX", field.y.x, original.y.x, changed);
8283
ImGui::SameLine();
83-
draw_float(name + "_YY", feild.y.y, original.y.y, changed);
84+
draw_float(name + "_YY", field.y.y, original.y.y, changed);
8485
ImGui::SameLine();
85-
draw_float(name + "_YZ", feild.y.z, original.y.z, changed);
86+
draw_float(name + "_YZ", field.y.z, original.y.z, changed);
8687

8788
ImGui::SetCursorPosX(200);
88-
draw_float(name + "_ZX", feild.z.x, original.z.x, changed);
89+
draw_float(name + "_ZX", field.z.x, original.z.x, changed);
8990
ImGui::SameLine();
90-
draw_float(name + "_ZY", feild.z.y, original.z.y, changed);
91+
draw_float(name + "_ZY", field.z.y, original.z.y, changed);
9192
ImGui::SameLine();
92-
draw_float(name + "_ZZ", feild.z.z, original.z.z, changed);
93+
draw_float(name + "_ZZ", field.z.z, original.z.z, changed);
9394

9495
ImGui::PopItemWidth();
9596

9697
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
9798
}
9899

99-
void calibration_model::draw_intrinsics(std::string name, mini_intrinsics& feild,
100+
void calibration_model::draw_intrinsics(std::string name, mini_intrinsics& field,
100101
const mini_intrinsics& original, bool& changed)
101102
{
102103
ImGui::SetCursorPosX(10);
103104
ImGui::Text("%s:", name.c_str()); ImGui::SameLine();
104-
ImGui::SetCursorPosX(200);
105105

106106
ImGui::PushItemWidth(120);
107+
107108
ImGui::SetCursorPosX(200);
108109
ImGui::Text("%s:", "ppx"); ImGui::SameLine();
109110
ImGui::SetCursorPosX(250);
110-
draw_float(name + "_ppx", feild.ppx, original.ppx, changed);
111+
draw_float(name + "_ppx", field.ppx, original.ppx, changed);
111112
ImGui::SameLine();
112113
ImGui::SetCursorPosX(400);
113114
ImGui::Text("%s:", "ppy"); ImGui::SameLine();
114115
ImGui::SetCursorPosX(450);
115-
draw_float(name + "_ppy", feild.ppy, original.ppy, changed);
116+
draw_float(name + "_ppy", field.ppy, original.ppy, changed);
116117

117118
ImGui::SetCursorPosX(200);
118119
ImGui::Text("%s:", "fx"); ImGui::SameLine();
119120
ImGui::SetCursorPosX(250);
120-
draw_float(name + "_fx", feild.fx, original.fx, changed);
121+
draw_float(name + "_fx", field.fx, original.fx, changed);
121122
ImGui::SameLine();
122123
ImGui::SetCursorPosX(400);
123124
ImGui::Text("%s:", "fy"); ImGui::SameLine();
124125
ImGui::SetCursorPosX(450);
125-
draw_float(name + "_fy", feild.fy, original.fy, changed);
126+
draw_float(name + "_fy", field.fy, original.fy, changed);
126127

127128
ImGui::SetCursorPosX(200);
128129
ImGui::Text("%s:", "width"); ImGui::SameLine();
129130
ImGui::SetCursorPosX(250);
130-
draw_int(name + "width", feild.image_width, original.image_width, changed);
131+
draw_int(name + "width", field.image_width, original.image_width, changed);
131132
ImGui::SameLine();
132133
ImGui::SetCursorPosX(400);
133134
ImGui::Text("%s:", "height"); ImGui::SameLine();
134135
ImGui::SetCursorPosX(450);
135-
draw_int(name + "height", feild.image_height, original.image_height, changed);
136+
draw_int(name + "height", field.image_height, original.image_height, changed);
136137

137138
ImGui::PopItemWidth();
138139

@@ -212,7 +213,7 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
212213
config_file cf(fn);
213214
table->baseline = cf.get("baseline");
214215

215-
auto load_float3x4 = [&](std::string name, librealsense::float3x3& m){
216+
auto load_float3x3 = [&](std::string name, librealsense::float3x3& m){
216217
m.x.x = cf.get(std::string( rsutils::string::from() << name << ".x.x").c_str());
217218
m.x.y = cf.get(std::string( rsutils::string::from() << name << ".x.y").c_str());
218219
m.x.z = cf.get(std::string( rsutils::string::from() << name << ".x.z").c_str());
@@ -226,10 +227,10 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
226227
m.z.z = cf.get(std::string( rsutils::string::from() << name << ".z.z").c_str());
227228
};
228229

229-
load_float3x4("intrinsic_left", table->intrinsic_left);
230-
load_float3x4("intrinsic_right", table->intrinsic_right);
231-
load_float3x4("world2left_rot", table->world2left_rot);
232-
load_float3x4("world2right_rot", table->world2right_rot);
230+
load_float3x3("intrinsic_left", table->intrinsic_left);
231+
load_float3x3("intrinsic_right", table->intrinsic_right);
232+
load_float3x3("world2left_rot", table->world2left_rot);
233+
load_float3x3("world2right_rot", table->world2right_rot);
233234

234235
for (int i = 0; i < librealsense::ds::max_ds_rect_resolutions; i++)
235236
{
@@ -264,7 +265,7 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
264265
config_file cf(fn);
265266
cf.set("baseline", table->baseline);
266267

267-
auto save_float3x4 = [&](std::string name, librealsense::float3x3& m){
268+
auto save_float3x3 = [&](std::string name, librealsense::float3x3& m){
268269
cf.set(std::string( rsutils::string::from() << name << ".x.x").c_str(), m.x.x);
269270
cf.set(std::string( rsutils::string::from() << name << ".x.y").c_str(), m.x.y);
270271
cf.set(std::string( rsutils::string::from() << name << ".x.z").c_str(), m.x.z);
@@ -278,10 +279,10 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
278279
cf.set(std::string( rsutils::string::from() << name << ".z.z").c_str(), m.z.z);
279280
};
280281

281-
save_float3x4("intrinsic_left", table->intrinsic_left);
282-
save_float3x4("intrinsic_right", table->intrinsic_right);
283-
save_float3x4("world2left_rot", table->world2left_rot);
284-
save_float3x4("world2right_rot", table->world2right_rot);
282+
save_float3x3("intrinsic_left", table->intrinsic_left);
283+
save_float3x3("intrinsic_right", table->intrinsic_right);
284+
save_float3x3("world2left_rot", table->world2left_rot);
285+
save_float3x3("world2right_rot", table->world2right_rot);
285286

286287
for (int i = 0; i < librealsense::ds::max_ds_rect_resolutions; i++)
287288
{
@@ -437,7 +438,7 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
437438
}
438439
if (ImGui::IsItemHovered())
439440
{
440-
RsImGui::CustomTooltip("%s", "Changing calibration will affect depth quality. Changes are persistent.\nThere is an option to get back to factory calibration, but it maybe worse than current calibration\nBefore writing to flash, we strongly recommend to make a file backup");
441+
RsImGui::CustomTooltip("%s", "Changing calibration will affect depth quality. Changes are persistent.\nThere is an option to get back to factory calibration, but it may be worse than current calibration\nBefore writing to flash, we strongly recommend to make a file backup");
441442
}
442443

443444
ImGui::SetCursorScreenPos({ (float)(x0 + w - 230), (float)(y0 + h - 30) });
@@ -494,7 +495,6 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
494495

495496
ImGui::PopStyleColor(2);
496497
}
497-
auto streams = dev.query_sensors()[0].get_active_streams();
498498
if (changed)
499499
{
500500
try
@@ -505,6 +505,7 @@ void calibration_model::d400_update(ux_window& window, std::string& error_messag
505505
{
506506
try
507507
{
508+
auto streams = dev.query_sensors()[0].get_active_streams();
508509
dev.query_sensors()[0].close();
509510
dev.query_sensors()[0].open(streams);
510511
dev.as<rs2::auto_calibrated_device>().set_calibration_table(_calibration);
@@ -572,7 +573,7 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
572573
config_file cf(fn);
573574
table->baseline = cf.get("baseline");
574575

575-
auto load_float3x4 = [&](std::string name, librealsense::float3x3& m){
576+
auto load_float3x3 = [&](std::string name, librealsense::float3x3& m){
576577
m.x.x = cf.get(std::string( rsutils::string::from() << name << ".x.x").c_str());
577578
m.x.y = cf.get(std::string( rsutils::string::from() << name << ".x.y").c_str());
578579
m.x.z = cf.get(std::string( rsutils::string::from() << name << ".x.z").c_str());
@@ -600,8 +601,8 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
600601
load_intrinsics( "left_coefficients_table", table->left_coefficients_table.base_instrinsics );
601602
load_intrinsics( "right_coefficients_table", table->right_coefficients_table.base_instrinsics );
602603
load_intrinsics( "rectified_intrinsics", table->rectified_intrinsics );
603-
load_float3x4( "left_rotation_matrix", table->left_coefficients_table.rotation_matrix );
604-
load_float3x4( "right_rotation_matrix", table->right_coefficients_table.rotation_matrix );
604+
load_float3x3( "left_rotation_matrix", table->left_coefficients_table.rotation_matrix );
605+
load_float3x3( "right_rotation_matrix", table->right_coefficients_table.rotation_matrix );
605606

606607
}
607608

@@ -628,7 +629,7 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
628629
config_file cf(fn);
629630
cf.set("baseline", table->baseline);
630631

631-
auto save_float3x4 = [&](std::string name, librealsense::float3x3& m){
632+
auto save_float3x3 = [&](std::string name, librealsense::float3x3& m){
632633
cf.set(std::string( rsutils::string::from() << name << ".x.x").c_str(), m.x.x);
633634
cf.set(std::string( rsutils::string::from() << name << ".x.y").c_str(), m.x.y);
634635
cf.set(std::string( rsutils::string::from() << name << ".x.z").c_str(), m.x.z);
@@ -656,8 +657,8 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
656657
save_intrinsics( "left_coefficients_table", table->left_coefficients_table.base_instrinsics );
657658
save_intrinsics( "right_coefficients_table", table->right_coefficients_table.base_instrinsics );
658659
save_intrinsics( "rectified_intrinsics", table->rectified_intrinsics );
659-
save_float3x4( "left_rotation_matrix", table->left_coefficients_table.rotation_matrix );
660-
save_float3x4( "right_rotation_matrix", table->right_coefficients_table.rotation_matrix );
660+
save_float3x3( "left_rotation_matrix", table->left_coefficients_table.rotation_matrix );
661+
save_float3x3( "right_rotation_matrix", table->right_coefficients_table.rotation_matrix );
661662

662663
}
663664
}
@@ -758,7 +759,7 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
758759
}
759760
if (ImGui::IsItemHovered())
760761
{
761-
RsImGui::CustomTooltip("%s", "Changing calibration will affect depth quality. Changes are persistent.\nThere is an option to get back to factory calibration, but it maybe worse than current calibration\nBefore writing to flash, we strongly recommend to make a file backup");
762+
RsImGui::CustomTooltip("%s", "Changing calibration will affect depth quality. Changes are persistent.\nThere is an option to get back to factory calibration, but it may be worse than current calibration\nBefore writing to flash, we strongly recommend to make a file backup");
762763
}
763764

764765
ImGui::SetCursorScreenPos({ (float)(x0 + w - 230), (float)(y0 + h - 30) });
@@ -815,7 +816,6 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
815816

816817
ImGui::PopStyleColor(2);
817818
}
818-
auto streams = dev.query_sensors()[0].get_active_streams();
819819
if (changed)
820820
{
821821
try
@@ -826,6 +826,7 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
826826
{
827827
try
828828
{
829+
auto streams = dev.query_sensors()[0].get_active_streams();
829830
dev.query_sensors()[0].close();
830831
dev.query_sensors()[0].open(streams);
831832
dev.as<rs2::auto_calibrated_device>().set_calibration_table(_calibration);
@@ -844,4 +845,4 @@ void calibration_model::d500_update( ux_window & window, std::string & error_mes
844845
}
845846
ImGui::PopStyleColor(3);
846847
ImGui::PopStyleVar(2);
847-
}
848+
}

common/calibration-model.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "notifications.h"
77
#include <rsutils/number/float3.h>
88

9-
#include "../src/ds/d500/d500-private.h"
9+
namespace librealsense { namespace ds { struct mini_intrinsics; } }
1010

1111
namespace rs2
1212
{
@@ -27,8 +27,8 @@ namespace rs2
2727
void open() { to_open = true; }
2828

2929
private:
30-
void draw_float4x4(std::string name, float3x3 & feild, const float3x3& original, bool& changed);
31-
void draw_intrinsics( std::string name, mini_intrinsics & feild, const mini_intrinsics & original, bool & changed );
30+
void draw_float4x4(std::string name, float3x3 & field, const float3x3& original, bool& changed);
31+
void draw_intrinsics( std::string name, mini_intrinsics & field, const mini_intrinsics & original, bool & changed );
3232
void draw_float(std::string name, float& x, const float& orig, bool& changed);
3333
void draw_int( std::string name, uint16_t & x, const uint16_t & orig, bool & changed );
3434
void d400_update(ux_window& window, std::string& error_message);

0 commit comments

Comments
 (0)