update depth precision setting

This commit is contained in:
Joe Dong
2024-04-15 09:59:56 +08:00
parent 39fbe99c7b
commit 9ad7b9f133
6 changed files with 44 additions and 1 deletions
+17 -1
View File
@@ -217,7 +217,7 @@ void OBCameraNode::setupDevices() {
sync_config.triggerOutEnable = trigger_out_enabled_;
device_->setMultiDeviceSyncConfig(sync_config);
}
if (info->pid() == GEMINI2_PID) {
if (device_->isPropertySupported(OB_PROP_DEPTH_PRECISION_LEVEL_INT, OB_PERMISSION_READ_WRITE)) {
auto default_precision_level = device_->getIntProperty(OB_PROP_DEPTH_PRECISION_LEVEL_INT);
if (default_precision_level != depth_precision_) {
device_->setIntProperty(OB_PROP_DEPTH_PRECISION_LEVEL_INT, depth_precision_);
@@ -226,6 +226,22 @@ void OBCameraNode::setupDevices() {
int32_t precisionLevel = device_->getIntProperty(OB_PROP_DEPTH_PRECISION_LEVEL_INT);
RCLCPP_INFO_STREAM(logger_, "Depth precision level:" << precisionLevel);
}
if (device_->isPropertySupported(OB_PROP_DEPTH_UNIT_FLEXIBLE_ADJUSTMENT_FLOAT,
OB_PERMISSION_READ_WRITE)) {
auto depth_unit_flexible_adjustment = depthPrecisionFromString(depth_precision_str_);
auto range = device_->getFloatPropertyRange(OB_PROP_DEPTH_UNIT_FLEXIBLE_ADJUSTMENT_FLOAT);
RCLCPP_INFO_STREAM(
logger_, "Depth unit flexible adjustment range: " << range.min << " - " << range.max);
if (depth_unit_flexible_adjustment < range.min ||
depth_unit_flexible_adjustment > range.max) {
RCLCPP_ERROR_STREAM(
logger_,
"depth unit flexible adjustment value is out of range, please check the value");
} else {
device_->setFloatProperty(OB_PROP_DEPTH_UNIT_FLEXIBLE_ADJUSTMENT_FLOAT,
depth_unit_flexible_adjustment);
}
}
for (const auto &stream_index : IMAGE_STREAMS) {
if (enable_stream_[stream_index]) {
+18
View File
@@ -17,6 +17,7 @@
#include <regex>
#include "orbbec_camera/utils.h"
#include <sensor_msgs/point_cloud2_iterator.hpp>
#include "orbbec_camera/constants.h"
namespace orbbec_camera {
sensor_msgs::msg::CameraInfo convertToCameraInfo(OBCameraIntrinsic intrinsic,
OBCameraDistortion distortion, int width) {
@@ -380,6 +381,13 @@ OB_DEPTH_PRECISION_LEVEL depthPrecisionLevelFromString(
}
}
float depthPrecisionFromString(const std::string &depth_precision_level_str) {
// covert 0.8mm to 0.8
std::string depth_precision_level_str_num =
depth_precision_level_str.substr(0, depth_precision_level_str.size() - 2);
return std::stof(depth_precision_level_str_num);
}
OBMultiDeviceSyncMode OBSyncModeFromString(const std::string &mode) {
if (mode == "FREE_RUN") {
return OBMultiDeviceSyncMode::OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN;
@@ -673,4 +681,14 @@ OBHoleFillingMode holeFillingModeFromString(const std::string &hole_filling_mode
return OB_HOLE_FILL_NEAREST;
}
}
bool isGemini2R(int pid) {
if (pid == GEMINI2R_PID || pid == GEMINI2RL_PID) {
return true;
}
if (pid == GEMINI2R_PID2 || pid == GEMINI2RL_PID2) {
return true;
}
return false;
}
} // namespace orbbec_camera