ROS配置SLAM环境

主要就是为了提取DS-SLAM的语义分割结果,据说是在segment.cc中修改。直接在segment.cc中imshow了半天也没出图片结果,好像是被ROS通信阻断了,索性把segment.cc的函数全搬来了放在ros_tum_realtime.cc中当然还是比较菜查找clion安装的路径locate clion.sh的sh /home/xcc/clion-2021.1.3/bin/clion.shCMake options-DCATKIN_DEVEL_PREFIX:PATH=/hom
摘要由CSDN通过智能技术生成

主要就是为了提取DS-SLAM的语义分割结果,据说是在segment.cc中修改。
直接在segment.cc中imshow了半天也没出图片结果,好像是被ROS通信阻断了,索性把segment.cc的函数全搬来了放在ros_tum_realtime.cc中
当然还是比较菜

查找clion安装的路径

locate clion.sh
sh /home/xcc/clion-2021.1.3/bin/clion.sh

CMake options

-DCATKIN_DEVEL_PREFIX:PATH=/home/xcc/catkin_ws/devel

配置ORB_SLAM2_PointMap_SegNetM的Program argumens

Vocabulary/ORBvoc.bin ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/TUM3.yaml ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/rgbd_dataset_freiburg3_walking_xyz/ ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/rgbd_dataset_freiburg3_walking_xyz/associate.txt ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/prototxts/segnet_pascal.prototxt ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/models/segnet_pascal.caffemodel ./Examples/ROS/ORB_SLAM2_PointMap_SegNetM/tools/pascal.png

Working directory

/home/xcc/catkin_ws/src/DS-SLAM

segemnt.cc删除了一些ROS通信


#include "Segment.h"
#include "Tracking.h"
#include "Camera.h"
#include <fstream>
#define SKIP_NUMBER 1
using namespace std;

namespace ORB_SLAM2 {
   
    Segment::Segment(const string &pascal_prototxt, const string &pascal_caffemodel, const string &pascal_png) {
   

        model_file = pascal_prototxt;
        trained_file = pascal_caffemodel;
        LUT_file = pascal_png;
        cv::waitKey(0);
        label_colours = cv::imread(LUT_file, 1);
        cv::imshow("image", label_colours);
        cv::waitKey(0);
        cv::cvtColor(label_colours, label_colours, CV_RGB2BGR);
        mImgSegmentLatest = cv::Mat(460, 320, CV_8UC1);
        cv::imshow("image", mImgSegmentLatest);
        cv::waitKey(0);

    }


    void Segment::Run() {
   
        classifier = new Classifier(model_file, trained_file);
        cout << "Load model ..." << endl;

        usleep(1);

        //cout << "Wait for new RGB img time =" << endl;
        //std::chrono::steady_clock::time_point t3 = std::chrono::steady_clock::now();
        // Recognise by Semantin segmentation
        mImgSegment = classifier->Predict(mImg, label_colours);
        cv::imshow("image", mImgSegment);
        cv::waitKey(0);
        cv::Mat mImgSegment_color = mImgSegment.clone();
        cv::imshow("image", mImgSegment_color);
        cv::waitKey(0);

        // 对于图像还有很多基本的操作,如剪切,旋转,缩放等,限于篇幅就不一一介绍了,请参看OpenCV官方文档查询每个函数的调用方法.
        // cv::destroyAllWindows();
        // exit(-1);
        cv::cvtColor(mImgSegment, mImgSegment_color, CV_GRAY2BGR);
        cv::imshow("image", mImgSegment_color);
        cv::waitKey(0);
        LUT(mImgSegment_color, label_colours, mImgSegment_color_final);
        cv::imshow("image", mImgSegment_color_final);
        cv::waitKey(0);
        cv::resize(mImgSegment, mImgSegment, cv::Size(Camera::width, Camera::height));
        cv::imshow("image", mImgSegment);
        cv::waitKey(0);
        cv::resize(mImgSegment_color_final, mImgSegment_color_final, cv::Size(Camera::width, Camera::height));
        cv::imshow("image", mImgSegment_color_final);
        cv::waitKey(0);
        //std::chrono::steady_clock::time_point t4 = std::chrono::steady_clock::now();
        //mSegmentTime+=std::chrono::duration_cast<std::chrono::duration<double> >(t4 - t3).count();
        //mSkipIndex=0;
        //imgIndex++;
    }

    //mSkipIndex++;
    //ProduceImgSegment();
}

bool Segment::CheckFinish()
{
   
    unique_lock<mutex> lock(mMutexFinish)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值