Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions orbbec_camera/include/orbbec_camera/ob_camera_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ class OBCameraNode {
int depth_rotation_ = -1;
int left_ir_rotation_ = -1;
int right_ir_rotation_ = -1;
// Software-rotation fallback values (degrees), set in setupDevices() only when the
// device firmware does not support hardware rotate (e.g. DaBai DCW). -1 = disabled.
int color_rotation_sw_ = -1;
int depth_rotation_sw_ = -1;
int color_exposure_ = -1;
int color_gain_ = -1;
int color_white_balance_ = -1;
Expand Down
2 changes: 2 additions & 0 deletions orbbec_camera/launch/dabai_dcw.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def generate_launch_description():
DeclareLaunchArgument('color_format', default_value='MJPG'),
DeclareLaunchArgument('enable_color', default_value='true'),
DeclareLaunchArgument('flip_color', default_value='false'),
DeclareLaunchArgument('color_rotation', default_value='-1'),
DeclareLaunchArgument('color_qos', default_value='default'),
DeclareLaunchArgument('color_camera_info_qos', default_value='default'),
DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'),
Expand All @@ -44,6 +45,7 @@ def generate_launch_description():
DeclareLaunchArgument('depth_format', default_value='Y11'),
DeclareLaunchArgument('enable_depth', default_value='true'),
DeclareLaunchArgument('flip_depth', default_value='false'),
DeclareLaunchArgument('depth_rotation', default_value='-1'),
DeclareLaunchArgument('min_depth_limit', default_value='0'),
DeclareLaunchArgument('max_depth_limit', default_value='0'),
DeclareLaunchArgument('depth_qos', default_value='default'),
Expand Down
38 changes: 28 additions & 10 deletions orbbec_camera/src/ob_camera_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,25 @@ void OBCameraNode::setupDevices() {
roi.y1_bottom = depth_ae_roi_bottom_;
device_->setStructuredData(OB_STRUCT_DEPTH_AE_ROI, &roi, sizeof(AE_ROI));
}
if (color_rotation_ != -1 &&
device_->isPropertySupported(OB_PROP_COLOR_ROTATE_INT, OB_PERMISSION_READ_WRITE)) {
device_->setIntProperty(OB_PROP_COLOR_ROTATE_INT, color_rotation_);
RCLCPP_INFO_STREAM(
logger_, "set color rotation to " << device_->getIntProperty(OB_PROP_COLOR_ROTATE_INT));
if (color_rotation_ != -1) {
if (device_->isPropertySupported(OB_PROP_COLOR_ROTATE_INT, OB_PERMISSION_READ_WRITE)) {
device_->setIntProperty(OB_PROP_COLOR_ROTATE_INT, color_rotation_);
RCLCPP_INFO_STREAM(
logger_, "set color rotation to " << device_->getIntProperty(OB_PROP_COLOR_ROTATE_INT));
} else {
// Firmware has no hardware color rotate (e.g. DaBai DCW); fall back to software.
color_rotation_sw_ = color_rotation_;
}
}
if (depth_rotation_ != -1 &&
device_->isPropertySupported(OB_PROP_DEPTH_ROTATE_INT, OB_PERMISSION_READ_WRITE)) {
device_->setIntProperty(OB_PROP_DEPTH_ROTATE_INT, depth_rotation_);
RCLCPP_INFO_STREAM(
logger_, "set depth rotation to " << device_->getIntProperty(OB_PROP_DEPTH_ROTATE_INT));
if (depth_rotation_ != -1) {
if (device_->isPropertySupported(OB_PROP_DEPTH_ROTATE_INT, OB_PERMISSION_READ_WRITE)) {
device_->setIntProperty(OB_PROP_DEPTH_ROTATE_INT, depth_rotation_);
RCLCPP_INFO_STREAM(
logger_, "set depth rotation to " << device_->getIntProperty(OB_PROP_DEPTH_ROTATE_INT));
} else {
// Firmware has no hardware depth rotate (e.g. DaBai DCW); fall back to software.
depth_rotation_sw_ = depth_rotation_;
}
}
if (left_ir_rotation_ != -1 &&
device_->isPropertySupported(OB_PROP_IR_ROTATE_INT, OB_PERMISSION_READ_WRITE)) {
Expand Down Expand Up @@ -2190,6 +2198,16 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr<ob::Frame> &frame,
// flip image
cv::flip(image, image, 1);
}
// Software rotation fallback for devices whose firmware does not support hardware
// rotate (e.g. DaBai DCW). color_rotation_sw_/depth_rotation_sw_ are only set in
// setupDevices() when the hardware rotate property was unavailable. Only 180 is done
// in software since it preserves image dimensions (step / camera_info stay valid).
int rotation_deg = (stream_index == COLOR) ? color_rotation_sw_
: (stream_index == DEPTH) ? depth_rotation_sw_
: -1;
if (rotation_deg == 180) {
cv::rotate(image, image, cv::ROTATE_180);
Comment on lines +2208 to +2209

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep camera info consistent with software rotation

When the fallback is active, e.g. DaBai DCW with color_rotation/depth_rotation:=180, this rotates the published image after the CameraInfo was already published above, so the message still describes the unrotated pixel coordinates (cx/cy and P). Consumers that rectify, register, or project the rotated image with that CameraInfo will compute rays for the wrong pixels, especially with non-centered principal points. The software path needs to publish matching calibration/frame data along with the rotated image.

Useful? React with 👍 / 👎.

}
sensor_msgs::msg::Image::UniquePtr image_msg(new sensor_msgs::msg::Image());

cv_bridge::CvImage(std_msgs::msg::Header(), encoding_[stream_index], image)
Expand Down