Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CAPE/CAPE/run_cape_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ int main(int argc, char ** argv){
double t2 = cv::getTickCount();
double time_elapsed = (t2-t1)/(double)cv::getTickFrequency();
cout<<"Total time elapsed: "<<time_elapsed<<endl;

std::ofstream ex_time;
ex_time.open ("./output/" + std::to_string(i) + "/" +"ex_time.txt");
ex_time << "Elapsed(ms)=" << time_elapsed << std::endl;
ex_time.close();
/* Uncomment this block to print model params
for(int p_id=0; p_id<nr_planes;p_id++){
cout<<"[Plane #"<<p_id<<"] with ";
Expand Down
10 changes: 9 additions & 1 deletion DDPFF/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iostream>
#include <fstream>
#include <time.h>
#include <sstream>
#include <string>
#include <rep/DDPFF.h>
Expand Down Expand Up @@ -57,8 +58,15 @@ int main() {
auto * depth = new depthBuffer_t();
read_pcd(*points);
ddpff->setBuffers(points, colors, depth);

clock_t start = clock();
ddpff->compute();
clock_t stop = clock();
std::ofstream ex_time;

ex_time.open ("output/ex_time.txt");
ex_time << "Elapsed(ms)=" << (double)(stop - start)/(CLOCKS_PER_SEC/1000) << std::endl;
ex_time.close();

const std::vector<PlanePointNormal> & result = ddpff->getPlanes();
for (const auto& plane : result) {
std::cout << "Plane with " << plane.count << " points detected!" << std::endl;
Expand Down
1 change: 1 addition & 0 deletions DDPFF/scripts/build_cloud_from_planes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@
os.mkdir(folder_path)

np.save(os.path.join(folder_path, "{}.npy".format(filename)), labels)
os.replace("output/ex_time.txt", os.path.join(folder_path,"ex_time.txt"))
o3d.io.write_point_cloud(os.path.join(folder_path, "{}.pcd".format(filename)), pcd)
10 changes: 9 additions & 1 deletion PCL_ConnectedComponents/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <time.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/cloud_viewer.h>
Expand Down Expand Up @@ -52,9 +53,16 @@ int main(int argc, char** argv) {
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud = readPointCloud(pathToRGB.path().string());
ConnectedComponents connectedComponentsAlgorithm(cloud);
std::vector<pcl::PointIndices> clusters;
connectedComponentsAlgorithm.SegmentCloud(clusters);

double comp_time = connectedComponentsAlgorithm.SegmentCloud(clusters);


writeClustersInDataFolder(pathToRGB.path().string(), cloud, clusters);

std::ofstream ex_time;
ex_time.open ("./output/" + getFileName(pathToRGB.path().string()) + "/" +"ex_time.txt");
ex_time << "Elapsed(ms)=" << comp_time << std::endl;
ex_time.close();
}
return 0;
}
2 changes: 2 additions & 0 deletions PCL_ConnectedComponents/scripts/build_colored_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def create_colored_cloud():
rootdir = "./input"

for file in os.listdir(rootdir):
if "ex_time" in file:
continue
file_path = os.path.join(rootdir, file)
npy_path = os.path.join("./output", file[:-4], file[:-4] + ".npy")
labels = np.load(npy_path)
Expand Down
2 changes: 2 additions & 0 deletions PCL_ConnectedComponents/scripts/save_as_npy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def convert_txt_files_to_npy_format():

for subdir, _, files in os.walk(rootdir):
for file in files:
if "ex_time" in file:
continue
file_path = os.path.join(subdir, file)
labels_array = np.loadtxt(file_path).astype(int)

Expand Down
7 changes: 5 additions & 2 deletions PCL_ConnectedComponents/src/ConnectedComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ConnectedComponents::ConnectedComponents(pcl::PointCloud<pcl::PointXYZRGBA>::Con
{
}

void ConnectedComponents::SegmentCloud(std::vector<pcl::PointIndices>& clusters) {
double ConnectedComponents::SegmentCloud(std::vector<pcl::PointIndices>& clusters) {
pcl::PointCloud<pcl::Normal>::Ptr normal_cloud(new pcl::PointCloud<pcl::Normal>);
ne_.setInputCloud(cloud);
ne_.compute(*normal_cloud);
Expand Down Expand Up @@ -37,12 +37,15 @@ void ConnectedComponents::SegmentCloud(std::vector<pcl::PointIndices>& clusters)
pcl::OrganizedConnectedComponentSegmentation<pcl::PointXYZRGBA, pcl::Label> euclidean_segmentation(
euclidean_cluster_comparator_);
euclidean_segmentation.setInputCloud(cloud);
clock_t start = clock();
euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices);

clock_t stop = clock();
for (auto & euclidean_label_indice : euclidean_label_indices) {
if (euclidean_label_indice.indices.size() > 1000) {
clusters.push_back(euclidean_label_indice);
}
}
return (double)(stop - start)/(CLOCKS_PER_SEC/1000);
}
return 0;
}
2 changes: 1 addition & 1 deletion PCL_ConnectedComponents/src/ConnectedComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class ConnectedComponents {

public:
ConnectedComponents(pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloud);
void SegmentCloud(std::vector<pcl::PointIndices>& clusters);
double SegmentCloud(std::vector<pcl::PointIndices>& clusters);
};
10 changes: 9 additions & 1 deletion PCL_RegionGrowing/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <time.h>
#include <vector>
#include <experimental/filesystem>
#include <fstream>
Expand Down Expand Up @@ -56,9 +57,16 @@ int main(int argc, char** argv) {

RegionGrowing regionGrowing;
std::vector<pcl::PointIndices> clusters;
regionGrowing.getClusters(cloud, clusters);

double comp_time = regionGrowing.getClusters(cloud, clusters);


writeClustersInDataFolder(pathToPCD.path().string(), cloud, clusters);

std::ofstream ex_time;
ex_time.open ("./output/" + getFileName(pathToPCD.path().string()) + "/" +"ex_time.txt");
ex_time << "Elapsed(ms)=" << comp_time << std::endl;
ex_time.close();
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions PCL_RegionGrowing/scripts/build_colored_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def create_colored_cloud():
rootdir = "./input"

for file in os.listdir(rootdir):
if "ex_time" in file:
continue
file_path = os.path.join(rootdir, file)
npy_path = os.path.join("./output", file[:-4], file[:-4] + ".npy")
labels = np.load(npy_path)
Expand Down
2 changes: 2 additions & 0 deletions PCL_RegionGrowing/scripts/save_as_npy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def convert_txt_files_to_npy_format():

for subdir, _, files in os.walk(rootdir):
for file in files:
if "ex_time" in file:
continue
file_path = os.path.join(subdir, file)
labels_array = np.loadtxt(file_path).astype(int)

Expand Down
6 changes: 4 additions & 2 deletions PCL_RegionGrowing/src/RegionGrowing.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "RegionGrowing.h"

void RegionGrowing::getClusters(pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud, std::vector<pcl::PointIndices>& clusters) {
double RegionGrowing::getClusters(pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud, std::vector<pcl::PointIndices>& clusters) {
pcl::search::Search<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
pcl::PointCloud <pcl::Normal>::Ptr normals(new pcl::PointCloud <pcl::Normal>);
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimator;
Expand All @@ -23,6 +23,8 @@ void RegionGrowing::getClusters(pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud,

reg.setSmoothnessThreshold(3.0 / 180.0 * M_PI);
reg.setCurvatureThreshold(1.0);

clock_t start = clock();
reg.extract(clusters);
clock_t stop = clock();
return (double)(stop - start)/(CLOCKS_PER_SEC/1000);
}
2 changes: 1 addition & 1 deletion PCL_RegionGrowing/src/RegionGrowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

class RegionGrowing {
public:
void getClusters(pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud, std::vector<pcl::PointIndices>& clusters);
double getClusters(pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloud, std::vector<pcl::PointIndices>& clusters);
};
10 changes: 10 additions & 0 deletions STORM-IRIT/app/pdpcComputeMultiScaleFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <PDPC/ScaleSpace/ScaleSampling.h>
#include <PDPC/MultiScaleFeatures/MultiScaleFeatures.h>
#include <PDPC/RIMLS/RIMLSOperator.h>
#include <fstream>

#include <algorithm>
#include <numeric>
Expand Down Expand Up @@ -40,13 +41,16 @@ int main(int argc, char **argv)
if(!ok) return 1;
const int point_count = points.size();


if(!points.has_normals())
{
error().iff(in_v) << "Normal vectors are required!";
return 1;
}

points.build_kdtree();

clock_t start = clock();

// 1. Scales ---------------------------------------------------------------
info().iff(in_v) << "Computing " << in_scount << " scales";
Expand Down Expand Up @@ -188,6 +192,12 @@ int main(int argc, char **argv)
}
} // for j

clock_t stop = clock();
std::ofstream ex_time;
ex_time.open ("./output/" + in_output + "/" +"ex_time.txt", std::ios_base::app);
ex_time << "Elapsed(m0)=" << (double)(stop - start)/(CLOCKS_PER_SEC/1000) << std::endl;
ex_time.close();

features.save(in_output + "_features.txt");
scales.save( in_output + "_scales.txt");

Expand Down
18 changes: 17 additions & 1 deletion STORM-IRIT/app/pdpcPostProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include <fstream>

using namespace pdpc;
std::string getFileName(std::string const &s) {
char sep = '/';
size_t i = s.rfind(sep, s.length());
if (i != std::string::npos) {
return(s.substr(i+1, s.length() - i - 6));
}
return("");
}

int main(int argc, char **argv)
{
Expand All @@ -30,6 +38,10 @@ int main(int argc, char **argv)
bool ok = opt.ok();
if(!ok) return 1;

std::ofstream ex_time;
std::cout << getFileName(in_output) << std::endl;
ex_time.open("./output/" + getFileName(in_output) + "/" +"ex_time.txt", std::ios_base::app);

PointCloud points;
ok = Loader::Load(in_input, points, in_v);
if(!ok) return 1;
Expand Down Expand Up @@ -57,6 +69,7 @@ int main(int argc, char **argv)
<< " (" << comp_data[i].size() << " pts)";
}
}
clock_t start = clock();

// Persistence range -------------------------------------------------------
if(!in_ranges.empty())
Expand Down Expand Up @@ -184,6 +197,9 @@ int main(int argc, char **argv)
}
}
}

clock_t stop = clock();
std::cout<<"END" << (double)(stop - start)/(CLOCKS_PER_SEC/1000)<<std::endl;
ex_time << "Elapsed(m2)=" << (double)(stop - start)/(CLOCKS_PER_SEC/1000) << std::endl;
ex_time.close();
return 0;
}
9 changes: 8 additions & 1 deletion STORM-IRIT/app/pdpcSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <PDPC/Common/Colors.h>
#include <PDPC/Common/String.h>
#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
Expand Down Expand Up @@ -64,10 +65,11 @@ int main(int argc, char **argv)
const bool in_v = opt.get_bool("verbose", "v").set_default(false).set_brief("Add verbose messages");

const bool in_debug = opt.get_bool("debug").set_default(false).set_brief("Save before/after segmentations as colored ply");

bool ok = opt.ok();
if(!ok) return 1;

std::ofstream ex_time;
ex_time.open ("./output/" + in_output + "/" +"ex_time.txt", std::ios_base::app);
PointCloud points;
ok = Loader::Load(in_input, points, in_v);
if(!ok) return 1;
Expand All @@ -93,6 +95,7 @@ int main(int argc, char **argv)
}

if(in_debug) points.request_colors();
clock_t start = clock();

// 1. Segmentations --------------------------------------------------------
info().iff(in_v) << "Performing " << scale_count << " planar region growing";
Expand Down Expand Up @@ -378,6 +381,10 @@ int main(int argc, char **argv)
}

ComponentDataSet comp_data(comp_set, std::move(reg_set));

clock_t stop = clock();
ex_time << "Elapsed(m1)=" << (double)(stop - start)/(CLOCKS_PER_SEC/1000) << std::endl;
ex_time.close();
comp_data.save(in_output + "_comp.txt");

comp_seg.save(in_output + "_seg.txt");
Expand Down
11 changes: 6 additions & 5 deletions STORM-IRIT/scripts/convert_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import numpy as np

if __name__ == '__main__':
arr = np.loadtxt(sys.argv[1], delimiter="\n")
arr += 1
filename = sys.argv[1].split('.')[0]
np.save(filename + ".npy", arr)
os.remove(sys.argv[1])
if not ("ex_time" in sys.argv[1]):
arr = np.loadtxt(sys.argv[1], delimiter="\n")
arr += 1
filename = sys.argv[1].split('.')[0]
np.save(filename + ".npy", arr)
os.remove(sys.argv[1])
8 changes: 5 additions & 3 deletions STORM-IRIT/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ process(){
./pdpcComputeMultiScaleFeatures -i "${filename}.ply" -v -o $filename
./pdpcSegmentation -i "${filename}.ply" -s "${filename}_scales.txt" -f "${filename}_features.txt" -o $filename -v

./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_range" -col -v -range 20 24 25 30 40 42
# ./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_range" -col -v -range 20 24 25 30 40 42

./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_pers" -col -v -pers 15 20 25
./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_pers" -col -v -pers 15

./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_scales" -col -v -scales 5 15 20 25
# ./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_pers" -col -v -pers 15 20 25

# ./pdpcPostProcess -i "${filename}.ply" -s "${filename}_seg.txt" -c "${filename}_comp.txt" -o $path/"${filename}_scales" -col -v -scales 5 15 20 25

for f in $path/*.ply; do
python3 convert_ply.py $f
Expand Down
9 changes: 9 additions & 0 deletions TAMS/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <time.h>
#include <vector>
#include <experimental/filesystem>
#include <pcl/point_types.h>
Expand Down Expand Up @@ -64,9 +65,17 @@ int main(int argc, char** argv) {
tams::SubwindowRGSegmentation segmentation;
segmentation.setparameters(parameters);
segmentation.setInput(cloud);

clock_t start = clock();
segmentation.preprocessing();
std::vector<std::vector<int>> indices = segmentation.applySegmentation();
clock_t stop = clock();
std::ofstream ex_time;
std::cout << pathToPCD.path().string() << std::endl;
writeClustersInDataFolder(pathToPCD.path().string(), cloud, indices);
ex_time.open ("./output/" + getFileName(pathToPCD.path().string()) + "/" +"ex_time.txt");
ex_time << "Elapsed(ms)=" << (double)(stop - start)/(CLOCKS_PER_SEC/1000) << std::endl;
ex_time.close();
}
return 0;
}
2 changes: 2 additions & 0 deletions TAMS/scripts/build_colored_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def create_colored_cloud():
rootdir = "./input"

for file in os.listdir(rootdir):
if "ex_time" in file:
continue
file_path = os.path.join(rootdir, file)
npy_path = os.path.join("./output", file[:-4], file[:-4] + ".npy")
labels = np.load(npy_path)
Expand Down
4 changes: 4 additions & 0 deletions TAMS/scripts/save_as_npy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from traceback import print_tb
import numpy as np


Expand All @@ -7,6 +8,9 @@ def convert_txt_files_to_npy_format():

for subdir, _, files in os.walk(rootdir):
for file in files:
print(file)
if "ex_time" in file:
continue
file_path = os.path.join(subdir, file)
labels_array = np.loadtxt(file_path).astype(int)

Expand Down
Loading