主要就是为了提取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)