yanyan-li / PlanarSLAM

A RGB-D SLAM system for structural scenes, which makes use of point-line-plane features and the Manhattan World assumption.
381 stars 85 forks source link

Segmentation error (solved) #3

Open wangzilongmax opened 3 years ago

wangzilongmax commented 3 years ago

我在ubuntu18运行,运行数据集显示段错误,这个为啥,安装编译都没问题

yanyan-li commented 3 years ago

Thanks for testing our system. Could you paste the input and output information here? Or trying to print something out to check which part generates errors.

wangzilongmax commented 3 years ago

Thanks for testing our system. Could you paste the input and output information here? Or trying to print something out to check which part generates errors.

mmexport1617323073739 PCL为ubuntu18的1.8,opencv为3.4,Eigen3.2.4,这是运行tum数据集的信息,运行其他数据集也是这样情况,编译的时候都是正常的,g2o这些都是用代码自带的版本编译的,实在不知道哪里有问题,希望给予帮助

wangzilongmax commented 3 years ago

Thanks for testing our system. Could you paste the input and output information here? Or trying to print something out to check which part generates errors.

mmexport1617323073739 PCL为ubuntu18的1.8,opencv为3.4,Eigen3.2.4,这是运行tum数据集的信息,运行其他数据集也是这样情况,编译的时候都是正常的,g2o这些都是用代码自带的版本编译的,实在不知道哪里有问题,希望给予帮助

yanyan-li commented 3 years ago

Can you try "fr3/structure_texture_near" ? maybe the sequences you tried cannot extract good planes? or those scenes are not Manhattan World models?

In the function: "bool Frame::MaxPointDistanceFromPlane(cv::Mat &plane, PointCloud::Ptr pointCloud) ", you can try to add image

joanpepcompany commented 3 years ago

Hello, I have found the same issue as wangzilongmax. I'm using Ubuntu 18.04, and I have tried with the PCL 1.7 and 1.9. The installation of the PCL has been done as you suggest. I have noticed that the problem is in the voxel filter and the normal extraction functions used in void Frame::ComputePlanes. The datasets used are: ICL_NUIM of_kt0 and the TUM rgbd_dataset_freiburg3_structure_notexture_far. Regards!

yanyan-li commented 3 years ago

Hi @wangzilongmax

The function " bool Frame::MaxPointDistanceFromPlane(cv::Mat &plane, PointCloud::Ptr pointCloud) " was added into the system. and tested it locally. Could you try to test it again.

joanpepcompany commented 3 years ago

Hello again, the problem persist with the function added. Do you also have this problem? I had some time to debug and I have found that the problem occurs when the exit of the function, Frame::ComputePlanes, generates a memory deallocation of the coarsecloudand the cloud_normals. This problem is exposed in the following link https://stackoverflow.com/questions/61278204/segmentation-fault-when-deallocating-pclpointcloudpclpointxyzptr I hope this helps, regards!

yanyan-li commented 3 years ago

Hello again, the problem persist with the function added. Do you also have this problem? I had some time to debug and I have found that the problem occurs when the exit of the function, Frame::ComputePlanes, generates a memory deallocation of the coarsecloudand the cloud_normals. This problem is exposed in the following link https://stackoverflow.com/questions/61278204/segmentation-fault-when-deallocating-pclpointcloudpclpointxyzptr I hope this helps, regards!

Hi, For the associations files of TUM RGB-D and ICL are different. For our system, we read rgb frames first, and then depth images. This is the result of of0, maybe you could pull the updated code and test it again. Screenshot from 2021-04-15 18-40-07

joanpepcompany commented 3 years ago

I upload the code and the problem persist. I have the same problem as yanyan-li. The following output is from the ICL-NUIM of_kt0 dataset.

img_width = 640 img_height = 480 mUndistX size = 0x556e5742d278mUndistY size = 0x556e5742d2d8

Camera Parameters:

ORB Extractor Parameters:

Depth Threshold (Close/Far Points): 3.32502 PlanarSLAM Printer: This is the 0th image

step=2873, #extractedPlanes=9

Segmentation fault (core dumped).

yanyan-li commented 3 years ago

I upload the code and the problem persist. I have the same problem as yanyan-li. The following output is from the ICL-NUIM of_kt0 dataset.

img_width = 640 img_height = 480 mUndistX size = 0x556e5742d278mUndistY size = 0x556e5742d2d8

Camera Parameters:

* fx: 481.2

* fy: -480

* cx: 319.5

* cy: 239.5

* k1: 0

* k2: 0

* p1: 0

* p2: 0

* fps: 30

* color order: RGB (ignored if grayscale)

ORB Extractor Parameters:

* Number of Features: 1000

* Scale Levels: 8

* Scale Factor: 1.2

* Initial Fast Threshold: 20

* Minimum Fast Threshold: 7

Depth Threshold (Close/Far Points): 3.32502 PlanarSLAM Printer: This is the 0th image

step=2873, #extractedPlanes=9

Segmentation fault (core dumped).

very wired. I pulled the current code and tested again. it worked well in the OF0 sequence.

  1. the mUndistX generated from your terminal seems wrong. img_width = 640 img_height = 480 mUndistX size = 480 x 640mUndistY size = 480 x 640
  2. how about other sequences of ICL-NUIM?
joanpepcompany commented 3 years ago

Hello,

  1. The function size() of OpenCV requires (). You can find the problem https://github.com/yanyan-li/PlanarSLAM/blob/2720f5c112bbb401604623fc3df716936b857894/src/Tracking.cc#L63
  2. The problem persists with all the datasets. I think the problem is related to the PCL library. Have you installed as you suggest or do have you installed by other sources like ROS? I have installed the PCL as you suggest in the readme, but the folder location after the make install is not found by your CMakeLists. Then, I used the sudo apt-get install libpcl-dev instead of your solution.
joanpepcompany commented 3 years ago

Hello, Commenting the following lines in the CMakeLists.txt solved the related problem:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

add_definitions(${PCL_DEFINITIONS})

zoe4751 commented 3 years ago

I tried "fr3/structure_texture_near" and "TUM/rgbd_dataset_freiburg2_desk", but the window"planar Mesh" are both empty,wish your help. 2021-08-07 13-25-51屏幕截图 2021-08-07 12-54-34屏幕截图 and the terminal is : 2021-08-07 14-17-16屏幕截图 wish your help.

yanyan-li commented 3 years ago

I tried "fr3/structure_texture_near" and "TUM/rgbd_dataset_freiburg2_desk", but the window"planar Mesh" are both empty,wish your help. 2021-08-07 13-25-51屏幕截图 2021-08-07 12-54-34屏幕截图 and the terminal is : 2021-08-07 14-17-16屏幕截图 wish your help.

It seems that some installation problems come from VTK and PCL.

Yejing-Lai commented 3 years ago

I tried "fr3/structure_texture_near" and "TUM/rgbd_dataset_freiburg2_desk", but the window"planar Mesh" are both empty,wish your help. 2021-08-07 13-25-51屏幕截图 2021-08-07 12-54-34屏幕截图 and the terminal is : 2021-08-07 14-17-16屏幕截图 wish your help.

Have you solved it? I have the same problem.

qiaozhijian commented 2 years ago

I ran into the same problem. What is certain is that this problem is related to PCL. I printed some infos in the function MaxPointDistanceFromPlane:

Screenshot from 2021-11-30 14-13-06

and found "seg.segment(inliers, coefficients);" broken. The output is listed:

Screenshot from 2021-11-30 14-19-36

My PCL version is 1.8.1. Someone said it is related to the combination of thread and PCL. So I save the point cloud to tmp.pcd, and tried it in a single script. But it ran normally. This is very confusing. It is also upsetting that this excellent work cannot be used because of PCL problems. The script is following:

#include<iostream>
#include<algorithm>
#include<System.h>
#include<Mesh.h>
#include <pcl/io/pcd_io.h> 
#include <pcl/point_types.h> 

using namespace std;

typedef pcl::PointXYZRGB PointT;

class Frame{
    public:
    Frame(int a = 0){
        pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>);
        pcl::io::loadPCDFile<PointT> ("tmp.pcd", *cloud);
        pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
        pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
        pcl::SACSegmentation<PointT> seg;
        seg.setOptimizeCoefficients(true);
        seg.setModelType(pcl::SACMODEL_PLANE);
        seg.setMethodType(pcl::SAC_RANSAC);
        seg.setDistanceThreshold(0.5);
        seg.setInputCloud(cloud);
        seg.segment(*inliers, *coefficients);
        cout<<"finish"<<endl<<flush;
    }
};

void func1(){ Frame frame = Frame(1);}

void func2(){ Frame frame = Frame(2);}

int main(int argc, char **argv)
{
    thread thread1(func1);
    thread thread2(func2);
    thread1.join();
    thread2.join();
    return 0;
}

I will continue to do related experiments to find solutions. If anyone has experience in solving this problem, please reply me, thank you!

qiaozhijian commented 2 years ago

Interesting...I put those code to the start of main.cc, it got broken.

Screenshot from 2021-11-30 14-47-19

terminal:

Screenshot from 2021-11-30 14-51-17

Then I deleted the code after row 38(It means SLAM was deleted), it ran normally. It seems some linked libraries are conflicted.

qiaozhijian commented 2 years ago

Removing '-march=native' in both PlanarSLAM/CmakeList and g2o/Cmakelist works for me.

It seems an error produced by vtk in PCL.