Pcl+qt+vs Visual Point Cloud

Source: Internet
Author: User
Tags qt designer

Objective

The Point Cloud Library (PCL) is a powerful, open-source C + + library that will help us greatly in the field of LIDAR data processing if a good PCL can be used. LiDAR technology after several decades of development, at home and abroad on the LiDAR point cloud data processing has been very rich, but there are still hardware development speed is greater than the speed of software development. The PCL algorithm is based on the selfless contribution of many researchers and program enthusiasts to today's powerful PCL.

Blog post, I'll make a visual point cloud program for how to combine PCL and QT libraries. This part of the PCL website has a few examples and can be used very well, and the UI is completely code design, which will help to learn QT, but for the lack of any QT foundation and want to get started by the students will inevitably have a certain degree of difficulty.

Here's a complete introduction to how to use the QT library, the QT designer UI, and the PCL-based read and display point cloud.

Pcl+qt+vs installation Configuration

My blog is involved, if you have not installed the configuration can be consulted.
The following new project is prompted to configure the PCL.

Create new projects and write related code
    1. Create a new Qtapplication project in VS
    2. Add a qvtkwidget part to the main window
    3. Add the File menu and open action to the UI and compile
Add code to read the PCD file

Directly below the file and source files
1. Pclvisualizer.h

#ifndefPclvisualizer_h#definePclvisualizer_h#include <Qtgui/qmainwindow>#include <Pcl/io/pcd_io.H>#include <Pcl/point_types.H>#include <Pcl/visualization/pcl_visualizer.H>#include "Ui_pclvisualizer.h"Class Pclvisualizer: Publicqmainwindow{Q_object Public: Pclvisualizer (Qwidget*Parent = 0Qt:: Wflagsflog== 0); ~pclvisualizer ();Private: Ui::P clvisualizerclassUi//Point cloud data storagePcl::P ointcloud<Pcl::P ointxyz>::P TRCloud Boost:: shared_ptr<Pcl:: Visualization::P clvisualizer>Viewer//Initialize VTK parts    voidInitialvtkwidget ();PrivateSlots//Create open Slots    voidOnOpen (); };#endif //Pclvisualizer_h
    1. Pclvisualizer.cpp
#include <QFileDialog>#include <iostream>#include "pclvisualizer.h"Pclvisualizer::P clvisualizer (qwidget *parent, Qt::wflags flags): Qmainwindow (parent, flags) {UI.SETUPUI ( This);//InitializeInitialvtkwidget ();//Connect signals and SlotsConnect (ui.actionopen,signal (triggered)), This, SLOT (OnOpen ()));} Pclvisualizer::~pclvisualizer () {}//voidPclvisualizer::initialvtkwidget () {Cloud.reset (NewPCL::P OINTCLOUD&LT;PCL::P ointxyz>); Viewer.reset (NewPcl::visualization::P Clvisualizer ("Viewer",false)); Viewer->addpointcloud (Cloud,"Cloud");    Ui.qvtkwidget->setrenderwindow (Viewer->getrenderwindow ());    Viewer->setupinteractor (Ui.qvtkwidget->getinteractor (), Ui.qvtkwidget->getrenderwindow ());   Ui.qvtkwidget->update (); }//Read text-type and binary-point cloud datavoidPclvisualizer::onopen () {//can only open PCD fileQString fileName = Qfiledialog::getopenfilename ( This, TR ("Open Pointcloud"),".", TR ("Open PCD files (*.pcd)"));if(!filename.isempty ()) {STD::stringFile_name=filename.tostdstring (); SENSOR_MSGS::P ointCloud2 cloud2;//PCL::P ointcloud<eigen::matrixxf> cloud2;eigen::vector4f origin; eigen::quaternionf orientation;intPcd_version;intData_type;unsigned intData_idx;intoffset =0;        PCL::P Cdreader Rd; Rd.readheader (FILE_NAME,CLOUD2,ORIGIN,ORIENTATION,PCD_VERSION,DATA_TYPE,DATA_IDX);if(data_type==0) {Pcl::io::loadpcdfile (filename.tostdstring (), *cloud); }Else if(data_type==2) {PCL::P Cdreader Reader;        READER.READ&LT;PCL::P ointxyz> (Filename.tostdstring (), *cloud); } Viewer->updatepointcloud (Cloud,"Cloud");        Viewer->resetcamera ();    Ui.qvtkwidget->update (); }   }
    1. After recompiling select the PCD file to open

      Show effect
Official Example compilation

The official example is to build a VS project under CMake and then compile with vs. Now I will officially give the first pclvisualizer in Qt with CMake, directly build with VS, and upload the complete project to Baidu Cloud disk, if necessary can be downloaded.

More complex examples

This software is based on QT, PCL, VTK, GDAL, Laslib, libLAS, Tiff, GeoTiff, OPENCV and other library development, is a summary of the author's study of LiDAR learning. If you earn a mentor in the future, you will gradually share some algorithms in the form of blog posts.

Pcl+qt+vs Visual Point Cloud

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.