Skip to content

Commit

Permalink
Implemented descriptor evaluation app
Browse files Browse the repository at this point in the history
  • Loading branch information
rodschulz committed Nov 3, 2016
1 parent 7bdae38 commit 822a52c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 135 deletions.
21 changes: 0 additions & 21 deletions config/config_descriptor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ normalEstimationRadius: -1
# calculation cache directory
cacheLocation: ../cache/

##### kmeans class debug params #####
# kmeans:
# debugAlgorithm: false
# debugMetric: false
# centerTitles: false
# dataTitles: false
# identityTitle: false
# displayFactor: 0.2
# display: centroid # centroid or center

##### descriptor calculation params #####
descriptor:
patchSize: 0.02
Expand All @@ -28,17 +18,6 @@ descriptor:
sequenceBin: 0.005
sequenceStat: mean # mean or median

##### clustering params #####
# clustering:
# implementation: kmeans # opencv, kmeans, kmedoids or stochastic
# metric: [closest, conf] # metric and args (euclidean, closest or closest_with_confidence)
# clusterNumber: 50
# maxIterations: 200
# stopThreshold: 0.0001
# attempts: 3
# generateElbowCurve: false
# generateDistanceMatrix: false

##### cloud smoothing params #####
cloudSmoothing:
useSmoothing: true
Expand Down
1 change: 0 additions & 1 deletion src/CloudLabeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "MetricFactory.hpp"
#include "Loader.hpp"
#include "Writer.hpp"
#include "ClusteringUtils.hpp"
#include <pcl/io/pcd_io.h>


Expand Down
2 changes: 2 additions & 0 deletions src/DenseEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include "Writer.hpp"
#include "Clustering.hpp"


#define CONFIG_LOCATION "config/config_dense_evaluator.yaml"


int main(int _argn, char **_argv)
{
// Get the current exec directory
Expand Down
125 changes: 12 additions & 113 deletions src/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
#include <iostream>
#include <iomanip>
#include <string>
// #include <opencv2/core/core.hpp>
// #include <pcl/io/pcd_io.h>
// #include "Clustering.hpp"
// #include "KMeans.hpp"
// #include "MetricFactory.hpp"
#include "Calculator.hpp"
// #include "Extractor.hpp"
// #include "Hist.hpp"
#include "CloudFactory.hpp"
#include "Loader.hpp"
// #include "Writer.hpp"
#include "Writer.hpp"
#include "Config.hpp"
// #include "CloudUtils.hpp"


#define CONFIG_LOCATION "./config/config.yaml"
#define CONFIG_LOCATION "config/config_descriptor.yaml"


void genPointCloud(pcl::PointCloud<pcl::PointNormal>::Ptr &cloud_, const SynCloudType cloudType_)
Expand Down Expand Up @@ -100,12 +92,19 @@ int main(int _argn, char **_argv)
throw std::runtime_error("Can't load cloud at " + workingDir + cloudFilename);
}



// Evaluate the descriptor around the target point
std::cout << "...calculating descriptor" << std::endl;
int targetPoint = Config::getTargetPoint();
DescriptorParams descriptorParams = Config::getDescriptorParams();
Descriptor descriptor = Calculator::calculateDescriptor(cloud, descriptorParams, Config::getTargetPoint());
Descriptor descriptor = Calculator::calculateDescriptor(cloud, descriptorParams, targetPoint);

// Generate histograms
std::cout << "...generating histograms" << std::endl;
std::vector<Hist> histograms = Calculator::generateAngleHistograms(descriptor, descriptorParams.useProjection);

// Write output
std::cout << "...writing output" << std::endl;
Writer::writeOuputData(cloud, descriptor, histograms, descriptorParams, targetPoint);


}
Expand All @@ -119,104 +118,4 @@ int main(int _argn, char **_argv)
std::cout << std::fixed << std::setprecision(3) << "Finished in " << elapsedTime << " [s]\n";

return EXIT_SUCCESS;



// try
// {
// if (system("rm -rf ./output/*") != 0)
// std::cout << "WARNING: can't clean output folder\n";
//
// std::cout << "Loading configuration file\n";
// if (!Config::load(CONFIG_LOCATION))
// throw std::runtime_error("Problem reading configuration file at " CONFIG_LOCATION);
// ExecutionParams params = Config::getExecutionParams();
//
// // Check if enough params were given
// if (_argn < 2 && !params.useSynthetic)
// throw std::runtime_error("Not enough exec params given\nUsage: Descriptor <input_file>");
//
// if (!params.useSynthetic)
// params.inputLocation = _argv[1];
//
// // Do things according to the execution type
// if (params.executionType == EXECUTION_METRIC)
// Metric::evaluateMetricCases("./output/metricEvaluation", params.inputLocation, params.targetMetric, params.metricArgs);
// else
// {
// // Load cloud
// pcl::PointCloud<pcl::PointNormal>::Ptr cloud(new pcl::PointCloud<pcl::PointNormal>());
// if (!getPointCloud(cloud, params))
// throw std::runtime_error("Can't load cloud");
//
// // Select execution type
// if (params.executionType == EXECUTION_DESCRIPTOR)
// {
// std::cout << "...Execution for descriptor calculation\n";
//
// std::cout << "Target point: " << params.targetPoint << "\n";
// Descriptor descriptor = Calculator::calculateDescriptor(cloud, params);
//
// // Calculate histograms
// std::cout << "Generating histograms\n";
// std::vector<Hist> histograms = Calculator::generateAngleHistograms(descriptor, params.useProjection);
//
// // Write output
// std::cout << "Writing output\n";
// Writer::writeOuputData(cloud, descriptor, histograms, params);
// }
// else if (params.executionType == EXECUTION_CLUSTERING)
// {
// std::cout << "...Execution for clustering\n";
//
// cv::Mat descriptors;
// if (!Loader::loadDescriptors(descriptors, params))
// {
// std::cout << "Cache not found, calculating descriptors\n";
// Calculator::calculateDescriptors(cloud, params, descriptors);
// Writer::writeDescriptorsCache(descriptors, params);
// }
//
// ClusteringResults results;
// MetricPtr metric = MetricFactory::createMetric(params.metric, params.getSequenceLength(), params.useConfidence);
// if (!params.labelData)
// {
// Clustering::searchClusters(descriptors, params, results);
//
// std::cout << "Generating SSE plot" << std::endl;
// Writer::writePlotSSE("sse", "SSE Evolution", results.errorEvolution);
// }
// else
// {
// std::cout << "Loading centers" << std::endl;
//
// if (!Loader::loadCenters(params.centersLocation, results.centers))
// throw std::runtime_error("Can't load clusters centers");
//
// Clustering::labelData(descriptors, results.centers, params, results.labels);
// }
//
// // Generate outputs
// std::cout << "Writing outputs" << std::endl;
// pcl::io::savePCDFileASCII("./output/visualization.pcd", *Clustering::generateClusterRepresentation(cloud, results.labels, results.centers, params));
// Writer::writeClusteredCloud("./output/clusters.pcd", cloud, results.labels);
// Writer::writeClustersCenters("./output/", results.centers);
//
// if (params.genDistanceMatrix)
// Writer::writeDistanceMatrix("./output/", descriptors, results.centers, results.labels, metric);
// if (params.genElbowCurve)
// Clustering::generateElbowGraph(descriptors, params);
// }
// }
// }
// catch (std::exception &_ex)
// {
// std::cout << "ERROR: " << _ex.what() << std::endl;
// }

// clock_t end = clock();
// double elapsedTime = double(end - begin) / CLOCKS_PER_SEC;

// std::cout << std::fixed << std::setprecision(3) << "Finished in " << elapsedTime << " [s]\n";
// return EXIT_SUCCESS;
}

0 comments on commit 822a52c

Please sign in to comment.