Ubuntu18.04 NX下用ZED2 双目立体相机进行SLAM

NX下的ZED2开发

  • 安装流程
    • 问题开始了
      • 看效果
      • 安装ZED2 ROS工具
    • 新故事篇章-zed2测距
      • 开始实现

安装流程

了解zed参数

因为 上的安装流程还是不太完整,我补充一下,希望对其他人也有帮助
部分流程参考这位:博主

自己的安装流程:
因为NX本来就自带cuda,所以无需安装cuda,所以首先你要知道自己cuda

  • 第一步

    进入下载官 页面, 址链接

    下载2.0.x版本的libjpeg-turbo-2.0.2.tar.gz

  • 第二步

    使用tar -zxvf libjpeg-turbo-2.0.2.tar.gz 将压缩包解压到当前目录中, 接着执行以下命令:

到这里, libjpeg-turbo就已经编译安装好了, 如果你是以root身份执行的,那么编译好后的文件在/usr/local/lib64 里面

  • 参考这位博主教程我是修改共享库配置文件/etc/ld.so.conf.

  • 1、设置:

  • 2、添加库路径:

保存退出;

  • 3、使配置立即生效

现在执行./ZED_Positional_Tracking成功了,tools里面的程序全部都可以执行成功.

看效果

执行命令

ros下命令行打开.pcd文件

新故事篇章-zed2测距

故事到这里,我才开始慢慢了解双目摄像头
zed2、
深度相机—TOF、双相机立体视觉、结构光立体视觉原理及优势对比、
点云的概念、
三维计算视觉研究、
双目原理、
聚类算法、
激光点云与图像融合的车辆检测方法、
双目立体视觉(4)- ZED2双目视觉开发理论与实践 with examples 0.1 object detection(这位博主很强啊)、
YOLO v5与双目测距结合,实现目标的识别和定位测距、
ORB-SLAM2系统的实时点云地图构建、

然后选择查看这两篇文章开始了三维建模的实践
基于ZED 2和ORB_SLAM2的SLAM实践
ZED 相机 && ORB-SLAM2安装环境配置与ROS下的调试

ROS Topic更改

运行流程:开启zed2->打开slam2->rviz可视化

突然项目要求居然从实时检测测距变成离线二维图测距,所以以上的东西又要放一放了。
题外话:项目要求是物外双目拍摄,然后回来再二维图上取点测距,这个和realsense深度摄像头很像,只是realsense测距只有10m,而这个zed2可以达到40米。好了,之后的内容就是直接拿zed2的深度图和rgb,然后三维映射到二维,然后opencv取点显示距离。搞好之后我再回来弄实时建图,融合图像识别加双目来测量每个聚类物的距离。但感觉户外用双目的点云测距肯定不如雷达,为什么不用雷达啊,因为穷。另外ZED2相机标定及运行VINS-mono、VINS-FUSION建模我也想跑一下,图像标定的话我想自己搞一下,那些都是后话。。。。

ZED2相机标定及运行VINS-mono
VINS-FUSION

开始实现

zed-ros的中心测距
中心测距是直接拿深度图,图像中心的深度值是通过图像像素中心的坐标然后转成深度图下的坐标来得到的。代码如下:

/////// Copyright (c) 2018, STEREOLABS.//// All rights reserved.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.//////** * This tutorial demonstrates simple receipt of ZED depth messages over the ROS system. */#include #include /** * Subscriber callback */void depthCallback(const sensor_msgs::Image::ConstPtr& msg){  // Get a pointer to the depth values casting the data  // pointer to floating point  float* depths = (float*)(&msg->data[0]);  // Image coordinates of the center pixel  int u = msg->width / 2;  int v = msg->height / 2;  // Linear index of the center pixel  int centerIdx = u + msg->width * v;  // Output the measure  ROS_INFO("Center distance : %g m", depths[centerIdx]);}/** * Node main function */int main(int argc, char** argv){  /**   * The ros::init() function needs to see argc and argv so that it can perform   * any ROS arguments and name remapping that were provided at the command line.   * For programmatic remappings you can use a different version of init() which takes   * remappings directly, but for most command-line programs, passing argc and argv is   * the easiest way to do it.  The third argument to init() is the name of the node.   *   * You must call one of the versions of ros::init() before using any other   * part of the ROS system.   */  ros::init(argc, argv, "zed_video_subscriber");  /**   * NodeHandle is the main access point to communications with the ROS system.   * The first NodeHandle constructed will fully initialize this node, and the last   * NodeHandle destructed will close down the node.   */  ros::NodeHandle n;  /**   * The subscribe() call is how you tell ROS that you want to receive messages   * on a given topic.  This invokes a call to the ROS   * master node, which keeps a registry of who is publishing and who   * is subscribing.  Messages are passed to a callback function, here   * called imageCallback.  subscribe() returns a Subscriber object that you   * must hold on to until you want to unsubscribe.  When all copies of the Subscriber   * object go out of scope, this callback will automatically be unsubscribed from   * this topic.   *   * The second parameter to the subscribe() function is the size of the message   * queue.  If messages are arriving faster than they are being processed, this   * is the number of messages that will be buffered up before beginning to throw   * away the oldest ones.   */  ros::Subscriber subDepth = n.subscribe(

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年5月8日
下一篇 2022年5月8日

相关推荐