Ubuntu 16.04 install CloudCompare

One single command should work <sup>[1]</sup>

snap install cloudcompare

But error occurs:ios

error: cannot perform the following tasks:
- Download snap "cloudcompare" (200) from channel "stable" (Get https://api.snapcraft.io/api/v1/snaps/download/SMYgr36XCuPZDbMnuOu5x4eFvcHALPyL_200.snap: dial tcp: lookup api.snapcraft.io on 127.0.1.1:53: read udp 127.0.0.1:55699->127.0.1.1:53: i/o timeout)

Solved by adding sudo

sudo snap install cloudcompare

Open cloudcompare in a terminal <sup>[2]</sup>

cloudcompare.ccViewergit

or cloudcompare.CloudComparegithub

Error occurs:ubuntu

QXcbConnection: Could not connect to display :0
Aborted (core dumped)

Solved by answer <sup>[3]</sup>

sudo snap install meshlabapi

Error occurred while loading pcd file

[Load] Can't guess file format: unhandled file extension'pcd'tcp

Sovled by answer <sup>[4]</sup>

The stable version of CC can not open pcd file.ui

Switch it to edge version bythis

sudo snap refresh --edge cloudcomparespa

NOTE: Edge verstion dosen't stable when saving .pcd files

There is a 90° rotation between along axis x between the original point cloud and output cloud..net

Update: a solution found <sup>[5]</sup>


So I gived up the edge version. Build and install CC from source <sup>[2]</sup>

git clone --recursive https://github.com/cloudcompare/trunk.git
cd trunk
mkdir build
cd build
cmake ..
make -j4
sudo make install

Launch CC ./qCC/CloudCompare

PCD file to text file

In this pcd2txt.cpp file (Thanks for Gordon), .pcd file can be converted to .txt file or reversally (that means .txt file can be converted to .pcd file too).

#include <string>
#include <iostream>
#include <fstream>

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>

#include <Eigen/Geometry>
#include <Eigen/Core>

void pcd2txt(pcl::PointCloud<pcl::PointXYZI>::Ptr pcdPtr)
{
    /*------------------ output pointcloud xyz as txt ----------------*/
    /*----------------------------------------------------------------*/
    std::ofstream xyz_txt("/home/gordon/feelEnvironment/data/segByCloudCompare/raw_pointcloud/pointcloud_xyz.txt", std::ios::out); 
    for(int i = 0; i < pcdPtr->points.size(); i++)
    {
        xyz_txt << std::fixed << std::setprecision(6) << pcdPtr->points[i].x << ' ' << pcdPtr->points[i].y << ' ' << pcdPtr->points[i].z << std::endl;
    }
    xyz_txt.close();
}


void txt2pcd(pcl::PointCloud<pcl::PointXYZ>::Ptr pcdPtr){
    std::ifstream fin("/home/gordon/feelEnvironment/data/segByCloudCompare/ganjian.txt", std::ios::in);
    int row;
    fin >> row;
    std::cout << "row size = " << row << std::endl;
    
    double temp;
    pcl::PointXYZ point;
    for(int i = 0; i < row; i++){
        fin >> temp;
        point.x = temp;
        
        fin >> temp;
        point.y = temp;
        
        fin >> temp;
        point.z = temp;
        
        pcdPtr->points.push_back(point);
    }
    
    if(row == pcdPtr->size())
        std::cout << "Success!" << std::endl;
    
}

int main (int argc, char** argv)
{
//     pcd to txt
    pcl::PCDReader reader;
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZI>);
    
    std::string fileLocation = "/home/gordon/feelEnvironment/data/segByCloudCompare/raw_pointcloud/1574588098460847.pcd";
    reader.read(fileLocation,*cloud);
    
    std::cout << "ori_pointcloud size = "<< cloud->points.size() << std::endl;
    std::cout << "width = " << cloud->width << "; height = " << cloud->height << std::endl;
    std::cout << "sensor origin : " << cloud->sensor_origin_ << std::endl;
    std::cout << "sensor orientation : " << cloud->sensor_orientation_.coeffs() << std::endl;
    
    pcd2txt(cloud);


    // txt to pcd
    // pcl::PCDWriter writer;
    
    // pcl::PointCloud<pcl::PointXYZ>::Ptr segCloud(new pcl::PointCloud<pcl::PointXYZ>);
    // txt2pcd(segCloud);
    // segCloud->width = segCloud->size();
    // segCloud->height = 1;
    
    // writer.write("/home/gordon/feelEnvironment/data/segByCloudCompare/xyz.pcd", *segCloud);
    

    return 0;
}

The CMakeLists.txt looks like this

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(pcd2txt)

find_package(PCL 1.5 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable(pcd2txt pcd2txt.cpp)
target_link_libraries (pcd2txt ${PCL_LIBRARIES})

NOTE: When saving .txt make sure to check number of points (seperate line)

References:

<span id="ref1">[1]</span> CloudCompare - Open Source project <span id="ref2">[2]</span> Ubuntu18.04 cloudcompare安裝 - 寫東西儀式感極強(其實拖延症晚期晚期)的大齡小白 <span id="ref3">[3]</span> ubuntu - QxcbConnection error - CloudCompare won't launch - Stack Overflow <span id="ref4">[4]</span> Still cannot open PCD files on Linux · Issue #536 · CloudCompare/CloudCompare · GitHub <span id="ref5">[5</span> 通過CloudCompare保存的點雲視點改變致使的問題_旅行在明天以前昨天以後的博客-CSDN博客

相關文章
相關標籤/搜索