查看: 78|回覆: 0

[Ubuntu] Ubuntu 16.04 install CloudCompare

[複製鏈接]

1

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2008-8-8
發表於 2019-8-30 11:26:00 | 顯示全部樓層 |閲讀模式

One single command should work [1]

snap install cloudcompare

But error occurs:

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 [2]

cloudcompare.ccViewer

or cloudcompare.CloudCompare

Error occurs:

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

Solved by answer [3]

sudo snap install meshlab

Error occurred while loading pcd file

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

Sovled by answer [4]

The stable version of CC can not open pcd file.

Switch it to edge version by

sudo snap refresh --edge cloudcompare

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.

Update: a solution found [5]


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

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:ointCloud<pcl:ointXYZI>:tr pcdPtr)
{
    /*------------------ output pointcloud xyz as txt ----------------*/
    /*----------------------------------------------------------------*/
    std:fstream xyz_txt("/home/gordon/feelEnvironment/data/segByCloudCompare/raw_pointcloud/pointcloud_xyz.txt", std::ios:ut); 
    for(int i = 0; i < pcdPtr->points.size(); i++)
    {
        xyz_txt << std::fixed << std::setprecision(6) << pcdPtr->points.x << ' ' << pcdPtr->points.y << ' ' << pcdPtr->points.z << std::endl;
    }
    xyz_txt.close();
}


void txt2pcd(pcl:ointCloud<pcl:ointXYZ>:tr 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:ointXYZ 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:CDReader reader;
    pcl:ointCloud<pcl:ointXYZI>::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:

[1] CloudCompare - Open Source project
[2] Ubuntu18.04 cloudcompare安装 - 写东西仪式感极强(其实拖延症晚期晚期)的大龄小白
[3] ubuntu - QxcbConnection error - CloudCompare won't launch - Stack Overflow
[4] Still cannot open PCD files on Linux · Issue #536 · CloudCompare/CloudCompare · GitHub
[5 经过CloudCompare保存的点云视点改变导致的问题_旅行在明天之前昨天之后的博客-CSDN博客



来源:https://www.cnblogs.com/linweilin/p/11434056.html
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部