Created
February 6, 2017 03:53
-
-
Save Tmbao/ba7b03f3354d90f41ebcddedd1b2484f to your computer and use it in GitHub Desktop.
FPFH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // main.cpp | |
| // FPFHExtractor | |
| // | |
| // Created by Bao Truong on 2/5/17. | |
| // Copyright © 2017 Bao Truong. All rights reserved. | |
| // | |
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| #include <pcl/point_types.h> | |
| #include <pcl/features/fpfh.h> | |
| #include <pcl/io/obj_io.h> | |
| using namespace pcl; | |
| int main(int argc, const char * argv[]) { | |
| cerr << "Reading " + string(argv[1]) << endl; | |
| PointCloud<PointXYZ>::Ptr cloud(new PointCloud<PointXYZ>()); | |
| io::loadOBJFile(argv[1], *cloud); | |
| cerr << "Cloud point's size: " << cloud->points.size() << endl; | |
| PointCloud<PointNormal>::Ptr object(new PointCloud<PointNormal>()); | |
| copyPointCloud(*cloud, *object); | |
| double feature_radius_ = 10; | |
| pcl::FPFHEstimation<pcl::PointNormal, pcl::PointNormal, pcl::FPFHSignature33> fest; | |
| pcl::PointCloud<pcl::FPFHSignature33>::Ptr object_features(new pcl::PointCloud<pcl::FPFHSignature33>()); | |
| fest.setRadiusSearch(feature_radius_); | |
| fest.setInputCloud(object); | |
| fest.setInputNormals(object); | |
| fest.compute(*object_features); | |
| FILE* fid = fopen(argv[2], "wb"); | |
| int nV = object->size(), nDim = 33; | |
| fwrite(&nV, sizeof(int), 1, fid); | |
| fwrite(&nDim, sizeof(int), 1, fid); | |
| for (int v = 0; v < nV; v++) { | |
| const pcl::PointNormal &pt = object->points[v]; | |
| float xyz[3] = {pt.x, pt.y, pt.z}; | |
| fwrite(xyz, sizeof(float), 3, fid); | |
| const pcl::FPFHSignature33 &feature = object_features->points[v]; | |
| fwrite(feature.histogram, sizeof(float), 33, fid); | |
| } | |
| fclose(fid); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment