Skip to content

Commit

Permalink
Humble low bandwidth stereo fix (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafadam authored Dec 3, 2024
1 parent 7589290 commit da0463f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion depthai_ros_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(CMAKE_BUILD_SHARED_LIBS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
add_compile_options(-Wall -Wextra -Wpedantic -Wno-deprecated-declarations -Wno-maybe-uninitialized)
endif()
# Default to C99
if(NOT CMAKE_C_STANDARD)
Expand Down
2 changes: 1 addition & 1 deletion depthai_ros_driver/src/dai_nodes/sensors/img_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void ImagePublisher::createImageConverter(std::shared_ptr<dai::Device> device) {
if(convConfig.alphaScalingEnabled) {
converter->setAlphaScaling(convConfig.alphaScaling);
}
if(convConfig.outputDisparity) {
if(!convConfig.outputDisparity) {
auto calHandler = device->readCalibration();
double baseline = calHandler.getBaselineDistance(pubConfig.leftSocket, pubConfig.rightSocket, false);
if(convConfig.reverseSocketOrder) {
Expand Down
5 changes: 3 additions & 2 deletions depthai_ros_driver/src/dai_nodes/sensors/stereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ void Stereo::setNames() {

void Stereo::setXinXout(std::shared_ptr<dai::Pipeline> pipeline) {
bool outputDisparity = ph->getParam<bool>("i_output_disparity");
bool lowBandwidth = ph->getParam<bool>("i_low_bandwidth");
std::function<void(dai::Node::Input)> stereoLinkChoice;
if(outputDisparity) {
if(outputDisparity || lowBandwidth) {
stereoLinkChoice = [&](auto input) { stereoCamNode->disparity.link(input); };
} else {
stereoLinkChoice = [&](auto input) { stereoCamNode->depth.link(input); };
Expand All @@ -92,7 +93,7 @@ void Stereo::setXinXout(std::shared_ptr<dai::Pipeline> pipeline) {
encConf.bitrate = ph->getParam<int>("i_low_bandwidth_bitrate");
encConf.frameFreq = ph->getParam<int>("i_low_bandwidth_frame_freq");
encConf.quality = ph->getParam<int>("i_low_bandwidth_quality");
encConf.enabled = ph->getParam<bool>("i_low_bandwidth");
encConf.enabled = lowBandwidth;

stereoPub = setupOutput(pipeline, stereoQName, stereoLinkChoice, ph->getParam<bool>("i_synced"), encConf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void StereoParamHandler::updateSocketsFromParams(dai::CameraBoardSocket& left, d

void StereoParamHandler::declareParams(std::shared_ptr<dai::node::StereoDepth> stereo) {
declareAndLogParam<int>("i_max_q_size", 30);
declareAndLogParam<bool>("i_low_bandwidth", false);
bool lowBandwidth = declareAndLogParam<bool>("i_low_bandwidth", false);
declareAndLogParam<int>("i_low_bandwidth_quality", 50);
declareAndLogParam<int>("i_low_bandwidth_profile", 4);
declareAndLogParam<int>("i_low_bandwidth_frame_freq", 30);
Expand Down Expand Up @@ -136,10 +136,13 @@ void StereoParamHandler::declareParams(std::shared_ptr<dai::node::StereoDepth> s
stereo->initialConfig.setLeftRightCheckThreshold(declareAndLogParam<int>("i_lrc_threshold", 10));
stereo->initialConfig.setMedianFilter(static_cast<dai::MedianFilter>(declareAndLogParam<int>("i_depth_filter_size", 5)));
stereo->initialConfig.setConfidenceThreshold(declareAndLogParam<int>("i_stereo_conf_threshold", 240));
if(declareAndLogParam<bool>("i_subpixel", true)) {
if(declareAndLogParam<bool>("i_subpixel", true) && !lowBandwidth) {
stereo->initialConfig.setSubpixel(true);
stereo->initialConfig.setSubpixelFractionalBits(declareAndLogParam<int>("i_subpixel_fractional_bits", 3));
}
else if(lowBandwidth) {
RCLCPP_INFO(getROSNode()->get_logger(), "Subpixel disabled due to low bandwidth mode");
}
stereo->setRectifyEdgeFillColor(declareAndLogParam<int>("i_rectify_edge_fill_color", 0));
if(declareAndLogParam<bool>("i_enable_alpha_scaling", false)) {
stereo->setAlphaScaling(declareAndLogParam<float>("i_alpha_scaling", 0.0));
Expand Down

0 comments on commit da0463f

Please sign in to comment.