国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

rviz是如何獲取圖像里選擇的點(diǎn)云的3D坐標(biāo)的

這篇具有很好參考價(jià)值的文章主要介紹了rviz是如何獲取圖像里選擇的點(diǎn)云的3D坐標(biāo)的。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

以前以為rviz是用OpenGL渲染繪圖,那么獲取圖像里像素點(diǎn)對應(yīng)的真實(shí)3D坐標(biāo)是采用的OpenGL里提供的API實(shí)現(xiàn)的,結(jié)果一看代碼還真不是這樣,rviz也就渲染用了OpenGL,其他都是自己實(shí)現(xiàn)的,圖像界面的實(shí)現(xiàn)完全是遵循MVC設(shè)計(jì)模式自己實(shí)現(xiàn)的透視投影和坐標(biāo)轉(zhuǎn)換等所有相關(guān)類。獲取點(diǎn)云圖像里所選擇的點(diǎn)云點(diǎn)的3D坐標(biāo)相關(guān)的代碼是這里:

src/rviz/selection/selection_manager.cpp:

bool SelectionManager::getPatchDepthImage(Ogre::Viewport* viewport,
                                          int x,
                                          int y,
                                          unsigned width,
                                          unsigned height,
                                          std::vector<float>& depth_vector)
{
  unsigned int num_pixels = width * height;
  depth_vector.reserve(num_pixels);

  setDepthTextureSize(width, height);


  M_CollisionObjectToSelectionHandler::iterator handler_it = objects_.begin();
  M_CollisionObjectToSelectionHandler::iterator handler_end = objects_.end();

  for (; handler_it != handler_end; ++handler_it)
  {
    handler_it->second->preRenderPass(0);
  }

  if (render(viewport, depth_render_texture_, x, y, x + width, y + height, depth_pixel_box_, "Depth",
             depth_texture_width_, depth_texture_height_))
  {
    uint8_t* data_ptr = (uint8_t*)depth_pixel_box_.data;

    for (uint32_t pixel = 0; pixel < num_pixels; ++pixel)
    {
      uint8_t a = data_ptr[4 * pixel];
      uint8_t b = data_ptr[4 * pixel + 1];
      uint8_t c = data_ptr[4 * pixel + 2];

      int int_depth = (c << 16) | (b << 8) | a;
      float normalized_depth = ((float)int_depth) / (float)0xffffff;
      depth_vector.push_back(normalized_depth * camera_->getFarClipDistance());
    }
  }
  else
  {
    ROS_WARN("Failed to render depth patch\n");
    return false;
  }

  handler_it = objects_.begin();
  handler_end = objects_.end();
  for (; handler_it != handler_end; ++handler_it)
  {
    handler_it->second->postRenderPass(0);
  }

  return true;
}

bool SelectionManager::get3DPatch(Ogre::Viewport* viewport,
                                  int x,
                                  int y,
                                  unsigned width,
                                  unsigned height,
                                  bool skip_missing,
                                  std::vector<Ogre::Vector3>& result_points)
{
  boost::recursive_mutex::scoped_lock lock(global_mutex_);
  ROS_DEBUG("SelectionManager.get3DPatch()");

  std::vector<float> depth_vector;


  if (!getPatchDepthImage(viewport, x, y, width, height, depth_vector))
    return false;


  unsigned int pixel_counter = 0;
  Ogre::Matrix4 projection = camera_->getProjectionMatrix();
  float depth;

  for (unsigned y_iter = 0; y_iter < height; ++y_iter)
    for (unsigned x_iter = 0; x_iter < width; ++x_iter)
    {
      depth = depth_vector[pixel_counter];

      // Deal with missing or invalid points
      if ((depth > camera_->getFarClipDistance()) || (depth == 0))
      {
        ++pixel_counter;
        if (!skip_missing)
        {
          result_points.push_back(Ogre::Vector3(NAN, NAN, NAN));
        }
        continue;
      }


      Ogre::Vector3 result_point;
      // We want to shoot rays through the center of pixels, not the corners,
      // so add .5 pixels to the x and y coordinate to get to the center
      // instead of the top left of the pixel.
      Ogre::Real screenx = float(x_iter + .5) / float(width);
      Ogre::Real screeny = float(y_iter + .5) / float(height);
      if (projection[3][3] == 0.0) // If this is a perspective projection
      {
        // get world-space ray from camera & mouse coord
        Ogre::Ray vp_ray = camera_->getCameraToViewportRay(screenx, screeny);
        // transform ray direction back into camera coords
        Ogre::Vector3 dir_cam = camera_->getDerivedOrientation().Inverse() * vp_ray.getDirection();

        // normalize, so dir_cam.z == -depth
        dir_cam = dir_cam / dir_cam.z * depth * -1;

        // compute 3d point from camera origin and direction*/
        result_point = camera_->getDerivedPosition() + camera_->getDerivedOrientation() * dir_cam;
      }
      else // else this must be an orthographic projection.
      {
        // For orthographic projection, getCameraToViewportRay() does
        // the right thing for us, and the above math does not work.
        Ogre::Ray ray;
        camera_->getCameraToViewportRay(screenx, screeny, &ray);

        result_point = ray.getPoint(depth);
      }

      result_points.push_back(result_point);
      ++pixel_counter;
    }

  return !result_points.empty();
}

bool SelectionManager::get3DPoint(Ogre::Viewport* viewport, int x, int y, Ogre::Vector3& result_point)
{
  ROS_DEBUG("SelectionManager.get3DPoint()");

  std::vector<Ogre::Vector3> result_points_temp;
  bool success = get3DPatch(viewport, x, y, 1, 1, true, result_points_temp);
  if (result_points_temp.empty())
  {
    // return result_point unmodified if get point fails.
    return false;
  }
  result_point = result_points_temp[0];

  return success;
}

世界3D坐標(biāo)是用的射線法計(jì)算出來。SelectionManager::get3DPoint()被rviz里多個(gè)地方調(diào)用,凡是UI界面上需要查看點(diǎn)的坐標(biāo)地方都是調(diào)用它。文章來源地址http://www.zghlxwxcb.cn/news/detail-857533.html

到了這里,關(guān)于rviz是如何獲取圖像里選擇的點(diǎn)云的3D坐標(biāo)的的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 基于3D點(diǎn)云的小目標(biāo)檢測學(xué)習(xí)筆記

    基于3D點(diǎn)云的小目標(biāo)檢測學(xué)習(xí)筆記

    一、與圖像相比, 基于點(diǎn)云的目標(biāo)檢測 一直面臨著一些 挑戰(zhàn) : 1、 非結(jié)構(gòu)化數(shù)據(jù) :點(diǎn)云作為場景中點(diǎn)的位置具有稀疏和非結(jié)構(gòu)化的性質(zhì),因此它們的密度和數(shù)量都隨著場景中對象而變化。 2、 不變性排列 :點(diǎn)云本質(zhì)上是一長串點(diǎn)(nx3矩陣,其中n是點(diǎn)數(shù))。 在幾何上,點(diǎn)

    2024年02月12日
    瀏覽(18)
  • Open3D快速裁剪指定區(qū)域的點(diǎn)云

    Open3D快速裁剪指定區(qū)域的點(diǎn)云 Open3D是一個(gè)用于計(jì)算機(jī)視覺和三維重建的開源庫,它提供了許多強(qiáng)大的工具來處理點(diǎn)云數(shù)據(jù)。其中包括一個(gè)簡單但功能強(qiáng)大的裁剪點(diǎn)云的函數(shù),可以通過指定一個(gè)三維框來選擇任意指定區(qū)域的點(diǎn)。 在本文中,我們將介紹如何在Open3D中使用該函數(shù)

    2024年02月07日
    瀏覽(20)
  • 3D點(diǎn)云分割系列5:RandLA-Net:3D點(diǎn)云的實(shí)時(shí)語義分割,隨機(jī)降采樣的重生

    3D點(diǎn)云分割系列5:RandLA-Net:3D點(diǎn)云的實(shí)時(shí)語義分割,隨機(jī)降采樣的重生

    《RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds》發(fā)布于CVPR 2020。 在自動(dòng)駕駛等領(lǐng)域,高效的分割網(wǎng)絡(luò)是目前最基本和最關(guān)鍵的研究方向。目前存在的一些點(diǎn)云處理方法包括PointNet、PointNet++、PointCNN、KPConv等方法,或多或少都存在效率不高或是特征采樣不足的情況,

    2024年02月04日
    瀏覽(19)
  • 基于Open3D的點(diǎn)云處理16-特征點(diǎn)匹配

    基于Open3D的點(diǎn)云處理16-特征點(diǎn)匹配

    將點(diǎn)云數(shù)據(jù)統(tǒng)一到一個(gè)世界坐標(biāo)系的過程稱之為點(diǎn)云配準(zhǔn)或者點(diǎn)云拼接。(registration/align) 點(diǎn)云配準(zhǔn)的過程其實(shí)就是找到同名點(diǎn)對;即找到在點(diǎn)云中處在真實(shí)世界同一位置的點(diǎn)。 常見的點(diǎn)云配準(zhǔn)算法: ICP、Color ICP、Trimed-ICP 算法流程: 選點(diǎn): 確定參與到配準(zhǔn)過程中的點(diǎn)集。 匹

    2024年02月10日
    瀏覽(39)
  • [論文閱讀]PillarNeXt——基于LiDAR點(diǎn)云的3D目標(biāo)檢測網(wǎng)絡(luò)設(shè)計(jì)

    [論文閱讀]PillarNeXt——基于LiDAR點(diǎn)云的3D目標(biāo)檢測網(wǎng)絡(luò)設(shè)計(jì)

    PillarNeXt: Rethinking Network Designs for 3D Object Detection in LiDAR Point Clouds 基于LiDAR點(diǎn)云的3D目標(biāo)檢測網(wǎng)絡(luò)設(shè)計(jì) 論文網(wǎng)址:PillarNeXt 代碼:PillarNeXt 這篇論文\\\"PillarNeXt: Rethinking Network Designs for 3D Object Detection in LiDAR Point Clouds\\\"重新思考了用于激光雷達(dá)點(diǎn)云3D目標(biāo)檢測的網(wǎng)絡(luò)設(shè)計(jì)。主要的貢獻(xiàn)

    2024年02月08日
    瀏覽(28)
  • 使用python-open3d讀取pcd,bin格式的點(diǎn)云,并顯示

    使用python-open3d讀取pcd,bin格式的點(diǎn)云,并顯示

    open3d讀取pcd格式點(diǎn)云 效果圖 ? ?用open3d讀取bin文件 ? 效果圖? ? ?

    2024年02月11日
    瀏覽(18)
  • 基于Open3D的點(diǎn)云處理17-Open3d的C++版本

    基于Open3D的點(diǎn)云處理17-Open3d的C++版本

    http://www.open3d.org/docs/latest/cpp_api.html http://www.open3d.org/docs/latest/getting_started.html#c http://www.open3d.org/docs/release/cpp_project.html#cplusplus-example-project https://github.com/isl-org/open3d-cmake-find-package https://github.com/isl-org/open3d-cmake-external-project https://github.com/isl-org/Open3D/releases Note: -DBUILD_SHARED_LIBS

    2024年02月09日
    瀏覽(47)
  • Open3D 格網(wǎng)法計(jì)算點(diǎn)云的占地面積

    ??該方法主要用于粗略統(tǒng)計(jì)機(jī)載點(diǎn)云的占地面積。方法原理是將點(diǎn)云沿 X O Y XOY X O Y 面劃分成格網(wǎng),統(tǒng)計(jì)有點(diǎn)的格網(wǎng)面積來近似表示點(diǎn)云占地面積。

    2024年02月05日
    瀏覽(16)
  • Open3D 計(jì)算點(diǎn)云的倒角距離(Chamfer Distance)

    ??Chamfer Distance距離可以計(jì)算生成點(diǎn)云數(shù)據(jù)與標(biāo)簽點(diǎn)云數(shù)據(jù)之間的平均最短點(diǎn)距離。Open3D可以直接用來計(jì)算點(diǎn)云的Chamfer Distance距離,關(guān)于的Chamfer Distance距離在點(diǎn)云上應(yīng)用的更多詳細(xì)介紹可以參考:PCL 計(jì)算點(diǎn)云的倒角距離(Chamfer Distance)或碩士論文: [1]張永涵. 基于深度學(xué)

    2024年02月12日
    瀏覽(23)
  • 【3D目標(biāo)檢測】基于偽雷達(dá)點(diǎn)云的單目3D目標(biāo)檢測方法研宄

    【3D目標(biāo)檢測】基于偽雷達(dá)點(diǎn)云的單目3D目標(biāo)檢測方法研宄

    本文是基于單目圖像的3D目標(biāo)檢測方法,是西安電子科技大學(xué)的郭鑫宇學(xué)長的碩士學(xué)位論文。 【2021】【單目圖像的3D目標(biāo)檢測方法研究】 研究的問題: 如何提高偽點(diǎn)云的質(zhì)量 偽點(diǎn)云體系中如何提高基于點(diǎn)云的檢測算法的效果 提出的方法: 一種基于置信度的偽點(diǎn)云采樣方法

    2024年02月06日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包