Skip to content

Commit

Permalink
PR IntelRealSense#13376 from OhadMeir: Adding OCC and Tare calibratio…
Browse files Browse the repository at this point in the history
…n flows to D555
  • Loading branch information
OhadMeir authored Sep 29, 2024
2 parents debab09 + a207041 commit 9bba62e
Show file tree
Hide file tree
Showing 15 changed files with 976 additions and 504 deletions.
2 changes: 1 addition & 1 deletion common/d500-on-chip-calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace rs2
}

d500_autocalib_notification_model::d500_autocalib_notification_model(std::string name,
std::shared_ptr<d500_on_chip_calib_manager> manager, bool exp)
std::shared_ptr<process_manager> manager, bool exp)
: process_notification_model(manager)
{
enable_expand = false;
Expand Down
2 changes: 1 addition & 1 deletion common/d500-on-chip-calib.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace rs2
RS2_CALIB_STATE_ABORT_CALLED
};

d500_autocalib_notification_model(std::string name, std::shared_ptr<d500_on_chip_calib_manager> manager, bool expaned);
d500_autocalib_notification_model(std::string name, std::shared_ptr<process_manager> manager, bool expaned);

d500_on_chip_calib_manager& get_manager() { return *std::dynamic_pointer_cast<d500_on_chip_calib_manager>(update_manager); }
void draw_content(ux_window& win, int x, int y, float t, std::string& error_message) override;
Expand Down
197 changes: 125 additions & 72 deletions common/device-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3349,21 +3349,41 @@ namespace rs2
{
if (sub->supports_on_chip_calib() && !has_autocalib)
{
bool is_d555 = false;

if( dev.supports( RS2_CAMERA_INFO_PRODUCT_ID ) )
{
auto pid_str = std::string( dev.get_info( RS2_CAMERA_INFO_PRODUCT_ID ) );
if( pid_str == "0B56" || pid_str == "DDS" )
is_d555 = true;
}

if (ImGui::Selectable("On-Chip Calibration", false, avoid_selection_flag))
{
try
{
auto manager = std::make_shared<d500_on_chip_calib_manager>(viewer, sub, *this, dev);
auto n = std::make_shared<d500_autocalib_notification_model>("", manager, false);
viewer.not_model->add_notification(n);
std::shared_ptr< process_manager > manager;
std::shared_ptr< process_notification_model > n;
if( is_d555 )
{
// D555 OHM is same as D455, using D400 calibration algorithms.
manager = std::make_shared< on_chip_calib_manager >( viewer, sub, *this, dev );
n = std::make_shared< autocalib_notification_model >( "", manager, false );
}
else
{
manager = std::make_shared< d500_on_chip_calib_manager >( viewer, sub, *this, dev );
n = std::make_shared< d500_autocalib_notification_model >( "", manager, false );
}
viewer.not_model->add_notification( n );
n->forced = true;
n->update_state = d500_autocalib_notification_model::RS2_CALIB_STATE_INIT_CALIB;

for (auto&& n : related_notifications)
if (dynamic_cast<d500_autocalib_notification_model*>(n.get()))
n->dismiss(false);
for( auto && n : related_notifications )
if( dynamic_cast< d500_autocalib_notification_model * >( n.get() ) )
n->dismiss( false );

related_notifications.push_back(n);
related_notifications.push_back( n );
}
catch (const error& e)
{
Expand All @@ -3376,93 +3396,126 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
std::string tooltip = rsutils::string::from()
<< "On-Chip Calibration"
<< (streaming ? " (Disabled while streaming)" : "");
std::string tooltip;
if( is_d555 )
tooltip = "This will improve the depth noise.\n"
"Point at a scene that normally would have > 50 %% valid depth pixels,\n"
"then press calibrate."
"The health-check will be calculated.\n"
"If >0.25 we recommend applying the new calibration.\n"
"\"White wall\" mode should only be used when pointing at a flat white wall "
"with projector on";
else
tooltip = rsutils::string::from() << "On-Chip Calibration" << (streaming ? " (Disabled while streaming)" : "");
ImGui::SetTooltip("%s", tooltip.c_str());
}
if (ImGui::Selectable("Dry Run On-Chip Calibration", false, avoid_selection_flag))

if( !is_d555 )
{
try
if( ImGui::Selectable( "Dry Run On-Chip Calibration", false, avoid_selection_flag ) )
{
auto manager = std::make_shared<d500_on_chip_calib_manager>(viewer, sub, *this, dev);
auto n = std::make_shared<d500_autocalib_notification_model>("", manager, false);
viewer.not_model->add_notification(n);
n->forced = true;
n->update_state = d500_autocalib_notification_model::RS2_CALIB_STATE_INIT_DRY_RUN;
try
{
auto manager = std::make_shared<d500_on_chip_calib_manager>(viewer, sub, *this, dev);
auto n = std::make_shared<d500_autocalib_notification_model>("", manager, false);
viewer.not_model->add_notification(n);
n->forced = true;
n->update_state = d500_autocalib_notification_model::RS2_CALIB_STATE_INIT_DRY_RUN;

for (auto&& n : related_notifications)
if (dynamic_cast<autocalib_notification_model*>(n.get()))
n->dismiss(false);
for (auto&& n : related_notifications)
if (dynamic_cast<autocalib_notification_model*>(n.get()))
n->dismiss(false);

related_notifications.push_back(n);
}
catch (const error& e)
{
error_message = error_to_string(e);
related_notifications.push_back(n);
}
catch (const error& e)
{
error_message = error_to_string(e);
}
catch (const std::exception& e)
{
error_message = e.what();
}
}
catch (const std::exception& e)
if (ImGui::IsItemHovered())
{
error_message = e.what();
std::string tooltip = rsutils::string::from()
<< "Dry Run On-Chip Calibration"
<< ( streaming ? " (Disabled while streaming)" : "" );
ImGui::SetTooltip("%s", tooltip.c_str());
}
}
if (ImGui::IsItemHovered())
{
std::string tooltip = rsutils::string::from()
<< "Dry Run On-Chip Calibration"
<< (streaming ? " (Disabled while streaming)" : "");
ImGui::SetTooltip("%s", tooltip.c_str());
}

bool is_d555 = false;

if (dev.supports(RS2_CAMERA_INFO_PRODUCT_ID))
{
auto pid_str = std::string(dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID));
if (pid_str == "0B56" || pid_str == "DDS")
is_d555 = true;
}

if( is_d555 && ImGui::Selectable( "Focal Length Calibration" ) )
else
{
try
if( ImGui::Selectable( "Focal Length Calibration" ) )
{
std::shared_ptr< subdevice_model > sub_color;
for( auto && sub2 : subdevices )
try
{
if( sub2->s->is< rs2::color_sensor >() )
std::shared_ptr< subdevice_model > sub_color;
for( auto && sub2 : subdevices )
{
sub_color = sub2;
break;
if( sub2->s->is< rs2::color_sensor >() )
{
sub_color = sub2;
break;
}
}
}

auto manager = std::make_shared< on_chip_calib_manager >( viewer, sub, *this, dev, sub_color );
auto n = std::make_shared< autocalib_notification_model >( "", manager, false );
viewer.not_model->add_notification( n );
n->forced = true;
n->update_state = autocalib_notification_model::RS2_CALIB_STATE_FL_INPUT;
auto manager = std::make_shared< on_chip_calib_manager >( viewer, sub, *this, dev, sub_color );
auto n = std::make_shared< autocalib_notification_model >( "", manager, false );
viewer.not_model->add_notification( n );
n->forced = true;
n->update_state = autocalib_notification_model::RS2_CALIB_STATE_FL_INPUT;

for( auto && n : related_notifications )
if( dynamic_cast< autocalib_notification_model * >( n.get() ) )
n->dismiss( false );
for( auto && n : related_notifications )
if( dynamic_cast< autocalib_notification_model * >( n.get() ) )
n->dismiss( false );

related_notifications.push_back( n );
manager->start_fl_viewer();
}
catch( const error & e )
{
error_message = error_to_string( e );
related_notifications.push_back( n );
manager->start_fl_viewer();
}
catch( const error & e )
{
error_message = error_to_string( e );
}
catch( const std::exception & e )
{
error_message = e.what();
}
}
catch( const std::exception & e )
if( ImGui::IsItemHovered() )
ImGui::SetTooltip( "Focal length calibration is used to adjust camera focal length with specific target." );

if( ImGui::Selectable( "Tare Calibration" ) )
{
error_message = e.what();
try
{
auto manager = std::make_shared< on_chip_calib_manager >( viewer, sub, *this, dev );
auto n = std::make_shared< autocalib_notification_model >( "", manager, false );
viewer.not_model->add_notification( n );
n->forced = true;
n->update_state = autocalib_notification_model::RS2_CALIB_STATE_TARE_INPUT;

for( auto && n : related_notifications )
if( dynamic_cast< autocalib_notification_model * >( n.get() ) )
n->dismiss( false );

related_notifications.push_back( n );
}
catch( const error & e )
{
error_message = error_to_string( e );
}
catch( const std::exception & e )
{
error_message = e.what();
}
}
if( ImGui::IsItemHovered() )
ImGui::SetTooltip( "Tare calibration is used to adjust camera absolute distance to flat target.\n"
"User needs either to enter the known ground truth or use the get button\n"
"with specific target to get the ground truth." );
}
if( ImGui::IsItemHovered() )
ImGui::SetTooltip(
"Focal length calibration is used to adjust camera focal length with specific target." );

has_autocalib = true;
}
Expand Down
2 changes: 1 addition & 1 deletion common/on-chip-calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3130,7 +3130,7 @@ namespace rs2
}
}

autocalib_notification_model::autocalib_notification_model(std::string name, std::shared_ptr<on_chip_calib_manager> manager, bool exp)
autocalib_notification_model::autocalib_notification_model(std::string name, std::shared_ptr<process_manager> manager, bool exp)
: process_notification_model(manager)
{
enable_expand = false;
Expand Down
2 changes: 1 addition & 1 deletion common/on-chip-calib.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace rs2
RS2_CALIB_STATE_FL_PLUS_INPUT, // Collect input parameters for focal length plus calib
};

autocalib_notification_model(std::string name, std::shared_ptr<on_chip_calib_manager> manager, bool expaned);
autocalib_notification_model(std::string name, std::shared_ptr<process_manager> manager, bool expaned);

on_chip_calib_manager& get_manager() { return *std::dynamic_pointer_cast<on_chip_calib_manager>(update_manager); }

Expand Down
18 changes: 13 additions & 5 deletions src/dds/rs-dds-device-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,19 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
}
set_matcher_type( matcher );

if (supports_info(RS2_CAMERA_INFO_PRODUCT_LINE) &&
!strcmp(get_info(RS2_CAMERA_INFO_PRODUCT_LINE).c_str(), "D500"))
set_auto_calibration_capability(std::make_shared<d500_auto_calibrated>(
std::make_shared<d500_debug_protocol_calibration_engine>(this)));

if( supports_info( RS2_CAMERA_INFO_PRODUCT_LINE )
&& ! strcmp( get_info( RS2_CAMERA_INFO_PRODUCT_LINE ).c_str(), "D500" ) )
{
// Find depth sensor to pass into d500_auto_calibrated object
sensor_base * depth_sensor = nullptr;
for( auto & sensor : sensor_name_to_info )
if( sensor.second.type == RS2_STREAM_DEPTH )
depth_sensor = sensor.second.proxy.get();

set_auto_calibration_capability( std::make_shared< d500_auto_calibrated >(
std::make_shared< d500_debug_protocol_calibration_engine >( this ), this, depth_sensor ) );
}

_calibration_changed_subscription = _dds_dev->on_calibration_changed(
[this]( std::shared_ptr< const realdds::dds_stream > const & stream )
{
Expand Down
2 changes: 2 additions & 0 deletions src/ds/advanced_mode/advanced_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "json_loader.hpp"
#include "ds/d400/d400-color.h"
#include "ds/d500/d500-color.h"
#include "ds/d500/d500-private.h"

#include <src/ds/features/amplitude-factor-feature.h>
#include <src/ds/features/remove-ir-pattern-feature.h>
Expand Down Expand Up @@ -117,6 +118,7 @@ namespace librealsense
break;
case ds::RS455_PID:
case ds::RS457_PID:
case ds::D555_PID:
default_450_mid_low_res(p);
switch (res)
{
Expand Down
Loading

0 comments on commit 9bba62e

Please sign in to comment.