yuchuli 1 жил өмнө
parent
commit
04de15d0c5

+ 73 - 0
src/tool/bin2pcd/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 49 - 0
src/tool/bin2pcd/bin2pcd.pro

@@ -0,0 +1,49 @@
+QT -= gui
+
+CONFIG += c++14 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+        main.cpp
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+!include(../../../include/ivpcl.pri ) {
+    error( "Couldn't find the ivpcl.pri file!" )
+}
+
+
+LIBS += -lboost_system -lboost_program_options
+
+unix:LIBS +=  -lpcl_common\
+        -lpcl_features\
+        -lpcl_filters\
+        -lpcl_io\
+        -lpcl_io_ply\
+        -lpcl_kdtree\
+        -lpcl_keypoints\
+        -lpcl_octree\
+        -lpcl_outofcore\
+        -lpcl_people\
+        -lpcl_recognition\
+        -lpcl_registration\
+        -lpcl_sample_consensus\
+        -lpcl_search\
+        -lpcl_segmentation\
+        -lpcl_surface\
+        -lpcl_tracking\
+        -lpcl_visualization

+ 82 - 0
src/tool/bin2pcd/main.cpp

@@ -0,0 +1,82 @@
+#include <boost/program_options.hpp>
+#include <pcl/point_types.h>
+#include <pcl/io/pcd_io.h>
+#include <pcl/common/point_operators.h>
+#include <pcl/common/io.h>
+#include <pcl/search/organized.h>
+#include <pcl/search/octree.h>
+#include <pcl/search/kdtree.h>
+#include <pcl/features/normal_3d_omp.h>
+#include <pcl/filters/conditional_removal.h>
+#include <pcl/segmentation/sac_segmentation.h>
+#include <pcl/segmentation/extract_clusters.h>
+#include <pcl/surface/gp3.h>
+#include <pcl/io/vtk_io.h>
+#include <pcl/filters/voxel_grid.h>
+
+#include <iostream>
+#include <fstream>
+
+using namespace pcl;
+using namespace std;
+
+namespace po = boost::program_options;
+//i=1;for x in ./*.bin; do ./build/bin2pcd --infile $x --outfile ./$i.pcd; let i=i+1; done
+int main(int argc, char **argv){
+    ///The file to read from.
+    string infile;
+
+    ///The file to output to.
+    string outfile;
+
+    // Declare the supported options.
+    po::options_description desc("Program options");
+    desc.add_options()
+        //Options
+        ("infile", po::value<string>(&infile)->required(), "the file to read a point cloud from")
+        ("outfile", po::value<string>(&outfile)->required(), "the file to write the DoN point cloud & normals to")
+        ;
+    // Parse the command line
+    po::variables_map vm;
+    po::store(po::parse_command_line(argc, argv, desc), vm);
+
+    // Print help
+    if (vm.count("help"))
+    {
+        cout << desc << "\n";
+        return false;
+    }
+
+    // Process options.
+    po::notify(vm);
+
+    // load point cloud
+    fstream input(infile.c_str(), ios::in | ios::binary);
+    if(!input.good()){
+        cerr << "Could not read file: " << infile << endl;
+        exit(EXIT_FAILURE);
+    }
+    input.seekg(0, ios::beg);
+
+    pcl::PointCloud<PointXYZI>::Ptr points (new pcl::PointCloud<PointXYZI>);
+
+    int i;
+    for (i=0; input.good() && !input.eof(); i++) {
+        PointXYZI point;
+        input.read((char *) &point.x, 3*sizeof(float));
+        input.read((char *) &point.intensity, sizeof(float));
+        points->push_back(point);
+
+        std::cout<<" x: "<<point.x<<" y: "<<point.y<<std::endl;
+    }
+    input.close();
+
+    cout << "Read KTTI point cloud with " << i << " points, writing to " << outfile << endl;
+
+    pcl::PCDWriter writer;
+
+    // Save DoN features
+    writer.write<PointXYZI> (outfile, *points, false);
+}
+
+