mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-12 19:20:20 +08:00
fix: change enhanced depth confidence threshold type from float to int and update default value
This commit is contained in:
@@ -932,7 +932,7 @@ class OBCameraNode {
|
||||
std::mutex enhanced_depth_filter_mutex_;
|
||||
std::atomic_bool enable_enhanced_depth_{false};
|
||||
std::string enhanced_depth_model_path_;
|
||||
float enhanced_depth_confidence_threshold_ = -1.0f;
|
||||
int enhanced_depth_confidence_threshold_ = -1;
|
||||
rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr confidence_image_publisher_;
|
||||
cv::Mat confidence_image_;
|
||||
OBStreamType align_target_stream_ = OB_STREAM_COLOR;
|
||||
|
||||
@@ -233,7 +233,7 @@ def generate_launch_description():
|
||||
DeclareLaunchArgument('enable_false_positive_filter', default_value='false'),
|
||||
DeclareLaunchArgument('enable_enhanced_depth', default_value='false'),
|
||||
DeclareLaunchArgument('enhanced_depth_model_path', default_value=''),
|
||||
DeclareLaunchArgument('enhanced_depth_confidence_threshold', default_value='0.20'),
|
||||
DeclareLaunchArgument('enhanced_depth_confidence_threshold', default_value='51'),
|
||||
DeclareLaunchArgument('decimation_filter_scale', default_value='-1'),
|
||||
DeclareLaunchArgument('sequence_id_filter_id', default_value='-1'),
|
||||
DeclareLaunchArgument('threshold_filter_max', default_value='-1'),
|
||||
|
||||
@@ -230,7 +230,7 @@ def generate_launch_description():
|
||||
DeclareLaunchArgument('enable_false_positive_filter', default_value='false'),
|
||||
DeclareLaunchArgument('enable_enhanced_depth', default_value='false'),
|
||||
DeclareLaunchArgument('enhanced_depth_model_path', default_value=''),
|
||||
DeclareLaunchArgument('enhanced_depth_confidence_threshold', default_value='0.20'),
|
||||
DeclareLaunchArgument('enhanced_depth_confidence_threshold', default_value='51'),
|
||||
DeclareLaunchArgument('decimation_filter_scale', default_value='-1'),
|
||||
DeclareLaunchArgument('sequence_id_filter_id', default_value='-1'),
|
||||
DeclareLaunchArgument('threshold_filter_max', default_value='-1'),
|
||||
|
||||
@@ -4071,10 +4071,8 @@ void OBCameraNode::getParameters() {
|
||||
setAndGetNodeParameter<bool>(enable_enhanced_depth, "enable_enhanced_depth", false);
|
||||
enable_enhanced_depth_.store(enable_enhanced_depth);
|
||||
setAndGetNodeParameter<std::string>(enhanced_depth_model_path_, "enhanced_depth_model_path", "");
|
||||
double enhanced_depth_confidence_threshold = 0.20;
|
||||
setAndGetNodeParameter<double>(enhanced_depth_confidence_threshold,
|
||||
"enhanced_depth_confidence_threshold", 0.20);
|
||||
enhanced_depth_confidence_threshold_ = static_cast<float>(enhanced_depth_confidence_threshold);
|
||||
setAndGetNodeParameter<int>(enhanced_depth_confidence_threshold_,
|
||||
"enhanced_depth_confidence_threshold", 51);
|
||||
setAndGetNodeParameter<bool>(enable_point_cloud_, "enable_point_cloud", false);
|
||||
setAndGetNodeParameter<std::string>(ir_info_url_, "ir_info_url", "");
|
||||
setAndGetNodeParameter<std::string>(color_info_url_, "color_info_url", "");
|
||||
@@ -4686,17 +4684,17 @@ bool OBCameraNode::validateEnhancedDepthFilterConfig(std::string &message) const
|
||||
}
|
||||
|
||||
void OBCameraNode::applyEnhancedDepthConfidenceThreshold() {
|
||||
if (!enhanced_depth_filter_ || enhanced_depth_confidence_threshold_ < 0.0f) {
|
||||
if (!enhanced_depth_filter_ || enhanced_depth_confidence_threshold_ < 0) {
|
||||
return;
|
||||
}
|
||||
auto range = enhanced_depth_filter_->getConfidenceThresholdRange();
|
||||
if (enhanced_depth_confidence_threshold_ < range.min ||
|
||||
enhanced_depth_confidence_threshold_ > range.max) {
|
||||
const auto confidence_threshold = static_cast<uint32_t>(enhanced_depth_confidence_threshold_);
|
||||
if (confidence_threshold < range.min || confidence_threshold > range.max) {
|
||||
std::ostringstream ss;
|
||||
ss << "Enhanced depth confidence threshold is out of range " << range.min << " - " << range.max;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
enhanced_depth_filter_->setConfidenceThreshold(enhanced_depth_confidence_threshold_);
|
||||
enhanced_depth_filter_->setConfidenceThreshold(confidence_threshold);
|
||||
}
|
||||
|
||||
bool OBCameraNode::ensureEnhancedDepthFilter(std::string &message) {
|
||||
@@ -7233,10 +7231,21 @@ bool OBCameraNode::applyEnhancedDepthFilterConfig(
|
||||
}
|
||||
|
||||
bool has_confidence_threshold = false;
|
||||
float confidence_threshold = enhanced_depth_confidence_threshold_;
|
||||
int confidence_threshold = enhanced_depth_confidence_threshold_;
|
||||
auto parse_confidence_threshold = [&message](double value, int &threshold) {
|
||||
if (std::floor(value) != value || value < 0.0 || value > 255.0) {
|
||||
message =
|
||||
"EnhancedDepthFilter confidence_threshold expects an integer value in range 0 - 255";
|
||||
return false;
|
||||
}
|
||||
threshold = static_cast<int>(value);
|
||||
return true;
|
||||
};
|
||||
if (!positional_params.empty()) {
|
||||
if (!parse_confidence_threshold(positional_params[0], confidence_threshold)) {
|
||||
return false;
|
||||
}
|
||||
has_confidence_threshold = true;
|
||||
confidence_threshold = positional_params[0];
|
||||
}
|
||||
for (const auto ¶m : named_params) {
|
||||
if (param.name != "confidence_threshold") {
|
||||
@@ -7247,8 +7256,10 @@ bool OBCameraNode::applyEnhancedDepthFilterConfig(
|
||||
if (!parseFilterConfigDouble(param.value, parsed_value, message)) {
|
||||
return false;
|
||||
}
|
||||
if (!parse_confidence_threshold(parsed_value, confidence_threshold)) {
|
||||
return false;
|
||||
}
|
||||
has_confidence_threshold = true;
|
||||
confidence_threshold = static_cast<float>(parsed_value);
|
||||
}
|
||||
|
||||
std::string validate_message;
|
||||
@@ -7257,7 +7268,7 @@ bool OBCameraNode::applyEnhancedDepthFilterConfig(
|
||||
return false;
|
||||
}
|
||||
|
||||
const float previous_threshold = enhanced_depth_confidence_threshold_;
|
||||
const int previous_threshold = enhanced_depth_confidence_threshold_;
|
||||
if (has_confidence_threshold) {
|
||||
enhanced_depth_confidence_threshold_ = confidence_threshold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user