From a71553dfb5acbdb44a643264baf64fc3cbce96f2 Mon Sep 17 00:00:00 2001 From: Lev Denisov Date: Wed, 25 Oct 2023 22:00:44 +0300 Subject: [PATCH] feat: changed the way the image is read --- .../python-benchmark/benchmark_process_cloud.py | 10 +++++++--- .../python-benchmark/benchmark_process_sequence.py | 13 ++++++++----- cpp/pybind/utils/utils.cpp | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/benchmark/python-benchmark/benchmark_process_cloud.py b/benchmark/python-benchmark/benchmark_process_cloud.py index db1e1f6..436b4cd 100644 --- a/benchmark/python-benchmark/benchmark_process_cloud.py +++ b/benchmark/python-benchmark/benchmark_process_cloud.py @@ -11,6 +11,7 @@ config_path = data_dir / Path("config") / Path("TUM_fr3_long_val.ini") intrinsics_path = data_dir / Path("config") / Path("intrinsics.K") + def benchmarkProcessCloud(): NUMBER_OF_RUNS = 10 @@ -22,11 +23,13 @@ def benchmarkProcessCloud(): print("Image Height:", image.height, "Image Width:", image.width, '\n') + coarse_algorithm = deplex.PlaneExtractor(image_height=image.height, image_width=image.width, config=config) + for i in range(NUMBER_OF_RUNS): start_time = timeit.default_timer() pcd_points = image.transform_to_pcd(camera_intrinsic) - coarse_algorithm = deplex.PlaneExtractor(image_height=image.height, image_width=image.width, config=config) + labels = coarse_algorithm.process(pcd_points) end_time = timeit.default_timer() @@ -56,7 +59,8 @@ def benchmarkProcessCloud(): print('Elapsed time (ms.) (mean):', f"{elapsed_time_mean:.5f}") print('FPS (max):', f"{1000 / elapsed_time_min:.5f}") print('FPS (min):', f"{1000 / elapsed_time_max:.5f}") - print('FPS (mean):', f"{1000 /elapsed_time_mean:.5f}") + print('FPS (mean):', f"{1000 / elapsed_time_mean:.5f}") + if __name__ == '__main__': - benchmarkProcessCloud() \ No newline at end of file + benchmarkProcessCloud() diff --git a/benchmark/python-benchmark/benchmark_process_sequence.py b/benchmark/python-benchmark/benchmark_process_sequence.py index f706660..7d2b3a2 100644 --- a/benchmark/python-benchmark/benchmark_process_sequence.py +++ b/benchmark/python-benchmark/benchmark_process_sequence.py @@ -12,8 +12,9 @@ config_path = data_dir / Path("config") / Path("TUM_fr3_long_val.ini") intrinsics_path = data_dir / Path("config") / Path("intrinsics.K") + def benchmarkProcessSequence(): - NUMBER_OF_SNAPSHOT = 50 + NUMBER_OF_SNAPSHOT = 1 execution_time = [] @@ -26,12 +27,13 @@ def benchmarkProcessSequence(): print("Image Height:", image.height, "Image Width:", image.width, '\n') + coarse_algorithm = deplex.PlaneExtractor(image_height=image.height, image_width=image.width, config=config) + for i in range(NUMBER_OF_SNAPSHOT): start_time = timeit.default_timer() - image = DepthImage(str(os.path.join(data_dir / Path("depth"), images[i]))) + image.reset(str(os.path.join(data_dir / Path("depth"), images[i]))) pcd_points = image.transform_to_pcd(camera_intrinsic) - coarse_algorithm = deplex.PlaneExtractor(image_height=image.height, image_width=image.width, config=config) labels = coarse_algorithm.process(pcd_points) end_time = timeit.default_timer() @@ -61,7 +63,8 @@ def benchmarkProcessSequence(): print('Elapsed time (ms.) (mean):', f"{elapsed_time_mean:.5f}") print('FPS (max):', f"{1000 / elapsed_time_min:.5f}") print('FPS (min):', f"{1000 / elapsed_time_max:.5f}") - print('FPS (mean):', f"{1000 /elapsed_time_mean:.5f}") + print('FPS (mean):', f"{1000 / elapsed_time_mean:.5f}") + if __name__ == '__main__': - benchmarkProcessSequence() \ No newline at end of file + benchmarkProcessSequence() diff --git a/cpp/pybind/utils/utils.cpp b/cpp/pybind/utils/utils.cpp index 5925b7b..23f9fce 100644 --- a/cpp/pybind/utils/utils.cpp +++ b/cpp/pybind/utils/utils.cpp @@ -31,6 +31,7 @@ void pybind_depth_image(py::module& m) { .def(py::init(), py::arg("image_path")) .def_property_readonly("height", &utils::DepthImage::getHeight) .def_property_readonly("width", &utils::DepthImage::getWidth) - .def("transform_to_pcd", &utils::DepthImage::toPointCloud, py::arg("intrinsics")); + .def("transform_to_pcd", &utils::DepthImage::toPointCloud, py::arg("intrinsics")) + .def("reset", &utils::DepthImage::reset, py::arg("image_path")); } } // namespace deplex \ No newline at end of file