[fix] only YUYV and I420 support color point cloud

This commit is contained in:
Joe Dong
2022-06-16 11:22:54 +08:00
parent 986cf29b5a
commit 438b04dab7
+8 -3
View File
@@ -36,10 +36,14 @@ OBCameraNode::OBCameraNode(rclcpp::Node* node, std::shared_ptr<ob::Device> devic
encoding_[INFRA0] = sensor_msgs::image_encodings::MONO16; encoding_[INFRA0] = sensor_msgs::image_encodings::MONO16;
stream_name_[OB_STREAM_IR] = "ir"; stream_name_[OB_STREAM_IR] = "ir";
unit_step_size_[INFRA0] = sizeof(uint8_t); unit_step_size_[INFRA0] = sizeof(uint8_t);
if (device_->getDeviceInfo()->pid() == FEMTO_PID) { const auto device_pid = device_->getDeviceInfo()->pid();
if (device_pid == FEMTO_PID || device_pid == FEMTO_LIVE_PID || device_pid == FEMTO_OW_PID) {
format_[COLOR] = OB_FORMAT_I420; format_[COLOR] = OB_FORMAT_I420;
} else if (device_->getDeviceInfo()->pid() == ASTRA_PLUS_PID) { } else if (device_pid == ASTRA_PLUS_PID || device_pid == ASTRA_PLUS_S_PID) {
format_[COLOR] = OB_FORMAT_YUYV; format_[COLOR] = OB_FORMAT_YUYV;
} else {
// default RGB888
format_[COLOR] = OB_FORMAT_RGB888;
} }
image_format_[OB_STREAM_COLOR] = CV_8UC3; image_format_[OB_STREAM_COLOR] = CV_8UC3;
encoding_[COLOR] = sensor_msgs::image_encodings::BGR8; encoding_[COLOR] = sensor_msgs::image_encodings::BGR8;
@@ -241,7 +245,8 @@ void OBCameraNode::publishPointCloud(std::shared_ptr<ob::FrameSet> frame_set) {
return; return;
} }
try { try {
if (publish_rgb_point_cloud_) { if (publish_rgb_point_cloud_ &&
(format_[COLOR] == OB_FORMAT_YUYV || format_[COLOR] == OB_FORMAT_I420)) {
if (frame_set->depthFrame() != nullptr && frame_set->colorFrame() != nullptr) { if (frame_set->depthFrame() != nullptr && frame_set->colorFrame() != nullptr) {
publishColorPointCloud(frame_set); publishColorPointCloud(frame_set);
} }