{"id":1080,"date":"2025-12-15T14:59:13","date_gmt":"2025-12-15T06:59:13","guid":{"rendered":"https:\/\/www.kakosci.com\/?p=1080"},"modified":"2025-12-15T14:59:13","modified_gmt":"2025-12-15T06:59:13","slug":"%e4%be%bf%e5%ae%9c%e6%b7%b1%e5%ba%a6%e7%9b%b8%e6%9c%ba%e5%90%af%e7%94%a8%e5%b8%a6%e5%85%89%e5%ad%a6%e8%89%b2%e5%bd%a9%e7%9a%84%e6%b7%b1%e5%ba%a6%e7%82%b9%e4%ba%91%ef%bc%88enable_colored_point_cloud","status":"publish","type":"post","link":"https:\/\/www.kakosci.com\/index.php\/2025\/12\/15\/%e4%be%bf%e5%ae%9c%e6%b7%b1%e5%ba%a6%e7%9b%b8%e6%9c%ba%e5%90%af%e7%94%a8%e5%b8%a6%e5%85%89%e5%ad%a6%e8%89%b2%e5%bd%a9%e7%9a%84%e6%b7%b1%e5%ba%a6%e7%82%b9%e4%ba%91%ef%bc%88enable_colored_point_cloud\/","title":{"rendered":"\u4fbf\u5b9c\u6df1\u5ea6\u76f8\u673a\u542f\u7528\u5e26\u5149\u5b66\u8272\u5f69\u7684\u6df1\u5ea6\u70b9\u4e91\uff08enable_colored_point_cloud\uff09"},"content":{"rendered":"\n<p>\u6dd8\u5b9d\u4e00\u5343\u7684orbbec\u6df1\u5ea6\u76f8\u673a\uff0c\u5b9e\u5219\u662f\u5e76\u975eorbbec\u7684\u522b\u5bb6\u505a\u7684\uff0c\u53ea\u80fd\u9002\u914d\u5965\u6bd4\u4e2d\u5149\u6bd4\u8f83\u8001\u7684sdk\u6216ros2\u4ed3\u5e93\uff0cROS2\u9002\u914d\u7684\u4ee3\u7801\uff1a<a href=\"https:\/\/github.com\/orbbec\/ros2_astra_camera\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/orbbec\/ros2_astra_camera<\/a><\/p>\n\n\n\n<p>launch\u6587\u4ef6\u91cc\u9762\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"841\" height=\"400\" src=\"https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-1.png\" alt=\"\" class=\"wp-image-1086\" srcset=\"https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-1.png 841w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-1-300x143.png 300w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-1-768x365.png 768w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-1-670x319.png 670w\" sizes=\"auto, (max-width: 841px) 100vw, 841px\" \/><\/figure>\n\n\n\n<p>\u5e26\u8272\u5f69\u7684\u70b9\u4e91\u9ed8\u8ba4\u6ca1\u6709\u5f00\u542f\uff0c\u5c31\u7b97\u6539true\u518d\u7f16\u8bd1\uff0c\u542f\u52a8\u540e\u867d\u7136\u6709\u5bf9\u5e94\u8bdd\u9898\u4e86\u4f46\u5230rviz2\u91cc\u4e00\u770b\u8fd8\u662f\u7a7a\u7684\uff0c\u63a7\u5236\u53f0\u4f1a\u62a5\u544a\u6df1\u5ea6\u4e0e\u5149\u5b66\u5c3a\u5bf8\u4e0d\u5339\u914d\u7684\u9519\uff0c\u786e\u5b9e\u4e00\u4e2a640*480\u4e00\u4e2a640*400\u3002\u7136\u800cpyorbbecsdk\u91cc\u90fd\u6709\u6df1\u5ea6\u56fe\u548c\u8272\u5f69\u56fe\u4e00\u8d77\u8f93\u51fa\u7684\u793a\u4f8b\u800c\u4e14\u5339\u914d\u5f97\u6ca1\u5565\u95ee\u9898\u65e0\u975e\u4e0d\u662f\u6574\u5e45\u90fd\u6709\u6df1\u5ea6\uff0c\u80af\u5b9a\u662f\u80fd\u6821\u6b63\u7684\u3002\u627e\u5230\u7528\u6765\u8f93\u51fa\u8fd9\u79cd\u70b9\u4e91\u7684\u6e90\u4ee3\u7801\uff0cpoint_cloud_xyzrgb.cpp\u4e2d\u7684\u4e00\u6bb5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">  \/\/ Check if the input image has to be resized\n  Image::ConstSharedPtr rgb_msg = rgb_msg_in;\n  if (depth_msg->width != rgb_msg->width || depth_msg->height != rgb_msg->height) {\n    CameraInfo info_msg_tmp = *info_msg;\n    info_msg_tmp.width = depth_msg->width;\n    info_msg_tmp.height = depth_msg->height;\n    float ratio = static_cast&lt;float>(depth_msg->width) \/ static_cast&lt;float>(rgb_msg->width);\n    info_msg_tmp.k[0] *= ratio;\n    info_msg_tmp.k[2] *= ratio;\n    info_msg_tmp.k[4] *= ratio;\n    info_msg_tmp.k[5] *= ratio;\n    info_msg_tmp.p[0] *= ratio;\n    info_msg_tmp.p[2] *= ratio;\n    info_msg_tmp.p[5] *= ratio;\n    info_msg_tmp.p[6] *= ratio;\n    model_.fromCameraInfo(info_msg_tmp);\n\n    cv_bridge::CvImageConstPtr cv_ptr;\n    try {\n      cv_ptr = cv_bridge::toCvShare(rgb_msg, rgb_msg->encoding);\n    } catch (cv_bridge::Exception&amp; e) {\n      RCLCPP_ERROR(logger_, \"cv_bridge exception: %s\", e.what());\n      return;\n    }\n    cv_bridge::CvImage cv_rsz;\n    cv_rsz.header = cv_ptr->header;\n    cv_rsz.encoding = cv_ptr->encoding;\n    \/\/ FIXME:\n    int end_raw = std::min&lt;int>(depth_msg->height \/ ratio, rgb_msg->height);\n    cv::resize(cv_ptr->image.rowRange(0, end_raw), cv_rsz.image,\n               cv::Size(depth_msg->width, depth_msg->height));\n    if ((rgb_msg->encoding == enc::RGB8) || (rgb_msg->encoding == enc::BGR8) ||\n        (rgb_msg->encoding == enc::MONO8)) {\n      rgb_msg = cv_rsz.toImageMsg();\n    } else {\n      rgb_msg = cv_bridge::toCvCopy(cv_rsz.toImageMsg(), enc::RGB8)->toImageMsg();\n    }\n\n    RCLCPP_ERROR_THROTTLE(logger_, *(node_->get_clock()), 50000,\n                          \"Depth resolution (%ux%u) does not match RGB resolution (%ux%u)\",\n                          depth_msg->width, depth_msg->height, rgb_msg->width, rgb_msg->height);\n    return;\n  } else {\n    rgb_msg = rgb_msg_in;\n  }<\/code><\/pre>\n\n\n\n<p>\u7834\u6848\u4e86\u662f\u4e24\u5e74\u524d\u8001\u4ed3\u5e93\u53ef\u80fd\u88ab\u5f03\u7528\uff0c\u8d6b\u7136\u8868\u7740\u4e2aFIXME\u3002\u6240\u4ee5\u8fd9\u6bb5\u4ee3\u7801\u5b9e\u9645\u524d\u9762\u5df2\u7ecf\u505a\u4e86\u9488\u5bf9\u70b9\u4e91\u548c\u8272\u5f69\u5c3a\u5bf8\u4e0d\u5339\u914d\u7684resize\u7b49\uff0c\u4f46\u6700\u540e\u53c8\u76f4\u63a5\u52a0\u4e86\u4e2a\u7ed9ROS2\u62a5\u7684ERROR\uff0c\u7136\u540ereturn\u3002<\/p>\n\n\n\n<p>\u62b1\u7740\u8bd5\u4e00\u8bd5\u7684\u5fc3\u6001\u628a\u62a5\u9519\u6539\u8b66\u544a\uff0creturn\u6ce8\u89c6\u6389\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">    RCLCPP_WARN_THROTTLE(logger_, *(node_->get_clock()), 50000,\n                          \"Depth resolution (%ux%u) does not match RGB resolution (%ux%u)\",\n                          depth_msg->width, depth_msg->height, rgb_msg->width, rgb_msg->height);\n    \/\/return;<\/code><\/pre>\n\n\n\n<p>\u7f16\u8bd1\u5b8c\u518d\u542f\u52a8\uff0c\u7ed3\u679c\u51fa\u6765\u70b9\u4e91\u8d28\u91cf\u611f\u89c9\u633a\u597d\u7684\u561b\u2026\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-1024x576.png\" alt=\"\" class=\"wp-image-1089\" srcset=\"https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-1024x576.png 1024w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-300x169.png 300w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-768x432.png 768w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-1536x864.png 1536w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-2048x1152.png 2048w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-520x293.png 520w, https:\/\/www.kakosci.com\/wp-content\/uploads\/2025\/12\/image-2-670x377.png 670w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6240\u4ee5\u5356\u5bb6\u4e3a\u4ec0\u4e48\u505a\u4e2a\u6df1\u5ea6\u76f8\u673a\u5c31\u62ff\u6765\u9002\u914d\u8fd9\u79cd\u5df2\u7ecf\u4e2d\u9014\u88ab\u653e\u5f03\uff0c\u6539\u90fd\u6ca1\u6539\u5b8c\u7684\u4ed3\u5e93\u2026\u2026\u597d\u5728\u786e\u5b9e\u80fd\u7528\uff0c\u8fd8\u662f\u8bf4\u771f\u6b63\u7684\u5751\u8fd8\u5728\u540e\u5934\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6dd8\u5b9d\u4e00\u5343\u7684orbbec\u6df1\u5ea6\u76f8\u673a\uff0c\u5b9e\u5219\u662f\u5e76\u975eorbbec\u7684\u522b\u5bb6\u505a\u7684\uff0c\u53ea\u80fd\u9002\u914d\u5965\u6bd4\u4e2d&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1085,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[95,87,93,66],"tags":[98,94,97,91,96],"class_list":["post-1080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ros2","category-87","category-93","category-66","tag-depth-camera","tag-orbbec","tag-point-cloud","tag-ros2","tag-rviz2"],"_links":{"self":[{"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/posts\/1080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/comments?post=1080"}],"version-history":[{"count":8,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/posts\/1080\/revisions"}],"predecessor-version":[{"id":1093,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/posts\/1080\/revisions\/1093"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/media\/1085"}],"wp:attachment":[{"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/media?parent=1080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/categories?post=1080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kakosci.com\/index.php\/wp-json\/wp\/v2\/tags?post=1080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}