Howto Install and Configure PCL on Ubuntu

Source: Internet
Author: User

Howtoinstall and Configure PCL on Ubuntu

Toinstall PCL, just follow official instructions onhttp://pointclouds.org/downloads/linux.html

$sudoadd-apt-repository PPA:V-LAUNCHPAD-JOCHEN-SPRICKERHOF-DE/PCL

$SUDOAPT-get Update

$sudoapt-get Install Libpcl-alls


Touse PCL in your CMake project, just add the following lines to YourCMakeLists.txt:

########################################################

#PCL

Find_package (PCL1.3 REQUIRED)

Include_directories (${pcl_include_dirs})

Link_directories (${pcl_library_dirs})

Add_definitions (${pcl_definitions})

########################################################


Andadd target_link_libraries: ${pcl_libraries}


Formore information to integrate PCL-your CMake project, please refertohttp://pointclouds.org/documentation/tutorials /using_pcl_pcl_config.php.


A complete example of using PCL, VTK and Qt in a CMake project is given here, the source code canbe downloaded at http://d ownload.csdn.net/detail/owldestiny/5268526:


The project structure is:

├──qtvtkpcltest

│├──bin

││└──qtvtkpcltest

│├──build

│├──cmakelists.txt

│├──include

││├──qtvtkpcltest.h

││└──qtvtkpcltest.h~

│├──qrc

│├──src

││├──main.cpp

││├──qtvtkpcltest.cpp

││└──qtvtkpcltest.cpp~

│└──ui

│└──qtvtkpcltest.ui


The CMakeLists.txt is:

========================================================================

Cmake_minimum_required (VERSION2.8)

Project (Qtvtkpcltest)

Set (Cmake_build_type Debug)

########################################################

#Qt

Find_package (Qt4 REQUIRED)

Include (${qt_use_file})

Add_definitions (${qt_definitions})

########################################################

########################################################

#VTK

#set (Vtk_dir "~/downloads/vtk/vtk5.10.1/build")

Set (Vtk_dir "/usr/local/lib/vtk-5.10")

Find_package (VTK REQUIRED)

Include (${vtk_use_file})

#MESSAGE (Status${vtk_libraries})

########################################################

########################################################

#PCL

Find_package (PCL 1.3REQUIRED)

Include_directories (${pcl_include_dirs})

Link_directories (${pcl_library_dirs})

Add_definitions (${pcl_definitions})

########################################################

########################################################

#Project settings

#set (project_sourcesmain.cpp) #all sources files

Set (Library_output_path${project_source_dir}/lib)

Set (Executable_output_path${project_source_dir}/bin)

Include_directories (${project_source_dir}/include${cmake_current_binary_dir}) #to include ui_*.h generated byQT4_ WRAP_UI, you should include ${cmake_current_binary_dir}

Aux_source_directory (${project_source_dir}/src/project_sources)

########################################################

########################################################

#Generate Qt Files

Set (project_headers${project_source_dir}/include/qtvtkpcltest.h) #only HEADERS includeq_object

Qt4_wrap_cpp (Project_headers_moc${project_headers})

Set (project_ui${project_source_dir}/ui/qtvtkpcltest.ui) #ui file

QT4_WRAP_UI (project_ui_uic${project_ui})

#file (COPY ${project_ui_uic}destination ${project_source_dir}/include/) #copy ui_.h file Toinclude

#set (PROJECT_RC${PROJECT_SOURCE_DIR}/QRC) #resource files

#QT4_WRAP_RESOURCES (PROJECT_RC_RCC${PROJECT_RC})

########################################################

########################################################

#generate Executables Andlink Libraries

Add_executable (Qtvtkpcltest${project_sources} ${project_headers_moc} ${project_ui_uic}) #${PROJECT_RC_RCC})

Target_link_libraries (Qtvtkpcltest${qt_libraries} ${vtk_libraries} QVTK ${pcl_libraries}) #QVTKQVTKWidget for VTK in Qt

========================================================================


The Qtvtkpcltest.ui is:

========================================================================

<?xml version= "1.0" encoding= "UTF-8"?> <ui version= "4.0" > <class>MainWindow</class> <
widgetclass= "Qmainwindow" name= "MainWindow" > <propertyname= "Geometry" > <rect> <x>0</x> <y>0</y> <width>720</width>  

========================================================================


The main.cpp is:

========================================================================

#include <QApplication>
#include "QtVtkPCLTest.h"
int main (int argc, char**argv)
{
Qapplication app (ARGC,ARGV);
Qt_qtvtkpcltest qttest;
Qttest.show ();
return app.exec ();
}

========================================================================


The QtVtkPCLTest.h is:

========================================================================

#include <QtGui/QMainWindow>
#include <QString>
#include <QFileDialog>
#include "ui_ QtVtkPCLTest.h "
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/ common/common.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <sensor_msgs/ Pointcloud2.h>
class Qt_qtvtkpcltest:public Qmainwindow
{
q_object public
:
qt_ Qtvtkpcltest ();
Public:
Ui::mainwindow Ui;
Boost::shared_ptr<pcl::visualization::P clvisualizer>m_pclviewer;
SENSOR_MSGS::P ointCloud2::P tr m_pointcloud2;
PCL::P OINTCLOUD<PCL::P ointxyz>::P tr m_pointcloudxyz;
PCL::P OINTCLOUD<PCL::P ointxyzrgba>::P tr M_pointcloudxyzrgba;
PCL::P OINTCLOUD<PCL::P ointxyzrgb>::P tr M_pointcloudxyzrgb;
PCL::P OINTCLOUD<PCL::P ointxyzi>::P tr M_pointcloudxyzi;
Public slots:
void Onloadpcdfile ();

========================================================================


The QtVtkPCLTest.cpp is:

========================================================================

#include "QtVtkPCLTest.h" Qt_qtvtkpcltest::qt_qtvtkpcltest (): M_pclviewer (newpcl::visualization::P Clvisualizer (" Test ", false),//mustset false to hide the PCL window m_pointcloud2 (newsensor_msgs::P ointCloud2 ()), M_POINTCLOUDXYZ ( NEWPCL::P OINTCLOUD&LT;PCL::P ointxyz>), M_pointcloudxyzrgb (NEWPCL::P OINTCLOUD&LT;PCL::P ointxyzrgb>), m_ Pointcloudxyzrgba (NEWPCL::P OINTCLOUD&LT;PCL::P ointxyzrgba>), M_pointcloudxyzi (NEWPCL::P OINTCLOUD&LT;PCL:: pointxyzi>) {ui.setupui (this); M_pclviewer->setbackgroundcolor (0.5,0.5, 0.5); this->ui.qvtkwidgettest-
>setrenderwindow (M_pclviewer->getrenderwindow ());
Connect (this->ui.pushbuttonloadpcd,signal (clicked ()), this, SLOT (Onloadpcdfile ())); } voidqt_qtvtkpcltest::onloadpcdfile () {//load PCD File QString strpath =qfiledialog::getopenfilename (this, tr ("Open
PCD File "),"/data/pcd_files ", tr (" PCD Files (*.PCD) "));
PCL::P Cdreader Reader; if (Reader.read (strpath.tostdstring (), *M_POINTCLOUD2) <0) {this->ui.statusbar->showmessage ("LoaD PCD File Error ");
Return
} std::string strfieldlist= pcl::getfieldslist (*M_POINTCLOUD2);
This->ui.statusbar->showmessage (QString ("PCD file:") +qstring::fromstdstring (strfieldlist));
Display PCD file This->m_pclviewer->removeallpointclouds (); if (Strfieldlist.compare ("X y z RGB") ==0) {pcl::io::loadpcdfile<pcl::P ointxyzrgb> (Strpath.tostdstring (), *m_
POINTCLOUDXYZRGB);
THIS-&GT;M_PCLVIEWER-&GT;ADDPOINTCLOUD&LT;PCL::P ointxyzrgb> (M_POINTCLOUDXYZRGB); } elseif (Strfieldlist.compare ("X y z rgba") ==0) {pcl::io::loadpcdfile<pcl::P ointxyzrgba> (Strpath.tostdstring (
), *m_pointcloudxyzrgba);
THIS-&GT;M_PCLVIEWER-&GT;ADDPOINTCLOUD&LT;PCL::P ointxyzrgba> (M_pointcloudxyzrgba); } elseif (Strfieldlist.compare ("X y z i") ==0) {pcl::io::loadpcdfile<pcl::P ointxyzi> (Strpath.tostdstring (), *m_
Pointcloudxyzi);
THIS-&GT;M_PCLVIEWER-&GT;ADDPOINTCLOUD&LT;PCL::P ointxyzi> (M_pointcloudxyzi); else {pcl::io::loadpcdfile<pcl::P ointxyz> (Strpath.tostdstring (), *m_pointcloudXYZ);
THIS-&GT;M_PCLVIEWER-&GT;ADDPOINTCLOUD&LT;PCL::P ointxyz> (M_POINTCLOUDXYZ);
 }
}


========================================================================




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.