├── .clang-format ├── .dockerignore ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTORS ├── LICENSE ├── Makefile ├── README.md ├── _config.yml ├── benchmarks ├── CMakeLists.txt └── benchmarks.json ├── cmake_modules ├── CUDACheckCompute.cmake ├── FindBrisk.cmake ├── FindCVD.cmake ├── FindCeres.cmake ├── FindEigen.cmake ├── FindEigen3.cmake ├── FindFreeImage.cmake ├── FindG2O.cmake ├── FindGVARS.cmake ├── FindGlog.cmake ├── FindLIBYAML.cmake ├── FindOpenCL.cmake ├── FindOpenNI.cmake ├── FindOpenNI2.cmake ├── FindPAPI.cmake ├── FindSLAMBENCH.cmake ├── FindSuiteSparse.cmake ├── FindTooN.cmake └── cuda_compute_capability.c ├── datasets ├── README.md └── datasets.repos ├── docker ├── Makefile ├── cuda-ubuntu-16.04.docker ├── fastCI.docker ├── fedora-24.docker ├── fedora-25.docker ├── fedora-26.docker ├── github.docker ├── run_cuda.sh ├── travis-deps.docker ├── ubuntu-14.04-bitbucket.docker ├── ubuntu-14.04-deps.docker ├── ubuntu-14.04.docker ├── ubuntu-16.04.docker └── ubuntu-16.10.docker ├── framework ├── CMakeLists.txt ├── makefiles │ ├── README.md │ ├── brisk.make │ ├── ceres.make │ ├── cvd.make │ ├── dataset-utils.makefile │ ├── deps.makefile │ ├── download_benchmarks.py │ ├── download_datasets.py │ ├── eigen3.make │ ├── flann.make │ ├── freeimage.make │ ├── g2o.make │ ├── gcc.make │ ├── gvars.make │ ├── libopencl-stub.make │ ├── opencv.make │ ├── opengv.make │ ├── openni.make │ ├── opentuner.make │ ├── pangolin.make │ ├── pcl.make │ ├── sophus.make │ ├── suitesparse.make │ └── toon.make ├── patchs │ ├── OpenNI2_SLAMBench.patch │ ├── OpenNI_SLAMBench.patch │ ├── SensorKinect_SLAMBench.patch │ ├── freeimage.patch │ └── libopencl-stub_SLAMBench.patch ├── shared │ ├── CMakeLists.txt │ ├── include │ │ ├── ColumnWriter.h │ │ ├── ParameterComponent.h │ │ ├── ParameterManager.h │ │ ├── Parameters.h │ │ ├── ResultWriter.h │ │ ├── SLAMBenchAPI.h │ │ ├── SLAMBenchConfiguration.h │ │ ├── SLAMBenchException.h │ │ ├── SLAMBenchLibraryHelper.h │ │ ├── SLAMBenchUI.h │ │ ├── SLAMBenchUI_Pangolin.h │ │ ├── TimeStamp.h │ │ ├── io │ │ │ ├── Event.h │ │ │ ├── FrameBuffer.h │ │ │ ├── FrameBufferSource.h │ │ │ ├── FrameFormat.h │ │ │ ├── FrameSource.h │ │ │ ├── InputInterface.h │ │ │ ├── InputInterfaceManager.h │ │ │ ├── PixelFormat.h │ │ │ ├── SLAMFile.h │ │ │ ├── SLAMFrame.h │ │ │ ├── SensorType.h │ │ │ ├── core │ │ │ │ └── Core.h │ │ │ ├── deserialisation │ │ │ │ ├── Deserialiser.h │ │ │ │ ├── SLAMFileDeserialiser.h │ │ │ │ ├── SLAMFileHeaderDeserialiser.h │ │ │ │ ├── SLAMFrameDeserialiser.h │ │ │ │ └── SensorCollectionDeserialiser.h │ │ │ ├── format │ │ │ │ ├── DataFormatter.h │ │ │ │ ├── EventDataFormatter.h │ │ │ │ ├── ImageDataFormatter.h │ │ │ │ └── PointCloud.h │ │ │ ├── openni15 │ │ │ │ ├── ONI15Frame.h │ │ │ │ ├── ONI15FrameStream.h │ │ │ │ └── ONI15InputInterface.h │ │ │ ├── openni2 │ │ │ │ ├── ONI2Frame.h │ │ │ │ ├── ONI2FrameStream.h │ │ │ │ └── ONI2InputInterface.h │ │ │ ├── realsense │ │ │ │ ├── RealSense2Frame.h │ │ │ │ ├── RealSense2FrameStream.h │ │ │ │ └── RealSense2InputInterface.h │ │ │ ├── sensor │ │ │ │ ├── AccelerometerSensor.h │ │ │ │ ├── CameraSensor.h │ │ │ │ ├── CameraSensorFinder.h │ │ │ │ ├── DepthSensor.h │ │ │ │ ├── EventCameraSensor.h │ │ │ │ ├── GroundTruthSensor.h │ │ │ │ ├── GyroSensor.h │ │ │ │ ├── IMUSensor.h │ │ │ │ ├── OdomSensor.h │ │ │ │ ├── PointCloudSensor.h │ │ │ │ ├── Sensor.h │ │ │ │ ├── SensorCollection.h │ │ │ │ ├── SensorDatabase.h │ │ │ │ └── sensor_builder.h │ │ │ └── serialisation │ │ │ │ ├── SLAMFileHeaderSerialiser.h │ │ │ │ ├── SLAMFileSerialiser.h │ │ │ │ ├── SLAMFrameSerialiser.h │ │ │ │ └── Serialiser.h │ │ ├── lodepng.h │ │ ├── math_types.h │ │ ├── metrics │ │ │ ├── ATEMetric.h │ │ │ ├── DepthEstimationMetric.h │ │ │ ├── DurationMetric.h │ │ │ ├── FrameData.h │ │ │ ├── MemoryMetric.h │ │ │ ├── Metric.h │ │ │ ├── MetricManager.h │ │ │ ├── MetricValue.h │ │ │ ├── Phase.h │ │ │ ├── PointCloudMetric.h │ │ │ ├── PowerMetric.h │ │ │ ├── RPEMetric.h │ │ │ ├── memory_utils │ │ │ │ └── CUDAMonitor.h │ │ │ └── power_utils │ │ │ │ ├── PAPIMonitor.h │ │ │ │ ├── PowerMonitor.h │ │ │ │ └── XU3Monitor.h │ │ ├── outputs │ │ │ ├── Output.h │ │ │ ├── OutputManager.h │ │ │ ├── OutputManagerWriter.h │ │ │ ├── PoseOutput.h │ │ │ ├── TrajectoryAlignmentMethod.h │ │ │ └── TrajectoryInterface.h │ │ ├── sb_malloc.h │ │ ├── sysutils.h │ │ ├── timings.h │ │ ├── utils.h │ │ └── values │ │ │ ├── Value.h │ │ │ ├── ValueDispatch.h │ │ │ ├── ValueInterface.h │ │ │ └── ValuePrinter.h │ └── src │ │ ├── ColumnWriter.cpp │ │ ├── ParameterComponent.cpp │ │ ├── ParameterManager.cpp │ │ ├── ResultWriter.cpp │ │ ├── SLAMBenchConfiguration.cpp │ │ ├── SLAMBenchUI_Pangolin.cpp │ │ ├── dummy_library.cpp │ │ ├── io │ │ ├── FrameBuffer.cpp │ │ ├── FrameBufferSource.cpp │ │ ├── FrameFormat.cpp │ │ ├── FrameSource.cpp │ │ ├── InputInterface.cpp │ │ ├── InputInterfaceManager.cpp │ │ ├── PixelFormat.cpp │ │ ├── SLAMFile.cpp │ │ ├── SLAMFrame.cpp │ │ ├── core │ │ │ └── Core.cpp │ │ ├── deserialisation │ │ │ ├── Deserialiser.cpp │ │ │ ├── SLAMFileDeserialiser.cpp │ │ │ ├── SLAMFileHeaderDeserialiser.cpp │ │ │ ├── SLAMFrameDeserialiser.cpp │ │ │ └── SensorCollectionDeserialiser.cpp │ │ ├── format │ │ │ ├── DataFormatter.cpp │ │ │ └── PointCloud.cpp │ │ ├── openni │ │ │ ├── ONI2Frame.cpp │ │ │ ├── ONI2FrameStream.cpp │ │ │ └── ONI2InputInterface.cpp │ │ ├── openni15 │ │ │ ├── ONI15Frame.cpp │ │ │ ├── ONI15FrameStream.cpp │ │ │ └── ONI15InputInterface.cpp │ │ ├── realsense │ │ │ ├── RealSense2Frame.cpp │ │ │ ├── RealSense2FrameStream.cpp │ │ │ └── RealSense2InputInterface.cpp │ │ ├── sensor │ │ │ ├── AccelerometerSensor.cpp │ │ │ ├── CameraSensor.cpp │ │ │ ├── CameraSensorFinder.cpp │ │ │ ├── DepthSensor.cpp │ │ │ ├── EventCameraSensor.cpp │ │ │ ├── GroundTruthSensor.cpp │ │ │ ├── GyroSensor.cpp │ │ │ ├── IMUSensor.cpp │ │ │ ├── OdomSensor.cpp │ │ │ ├── PointCloudSensor.cpp │ │ │ ├── Sensor.cpp │ │ │ ├── SensorCollection.cpp │ │ │ └── SensorDatabase.cpp │ │ └── serialisation │ │ │ ├── SLAMFileHeaderSerialiser.cpp │ │ │ ├── SLAMFileSerialiser.cpp │ │ │ ├── SLAMFrameSerialiser.cpp │ │ │ └── Serialiser.cpp │ │ ├── library_wrapper.cpp │ │ ├── lodepng.cpp │ │ ├── metrics │ │ ├── ATEMetric.cpp │ │ ├── DepthEstimationMetric.cpp │ │ ├── DurationMetric.cpp │ │ ├── MemoryMetric.cpp │ │ ├── Metric.cpp │ │ ├── MetricManager.cpp │ │ ├── Phase.cpp │ │ ├── PointCloudMetric.cpp │ │ ├── PowerMetric.cpp │ │ ├── RPEMetric.cpp │ │ ├── memory_utils │ │ │ └── CUDAMonitor.cpp │ │ └── power_utils │ │ │ ├── PAPIMonitor.cpp │ │ │ └── XU3Monitor.cpp │ │ ├── outputs │ │ ├── Output.cpp │ │ ├── OutputManager.cpp │ │ ├── OutputManagerWriter.cpp │ │ ├── TrajectoryAlignmentMethod.cpp │ │ └── TrajectoryInterface.cpp │ │ ├── sb_malloc.cpp │ │ └── values │ │ ├── Value.cpp │ │ ├── ValueDispatch.cpp │ │ ├── ValueInterface.cpp │ │ └── ValuePrinter.cpp └── tools │ ├── CMakeLists.txt │ ├── README.md │ ├── accuracy-tools │ ├── CMakeLists.txt │ └── pointcloud_aligner.cpp │ ├── dataset-tools │ ├── BONN.cpp │ ├── CMakeLists.txt │ ├── ETHI.cpp │ ├── EUROCMAV.cpp │ ├── ICL.cpp │ ├── ICLNUIM.cpp │ ├── OpenLORIS.cpp │ ├── SVO.cpp │ ├── TUM-ROSBAG.cpp │ ├── TUM.cpp │ ├── UZHFPV.cpp │ ├── VolumeDeform.cpp │ ├── dataset-generator.cpp │ ├── include │ │ ├── BONN.h │ │ ├── DatasetReader.h │ │ ├── ETHI.h │ │ ├── EUROCMAV.h │ │ ├── ICL.h │ │ ├── ICLNUIM.h │ │ ├── OpenLORIS.h │ │ ├── SVO.h │ │ ├── TUM.h │ │ ├── UZHFPV.h │ │ ├── VolumeDeform.h │ │ └── utils │ │ │ ├── PlyASCIIReader.h │ │ │ ├── RegexPattern.h │ │ │ ├── dataset_utils.h │ │ │ └── tinyply.h │ ├── io-inspect.cpp │ ├── io-monoslam.cpp │ ├── io-readply.cpp │ ├── lodepng.cpp │ └── lodepng.h │ ├── loaders │ ├── CMakeLists.txt │ ├── benchmark_loader.cpp │ ├── pangolin_loader.cpp │ └── slambench_app.cpp │ └── profiling-tools │ ├── CMakeLists.txt │ └── OCLWrapper.cpp ├── icra2018_results ├── 1080 │ ├── memory_efusion_living_room_traj2_loop.log │ ├── memory_infinitam_living_room_traj2_loop.log │ ├── memory_kfusion_living_room_traj2_loop.log │ ├── memory_lsdslam_living_room_traj2_loop.log │ ├── memory_orbslam2_living_room_traj2_loop.log │ ├── violons_libefusion-cuda_living_room_traj0_loop.log │ ├── violons_libefusion-cuda_living_room_traj1_loop.log │ ├── violons_libefusion-cuda_living_room_traj2_loop.log │ ├── violons_libefusion-cuda_living_room_traj3_loop.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libinfinitam-cpp_living_room_traj0_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj1_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj2_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj3_loop.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libinfinitam-cuda_living_room_traj0_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj1_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj2_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj3_loop.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libkfusion-cpp_living_room_traj0_loop.log │ ├── violons_libkfusion-cpp_living_room_traj1_loop.log │ ├── violons_libkfusion-cpp_living_room_traj2_loop.log │ ├── violons_libkfusion-cpp_living_room_traj3_loop.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libkfusion-cuda_living_room_traj0_loop.log │ ├── violons_libkfusion-cuda_living_room_traj1_loop.log │ ├── violons_libkfusion-cuda_living_room_traj2_loop.log │ ├── violons_libkfusion-cuda_living_room_traj3_loop.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_liblsdslam-cpp_living_room_traj0_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj1_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj2_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj3_loop.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_liborbslam2-original_living_room_traj0_loop.log │ ├── violons_liborbslam2-original_living_room_traj1_loop.log │ ├── violons_liborbslam2-original_living_room_traj2_loop.log │ ├── violons_liborbslam2-original_living_room_traj3_loop.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg1_rpy.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg1_xyz.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg2_rpy.log │ └── violons_liborbslam2-original_rgbd_dataset_freiburg2_xyz.log ├── Makefile ├── paper_run.sh ├── plotutils.py ├── slamlog.py ├── tegra │ ├── memory_efusion_living_room_traj2_loop.log │ ├── memory_infinitam_living_room_traj2_loop.log │ ├── memory_kfusion_living_room_traj2_loop.log │ ├── memory_lsdslam_living_room_traj2_loop.log │ ├── memory_orbslam2_living_room_traj2_loop.log │ ├── violons_libefusion-cuda_living_room_traj0_loop.log │ ├── violons_libefusion-cuda_living_room_traj1_loop.log │ ├── violons_libefusion-cuda_living_room_traj2_loop.log │ ├── violons_libefusion-cuda_living_room_traj3_loop.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libefusion-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libinfinitam-cpp_living_room_traj0_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj1_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj2_loop.log │ ├── violons_libinfinitam-cpp_living_room_traj3_loop.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libinfinitam-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libinfinitam-cuda_living_room_traj0_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj1_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj2_loop.log │ ├── violons_libinfinitam-cuda_living_room_traj3_loop.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libinfinitam-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libkfusion-cpp_living_room_traj0_loop.log │ ├── violons_libkfusion-cpp_living_room_traj1_loop.log │ ├── violons_libkfusion-cpp_living_room_traj2_loop.log │ ├── violons_libkfusion-cpp_living_room_traj3_loop.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libkfusion-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_libkfusion-cuda_living_room_traj0_loop.log │ ├── violons_libkfusion-cuda_living_room_traj1_loop.log │ ├── violons_libkfusion-cuda_living_room_traj2_loop.log │ ├── violons_libkfusion-cuda_living_room_traj3_loop.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg1_rpy.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg1_xyz.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg2_rpy.log │ ├── violons_libkfusion-cuda_rgbd_dataset_freiburg2_xyz.log │ ├── violons_liblsdslam-cpp_living_room_traj0_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj1_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj2_loop.log │ ├── violons_liblsdslam-cpp_living_room_traj3_loop.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg1_rpy.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg1_xyz.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg2_rpy.log │ ├── violons_liblsdslam-cpp_rgbd_dataset_freiburg2_xyz.log │ ├── violons_liborbslam2-original_living_room_traj0_loop.log │ ├── violons_liborbslam2-original_living_room_traj1_loop.log │ ├── violons_liborbslam2-original_living_room_traj2_loop.log │ ├── violons_liborbslam2-original_living_room_traj3_loop.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg1_rpy.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg1_xyz.log │ ├── violons_liborbslam2-original_rgbd_dataset_freiburg2_rpy.log │ └── violons_liborbslam2-original_rgbd_dataset_freiburg2_xyz.log ├── utils.py └── violins.py └── scripts ├── evaluate.py └── tum_evaluate_tools ├── __init__.py ├── associate.py └── evaluate_ate.py /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Google 3 | NamespaceIndentation: All 4 | ColumnLimit: 120 5 | IndentWidth: 4 6 | ... 7 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | docker/ 2 | bitbucket-pipelines.yml 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Docker files 2 | /docker/tmp 3 | /docker/nvidia-driver.run 4 | docker/workspace/ 5 | framework/makefiles/benchmarks.makefile 6 | framework/makefiles/datasets.makefile 7 | # Build files 8 | /build/ 9 | /install/ 10 | /android-build/ 11 | 12 | # Eclipse and other IDE files 13 | .cproject 14 | .project 15 | .settings/ 16 | .idea 17 | .pydevproject 18 | *~ 19 | 20 | # Python 21 | *.pyc 22 | 23 | # Dependencies 24 | /deps 25 | /android-deps/ 26 | 27 | 28 | # Ignore benchmarks folders 29 | benchmarks/* 30 | !benchmarks/CMakeLists.txt 31 | 32 | 33 | # DSE Files 34 | /opentuner.db/ 35 | 36 | # Paper results 37 | paper/*.aux 38 | paper/*.pdf 39 | paper/*.tex 40 | 41 | 42 | # Datasets 43 | 44 | /datasets 45 | /iros2020_results_backup 46 | /iros2020_results 47 | !/datasets/README.md 48 | !/datasets/datasets.repos 49 | 50 | # macOS 51 | .DS_Store 52 | 53 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: trusty 3 | sudo: required 4 | 5 | services: 6 | - docker 7 | 8 | 9 | script: 10 | - make -C docker github-docker-image 11 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | - Bodin Bruno 2 | - Mawer John 3 | - Melot Nicolas 4 | - Moldovan Adrian 5 | - Nardi Luigi 6 | - Nisbet Andy 7 | - Saeedi Sajad 8 | - Vespa Emanuele 9 | - Wagstaff Harry 10 | - Zia M Zeeshan 11 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ####################################################### 2 | # This file is the CMAKE script for Benchmarks Libraries 3 | ####################################################### 4 | cmake_minimum_required(VERSION 3.10) 5 | 6 | project(benchmarks) 7 | if (NOT SLAMBENCH_INCLUDE_DIR) 8 | message( FATAL_ERROR "SLAMBENCH_INCLUDE_DIR not found") 9 | else () 10 | include_directories(${SLAMBENCH_INCLUDE_DIR}) 11 | endif() 12 | 13 | ## EXTERNAL SOURCE CODE, SKIP WARNINGS .... 14 | ############################################################ 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") 17 | 18 | #### ADD USE-CASES DIRECTORIES ### 19 | ############################################################ 20 | if ("${APPS}" STREQUAL "all") 21 | message(STATUS "Select all applications...") 22 | set(APPS_MOD "efusion;kfusion;lsdslam;monoslam;infinitam;ptam;okvis;orbslam2;orbslam3;svo;flame,refusion,kinectfusion,dso,fullfusion") 23 | else() 24 | message(STATUS "Select only ${APPS} applications...") 25 | string(REPLACE "," ";" APPS_MOD "${APPS}") 26 | endif() 27 | 28 | set(app_list ${APPS_MOD}) 29 | MESSAGE(STATUS "Application loop over ${APPS_MOD}") 30 | FOREACH(app ${app_list}) 31 | IF(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${app}") 32 | MESSAGE(STATUS "Load application ${app}") 33 | ADD_SUBDIRECTORY(${app}) 34 | ELSE() 35 | MESSAGE(STATUS "Use-case ${app} not found. Please try \" make ${app} \" to download the usecase.") 36 | ENDIF() 37 | ENDFOREACH(app) 38 | -------------------------------------------------------------------------------- /cmake_modules/CUDACheckCompute.cmake: -------------------------------------------------------------------------------- 1 | ############################# 2 | #Sourced from: 3 | #https://raw.githubusercontent.com/jwetzl/CudaLBFGS/master/CheckComputeCapability.cmake 4 | ############################# 5 | # Check for GPUs present and their compute capability 6 | # based on http://stackoverflow.com/questions/2285185/easiest-way-to-test-for-existence-of-cuda-capable-gpu-from-cmake/2297877#2297877 (Christopher Bruns) 7 | 8 | if(CUDA_FOUND) 9 | message(STATUS "Try to compile and run : ${PROJECT_SOURCE_DIR}/cmake/cuda_compute_capability.c") 10 | try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR 11 | ${CMAKE_BINARY_DIR} 12 | ${CMAKE_SOURCE_DIR}/cmake_modules/cuda_compute_capability.c 13 | CMAKE_FLAGS 14 | -DINCLUDE_DIRECTORIES:STRING=${CUDA_TOOLKIT_INCLUDE} 15 | -DLINK_LIBRARIES:STRING=${CUDA_CUDART_LIBRARY} 16 | COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR 17 | RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR) 18 | message(STATUS "Compile: ${RUN_OUTPUT_VAR}") 19 | if (COMPILE_RESULT_VAR) 20 | message(STATUS "compiled -> " ${RUN_RESULT_VAR}) 21 | else() 22 | message(STATUS "didn't compile") 23 | endif() 24 | # COMPILE_RESULT_VAR is TRUE when compile succeeds 25 | # RUN_RESULT_VAR is zero when a GPU is found 26 | if(COMPILE_RESULT_VAR AND NOT RUN_RESULT_VAR) 27 | message(STATUS "worked") 28 | set(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether CUDA-capable GPU is present") 29 | set(CUDA_COMPUTE_CAPABILITY ${RUN_OUTPUT_VAR} CACHE STRING "Compute capability of CUDA-capable GPU present") 30 | mark_as_advanced(CUDA_COMPUTE_CAPABILITY) 31 | else() 32 | message(STATUS "didn't work") 33 | set(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether CUDA-capable GPU is present") 34 | endif() 35 | endif() 36 | -------------------------------------------------------------------------------- /cmake_modules/FindBrisk.cmake: -------------------------------------------------------------------------------- 1 | 2 | find_path(BRISK_INCLUDE_PATH Brisk/Brisk.h 3 | ~/usr/include 4 | ~/usr/.local/include 5 | ~/.local/include 6 | ~/usr/local/include 7 | /usr/include 8 | /usr/local/include 9 | thirdparty 10 | ) 11 | 12 | if(BRISK_INCLUDE_PATH) 13 | set(BRISK_FOUND TRUE) 14 | set(BRISK_INCLUDE_PATHS ${BRISK_INCLUDE_PATH} CACHE STRING "The include paths needed to use BRISK") 15 | endif() 16 | 17 | mark_as_advanced( 18 | BRISK_INCLUDE_PATHS 19 | ) 20 | 21 | 22 | # Generate appropriate messages 23 | if(BRISK_FOUND) 24 | if(NOT BRISK_FIND_QUIETLY) 25 | message("-- Found Brisk: ${BRISK_INCLUDE_PATH}") 26 | endif(NOT BRISK_FIND_QUIETLY) 27 | else(BRISK_FOUND) 28 | if(BRISK_FIND_REQUIRED) 29 | message(FATAL_ERROR "-- Could NOT find BRISK (missing: BRISK_INCLUDE_PATH)") 30 | endif(BRISK_FIND_REQUIRED) 31 | endif(BRISK_FOUND) 32 | -------------------------------------------------------------------------------- /cmake_modules/FindCVD.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libCVD 2 | # 3 | # CVD_FOUND - system has libCVD 4 | # CVD_INCLUDE_DIR - the libCVD include directories 5 | # CVD_LIBRARY - link these to use libCVD 6 | 7 | FIND_PATH( 8 | CVD_INCLUDE_DIR 9 | NAMES cvd/cvd_image.h 10 | PATHS 11 | /usr/include 12 | /usr/local/include 13 | ) 14 | 15 | FIND_LIBRARY( 16 | CVD_LIBRARY 17 | NAMES cvd 18 | PATHS 19 | /usr/lib 20 | /usr/local/lib 21 | ) 22 | 23 | IF(CVD_INCLUDE_DIR AND CVD_LIBRARY) 24 | SET(CVD_FOUND TRUE) 25 | ENDIF() 26 | 27 | IF(CVD_FOUND) 28 | IF(NOT CVD_FIND_QUIETLY) 29 | MESSAGE(STATUS "Found CVD: ${CVD_LIBRARY}") 30 | ENDIF() 31 | ELSE() 32 | IF(CVD_FIND_REQUIRED) 33 | MESSAGE(FATAL_ERROR "Could not find CVD") 34 | ENDIF() 35 | ENDIF() 36 | -------------------------------------------------------------------------------- /cmake_modules/FindCeres.cmake: -------------------------------------------------------------------------------- 1 | # -*- mode: cmake; -*- 2 | ############################################################################### 3 | # Find Ceres 4 | # 5 | # This sets the following variables: 6 | # CERES_FOUND - True if CERES was found. 7 | # CERES_INCLUDE_DIRS - Directories containing the CERES include files. 8 | # CERES_LIBRARIES - Libraries needed to use CERES. 9 | # 10 | 11 | find_path(CERES_INCLUDE_PATH ceres/ceres.h 12 | ${CERES_DIR}/include 13 | NO_DEFAULT_PATH 14 | ) 15 | 16 | find_library(CERES_DYNAMIC_LIBRARY NAMES libceres.so PATHS 17 | ${CERES_DIR}/lib64 18 | ${CERES_DIR}/lib 19 | NO_DEFAULT_PATH 20 | ) 21 | find_library(CERES_STATIC_LIBRARY NAMES libceres.a PATHS 22 | ${CERES_DIR}/lib64 23 | ${CERES_DIR}/lib 24 | NO_DEFAULT_PATH 25 | ) 26 | 27 | message(STATUS "CERES_DIR=${CERES_DIR}") 28 | message(STATUS "CERES_INCLUDE_PATH=${CERES_INCLUDE_PATH}") 29 | message(STATUS "CERES_DYNAMIC_LIBRARY=${CERES_DYNAMIC_LIBRARY}") 30 | message(STATUS "CERES_STATIC_LIBRARY=${CERES_STATIC_LIBRARY}") 31 | 32 | 33 | if(CERES_STATIC_LIBRARY OR CERES_DYNAMIC_LIBRARY) 34 | if(CERES_INCLUDE_PATH) 35 | set(CERES_FOUND TRUE) 36 | set(CERES_INCLUDE_PATHS ${CERES_INCLUDE_PATH} CACHE STRING "The include paths needed to use CERES") 37 | if(CERES_STATIC_LIBRARY) 38 | set(CERES_LIBRARIES "${CERES_STATIC_LIBRARY}" CACHE STRING "The libraries needed to use CERES") 39 | ELSE() 40 | set(CERES_LIBRARIES "${CERES_DYNAMIC_LIBRARY}" CACHE STRING "The libraries needed to use CERES") 41 | ENDIF() 42 | else() 43 | if(Ceres_FIND_REQUIRED) 44 | message(FATAL_ERROR "-- Could NOT find CERES (missing: CERES_INCLUDE_PATH)") 45 | endif(Ceres_FIND_REQUIRED) 46 | endif() 47 | else() 48 | if(Ceres_FIND_REQUIRED) 49 | message(FATAL_ERROR "-- Could NOT find CERES (missing: CERES_STATIC_LIBRARY or CERES_DYNAMIC_LIBRARY)") 50 | endif(Ceres_FIND_REQUIRED) 51 | endif() 52 | 53 | mark_as_advanced( 54 | CERES_INCLUDE_PATHS 55 | CERES_LIBRARIES 56 | ) 57 | 58 | 59 | 60 | # Generate appropriate messages 61 | if(Ceres_FOUND) 62 | if(NOT Ceres_FIND_QUIETLY) 63 | message("-- Found CERES: ${CERES_INCLUDE_PATH}") 64 | endif(NOT Ceres_FIND_QUIETLY) 65 | endif(Ceres_FOUND) 66 | -------------------------------------------------------------------------------- /cmake_modules/FindGVARS.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find GVARS 2 | # 3 | # GVARS_FOUND - system has GVARS 4 | # GVARS_INCLUDE_DIR - the GVARS include directories 5 | # GVARS_LIBRARY - link these to use GVARS 6 | 7 | FIND_PATH( 8 | GVARS_INCLUDE_DIR 9 | NAMES gvars3/config.h 10 | PATHS 11 | /usr/include 12 | /usr/local/include 13 | ) 14 | 15 | FIND_LIBRARY( 16 | GVARS_LIBRARY 17 | NAMES GVars3 18 | PATHS 19 | /usr/lib 20 | /usr/local/lib 21 | ) 22 | 23 | IF(GVARS_INCLUDE_DIR AND GVARS_LIBRARY) 24 | SET(GVARS_FOUND TRUE) 25 | ENDIF() 26 | 27 | IF(GVARS_FOUND) 28 | IF(NOT GVARS_FIND_QUIETLY) 29 | MESSAGE(STATUS "Found GVARS: ${GVARS_LIBRARY}") 30 | ENDIF() 31 | ELSE() 32 | IF(GVARS_FIND_REQUIRED) 33 | MESSAGE(FATAL_ERROR "Could not find GVARS") 34 | ENDIF() 35 | ENDIF() 36 | -------------------------------------------------------------------------------- /cmake_modules/FindLIBYAML.cmake: -------------------------------------------------------------------------------- 1 | # CMake module to search for the libyaml library 2 | # (library for parsing YAML files) 3 | # 4 | # If it's found it sets LIBYAML_FOUND to TRUE 5 | # and following variables are set: 6 | # LIBYAML_INCLUDE_DIR 7 | # LIBYAML_LIBRARY 8 | 9 | 10 | FIND_PATH(LIBYAML_INCLUDE_DIR NAMES yaml.h 11 | HINTS 12 | /usr/include/yaml-cpp/) 13 | FIND_LIBRARY(LIBYAML_LIBRARY NAMES yaml-cpp 14 | HINTS 15 | /usr/lib64) 16 | 17 | if(LIBYAML_LIBRARY) 18 | message(STATUS "Found LIBYAML Library: ${LIBYAML_LIBRARY}") 19 | else() 20 | message(STATUS "NOT Found LIBYAML Library: ${LIBYAML_LIBRARY}") 21 | endif() 22 | 23 | if(LIBYAML_INCLUDE_DIR) 24 | message(STATUS "Found LIBYAML includes: ${LIBYAML_INCLUDE_DIR}") 25 | else() 26 | message(STATUS "NOT Found LIBYAML includes: ${LIBYAML_INCLUDE_DIR}") 27 | endif() 28 | 29 | if(LIBYAML_LIBRARY AND LIBYAML_INCLUDE_DIR) 30 | message(STATUS "Found LIBYAML: ${LIBYAML_LIBRARY}") 31 | set(LIBYAML_FOUND TRUE) 32 | ELSE() 33 | IF(LIBYAML_FIND_REQUIRED) 34 | message(FATAL_ERROR "NOT FOUND: LIBYAML") 35 | ELSE() 36 | message(STATUS "NOT FOUND: LIBYAML") 37 | ENDIF() 38 | endif() 39 | 40 | mark_as_advanced( 41 | LIBYAML_INCLUDE_DIR 42 | LIBYAML_LIBRARY 43 | ) 44 | -------------------------------------------------------------------------------- /cmake_modules/FindOpenNI.cmake: -------------------------------------------------------------------------------- 1 | # -*- mode: cmake; -*- 2 | ############################################################################### 3 | # Find OpenNI 4 | # 5 | # This sets the following variables: 6 | # OPENNI_FOUND - True if OPENNI was found. 7 | # OPENNI_INCLUDE_DIRS - Directories containing the OPENNI include files. 8 | # OPENNI_LIBRARIES - Libraries needed to use OPENNI. 9 | # OPENNI_DEFINITIONS - Compiler flags for OPENNI. 10 | # 11 | # File forked from augmented_dev, project of alantrrs 12 | # (https://github.com/alantrrs/augmented_dev). 13 | 14 | find_package(PkgConfig) 15 | if(${CMAKE_VERSION} VERSION_LESS 2.8.2) 16 | pkg_check_modules(PC_OPENNI openni-dev) 17 | else() 18 | pkg_check_modules(PC_OPENNI QUIET openni-dev) 19 | endif() 20 | 21 | set(OPENNI_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) 22 | 23 | #using the 64bit version of OpenNi if generating for 64bit 24 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 25 | set(PROGRAMFILES_ "$ENV{PROGRAMW6432}") 26 | set(OPENNI_SUFFIX "64") 27 | else(CMAKE_SIZEOF_VOID_P EQUAL 8) 28 | set(PROGRAMFILES_ "$ENV{PROGRAMFILES}") 29 | set(OPENNI_SUFFIX "") 30 | endif(CMAKE_SIZEOF_VOID_P EQUAL 8) 31 | 32 | #add a hint so that it can find it without the pkg-config 33 | find_path(OPENNI_INCLUDE_DIR XnStatus.h 34 | HINTS ${PC_OPENNI_INCLUDEDIR} ${PC_OPENNI_INCLUDE_DIRS} /usr/include/ni /usr/include/openni 35 | "${PROGRAMFILES_}/OpenNI/Include" 36 | PATH_SUFFIXES openni) 37 | #add a hint so that it can find it without the pkg-config 38 | find_library(OPENNI_LIBRARY 39 | NAMES OpenNI64 OpenNI 40 | HINTS ${PC_OPENNI_LIBDIR} ${PC_OPENNI_LIBRARY_DIRS} /usr/lib "${PROGRAMFILES_}/OpenNI/Lib${OPENNI_SUFFIX}") 41 | 42 | set(OPENNI_INCLUDE_DIRS ${OPENNI_INCLUDE_DIR}) 43 | set(OPENNI_LIBRARIES ${OPENNI_LIBRARY}) 44 | 45 | include(FindPackageHandleStandardArgs) 46 | find_package_handle_standard_args(OpenNI DEFAULT_MSG 47 | OPENNI_LIBRARY OPENNI_INCLUDE_DIR) 48 | 49 | mark_as_advanced(OPENNI_LIBRARY OPENNI_INCLUDE_DIR) 50 | -------------------------------------------------------------------------------- /cmake_modules/FindOpenNI2.cmake: -------------------------------------------------------------------------------- 1 | find_library(OPENNI2_LIBRARY 2 | NAMES OpenNI2 3 | PATHS ~/usr/lib ~/usr/local/lib ~/.local/lib64 ~/.local/lib /usr/lib /usr/local/lib /data/Repositories/OpenNI2-2.2-beta2/Bin/x64-Release /scratch/cad/OpenNI/Redist /data/sw/OpenNI/OpenNI2-2.2-beta2/Bin/x64-Release 4 | PATH_SUFFIXES openni2 ni2 5 | ) 6 | if(OPENNI2_LIBRARY) 7 | else() 8 | find_library(OPENNI2_LIBRARY 9 | NAMES OpenNI2 10 | PATHS /usr/lib /usr/local/lib 11 | ) 12 | endif() 13 | 14 | find_path(OPENNI2_INCLUDE_PATH 15 | NAMES OpenNI.h 16 | PATHS ~/usr/include ~/.local/include ~/usr/local/include /usr/include /usr/local/include /scratch/cad/OpenNI/Include /data/sw/OpenNI/OpenNI2-2.2-beta2/Include 17 | PATH_SUFFIXES openni2 ni2 18 | ) 19 | 20 | 21 | if(OPENNI2_LIBRARY) 22 | else() 23 | message(STATUS "NOT Found OpenNI2 Library: ${OPENNI2_LIBRARY}") 24 | endif() 25 | if(OPENNI2_INCLUDE_PATH) 26 | set(OPENNI2_INCLUDE_DIR ${OPENNI2_INCLUDE_PATH}) 27 | else() 28 | message(STATUS "NOT Found OpenNI2 includes: ${OPENNI2_INCLUDE_PATH}") 29 | endif() 30 | if(OPENNI2_LIBRARY AND OPENNI2_INCLUDE_PATH) 31 | message(STATUS "Found OpenNI2: ${OPENNI2_LIBRARY}") 32 | set(OpenNI2_FOUND TRUE) 33 | set(OPENNI2_INCLUDE_PATHS ${OPENNI2_INCLUDE_PATH} CACHE STRING "The include paths needed to use OpenNI2") 34 | set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} CACHE STRING "The libraries needed to use OpenNI2") 35 | else() 36 | message(STATUS "NOT FOUND: OpenNI2") 37 | endif() 38 | 39 | mark_as_advanced( 40 | OPENNI2_INCLUDE_PATHS 41 | OPENNI2_LIBRARIES 42 | ) 43 | -------------------------------------------------------------------------------- /cmake_modules/FindPAPI.cmake: -------------------------------------------------------------------------------- 1 | # Try to find PAPI headers and libraries. 2 | # 3 | # Usage of this module as follows: 4 | # 5 | # find_package(PAPI) 6 | # 7 | # Variables used by this module, they can change the default behaviour and need 8 | # to be set before calling find_package: 9 | # 10 | # PAPI_PREFIX Set this variable to the root installation of 11 | # libpapi if the module has problems finding the 12 | # proper installation path. 13 | # 14 | # Variables defined by this module: 15 | # 16 | # PAPI_FOUND System has PAPI libraries and headers 17 | # PAPI_LIBRARIES The PAPI library 18 | # PAPI_INCLUDE_DIRS The location of PAPI headers 19 | 20 | find_path(PAPI_PREFIX 21 | NAMES include/papi.h 22 | ) 23 | 24 | find_library(PAPI_LIBRARY 25 | # Pick the static library first for easier run-time linking. 26 | NAMES libpapi.a papi 27 | HINTS ${PAPI_PREFIX}/lib ${HILTIDEPS}/lib 28 | ) 29 | 30 | find_library(SENSORS_LIBRARY 31 | NAMES sensors 32 | DOCS "LM_SENSORS Library" 33 | ) 34 | 35 | 36 | find_path(PAPI_INCLUDE_DIRS 37 | NAMES papi.h 38 | HINTS ${PAPI_PREFIX}/include ${HILTIDEPS}/include 39 | ) 40 | 41 | if (PAPI_LIBRARY AND SENSORS_LIBRARY) 42 | SET(PAPI_LIBRARIES ${PAPI_LIBRARY} ${SENSORS_LIBRARY}) 43 | ENDIF() 44 | 45 | include(FindPackageHandleStandardArgs) 46 | find_package_handle_standard_args(PAPI DEFAULT_MSG 47 | PAPI_LIBRARY 48 | SENSORS_LIBRARY 49 | PAPI_INCLUDE_DIRS 50 | ) 51 | 52 | 53 | mark_as_advanced( 54 | PAPI_PREFIX_DIRS 55 | PAPI_LIBRARIES 56 | PAPI_INCLUDE_DIRS 57 | ) 58 | -------------------------------------------------------------------------------- /cmake_modules/FindSLAMBENCH.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | find_path(SLAMBENCH_INCLUDE_PATH SLAMBenchAPI.h) 4 | 5 | find_library(SLAMBENCH_UTILS_LIBRARY libslambench-utils.a PATH ${SLAMBENCH_LIBRARY_PATH}) 6 | find_library(SLAMBENCH_IO_LIBRARY libslambench-io.a PATH ${SLAMBENCH_LIBRARY_PATH}) 7 | find_library(SLAMBENCH_C_WRAPPER_LIBRARY libslambench-c-wrapper.a PATH ${SLAMBENCH_LIBRARY_PATH}) 8 | find_library(SLAMBENCH_METRICS_LIBRARY libslambench-metrics.a PATH ${SLAMBENCH_LIBRARY_PATH}) 9 | 10 | if(SLAMBENCH_INCLUDE_PATH) 11 | if(SLAMBENCH_UTILS_LIBRARY) 12 | set(SLAMBENCH_FOUND TRUE) 13 | SET(SLAMBENCH_INCLUDE_DIR ${EIGEN3_INCLUDE_DIR} ${SLAMBENCH_INCLUDE_PATH} CACHE STRING "The include paths needed to use SLAMBENCH") 14 | SET(SLAMBENCH_LIBRARIES ${SLAMBENCH_UTILS_LIBRARY} -Wl,--whole-archive ${SLAMBENCH_IO_LIBRARY} ${SLAMBENCH_METRICS_LIBRARY} -Wl,--no-whole-archive) 15 | SET(SLAMBENCH_C_WRAPPER -Wl,--whole-archive ${SLAMBENCH_C_WRAPPER_LIBRARY} -Wl,--no-whole-archive) 16 | else() 17 | MESSAGE(STATUS "SLAMBENCH libraries are missing.") 18 | endif() 19 | else() 20 | MESSAGE(STATUS "SLAMBENCH headers are missing.") 21 | endif() 22 | mark_as_advanced( 23 | SLAMBENCH_INCLUDE_DIR 24 | SLAMBENCH_LIBRARIES 25 | SLAMBENCH_C_WRAPPER 26 | ) 27 | 28 | 29 | # Generate appropriate messages 30 | if(SLAMBENCH_FOUND) 31 | if(NOT SLAMBENCH_FIND_QUIETLY) 32 | message("-- Found SLAMbench2: ${SLAMBENCH_INCLUDE_DIR}") 33 | endif(NOT SLAMBENCH_FIND_QUIETLY) 34 | else(SLAMBENCH_FOUND) 35 | if(SLAMBENCH_FIND_REQUIRED) 36 | if(NOT SLAMBENCH_INCLUDE_PATH) 37 | message(FATAL_ERROR "-- Could NOT find SLAMBENCH (missing: SLAMBENCH_INCLUDE_PATH)") 38 | else () 39 | message(FATAL_ERROR "-- Could NOT find SLAMBENCH (missing: SLAMBENCH_LIBRARY_PATH)") 40 | endif() 41 | 42 | endif(SLAMBENCH_FIND_REQUIRED) 43 | endif(SLAMBENCH_FOUND) 44 | -------------------------------------------------------------------------------- /cmake_modules/FindTooN.cmake: -------------------------------------------------------------------------------- 1 | 2 | find_path(TOON_INCLUDE_PATH TooN/TooN.h 3 | ~/usr/include 4 | ~/usr/.local/include 5 | ~/.local/include 6 | ~/usr/local/include 7 | /usr/include 8 | /usr/local/include 9 | thirdparty 10 | ) 11 | 12 | if(TOON_INCLUDE_PATH) 13 | set(TooN_FOUND TRUE) 14 | set(TOON_INCLUDE_PATHS ${TOON_INCLUDE_PATH} CACHE STRING "The include paths needed to use TooN") 15 | endif() 16 | 17 | mark_as_advanced( 18 | TOON_INCLUDE_PATHS 19 | ) 20 | 21 | 22 | # Generate appropriate messages 23 | if(TooN_FOUND) 24 | if(NOT TooN_FIND_QUIETLY) 25 | message(STATUS "Found Toon: ${TOON_INCLUDE_PATH}") 26 | endif(NOT TooN_FIND_QUIETLY) 27 | else(TooN_FOUND) 28 | if(TooN_FIND_REQUIRED) 29 | message(FATAL_ERROR "Could NOT find TooN (missing: TOON_INCLUDE_PATH)") 30 | endif(TooN_FIND_REQUIRED) 31 | endif(TooN_FOUND) 32 | -------------------------------------------------------------------------------- /cmake_modules/cuda_compute_capability.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Florian Rathgeber, florian.rathgeber@gmail.com 3 | * 4 | * This code is licensed under the MIT License. See the FindCUDA.cmake script 5 | * for the text of the license. 6 | * 7 | * Based on code by Christopher Bruns published on Stack Overflow (CC-BY): 8 | * http://stackoverflow.com/questions/2285185 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | int main() { 15 | int deviceCount, device, major = 9999, minor = 9999; 16 | int gpuDeviceCount = 0; 17 | struct cudaDeviceProp properties; 18 | 19 | if (cudaGetDeviceCount(&deviceCount) != cudaSuccess) 20 | { 21 | printf("Couldn't get device count: %s\n", cudaGetErrorString(cudaGetLastError())); 22 | return 1; 23 | } 24 | /* machines with no GPUs can still report one emulation device */ 25 | for (device = 0; device < deviceCount; ++device) { 26 | cudaGetDeviceProperties(&properties, device); 27 | if (properties.major != 9999) {/* 9999 means emulation only */ 28 | ++gpuDeviceCount; 29 | /* get minimum compute capability of all devices */ 30 | if (major > properties.major) { 31 | major = properties.major; 32 | minor = properties.minor; 33 | } else if ((major == properties.major) && (minor > properties.minor)) { 34 | minor = properties.minor; 35 | } 36 | } 37 | } 38 | 39 | /* don't just return the number of gpus, because other runtime cuda 40 | errors can also yield non-zero return values */ 41 | if (gpuDeviceCount > 0) { 42 | if ((major == 2 && minor == 1)) 43 | { 44 | // There is no --arch compute_21 flag for nvcc, so force minor to 0 45 | minor = 0; 46 | } 47 | /* this output will be parsed by FindCUDA.cmake */ 48 | printf("%d%d", major, minor); 49 | return 0; /* success */ 50 | } 51 | return 1; /* failure */ 52 | } 53 | -------------------------------------------------------------------------------- /datasets/README.md: -------------------------------------------------------------------------------- 1 | #### Supported Datasets 2 | 3 | Here is a list of the datasets available: 4 | - TUM RGB-D SLAM dataset [Sturm et al., IROS 2012]: https://vision.in.tum.de/data/datasets/rgbd-dataset 5 | - ICL-NUIM dataset [Handa et al., ICRA 2014]: https://www.doc.ic.ac.uk/~ahanda/VaFRIC/iclnuim.html 6 | - EuRoC MAV Dataset [Burri et al., IJJR 2016]: https://projects.asl.ethz.ch/datasets/doku.php 7 | - SVO sample dataset [Forster et al., ICRA 2014]: https://github.com/uzh-rpg/rpg_svo 8 | 9 | If you use any of these datasets, please refer to their respective publication. 10 | 11 | --------------------------------------- 12 | 13 | In addition to their _primary_ format, the following datasets 14 | are also supported as __rosbag__ files: 15 | - TUM RGB-D SLAM dataset [https://vision.in.tum.de/data/datasets/rgbd-dataset/file_formats] 16 | 17 | Please note that, as rosbags contain unprocessed sensor data, 18 | processing rosbag datasets can take considerably longer 19 | than processing datasets in their primary format. 20 | 21 | Rosbag support requires the following ROS packages: 22 | - cpp_common 23 | - roscpp_serialization 24 | - rostime 25 | - rosbag_storage 26 | - tf 27 | 28 | The following versions of the ROS packages have been tested: 29 | - ROS kinetic / Linux Ubuntu 16.04 (xenial) 30 | - ROS melodic / Linux Ubuntu 18.04 (bionic) 31 | 32 | If __rosbag__ support is required and ROS is not installed in the standard location (/opt/ros) make sure to setup the ROS environment before building SLAMBench. 33 | -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | 2 | #################################### 3 | #### DOCKER PART #### 4 | #################################### 5 | 6 | ## sudo service docker start 7 | 8 | SLAMBENCH2_DIRECTORY=../ 9 | 10 | .PHONY: ./%-docker-image %-docker-image 11 | 12 | ./tmp/%-docker-image/DockerFile : ./%.docker 13 | mkdir -p ./tmp/$*-docker-image/slambench2 14 | rm -rf ./tmp/$*-docker-image/slambench2/* 15 | cp -r ${SLAMBENCH2_DIRECTORY}/CMakeLists.txt ${SLAMBENCH2_DIRECTORY}/benchmarks ${SLAMBENCH2_DIRECTORY}/cmake_modules ${SLAMBENCH2_DIRECTORY}/framework ${SLAMBENCH2_DIRECTORY}/Makefile ./tmp/$*-docker-image/slambench2 16 | cp -rf $< ./tmp/$*-docker-image/DockerFile 17 | # cp -f nvidia-driver.run ./tmp/$*-docker-image/ 18 | 19 | fedora24 : 20 | make fedora-24-docker-image 21 | 22 | ubuntu14 : 23 | make ubuntu-14.04-docker-image 24 | 25 | ubuntu16 : 26 | make ubuntu-16.04-docker-image 27 | 28 | 29 | 30 | 31 | nvidia_version=$(shell cat /proc/driver/nvidia/version | head -n 1 | awk '{ print $$8 }') 32 | 33 | nvidia-driver.run : 34 | wget -O nvidia-driver.run "http://us.download.nvidia.com/XFree86/Linux-x86_64/${nvidia_version}/NVIDIA-Linux-x86_64-${nvidia_version}.run" 35 | 36 | cuda-ubuntu16 : nvidia-driver.run 37 | make cuda-ubuntu-16.04-docker-image 38 | 39 | %-docker-image: ./%.docker ./tmp/%-docker-image/DockerFile 40 | docker build -f ./tmp/$*-docker-image/DockerFile -t bbodin/slambench:$* ./tmp/$*-docker-image 41 | -------------------------------------------------------------------------------- /docker/fastCI.docker: -------------------------------------------------------------------------------- 1 | FROM fedora:26 2 | 3 | # Dependencies 4 | ################################################################## 5 | 6 | RUN dnf install -y git wget gcc gcc-c++ make mercurial cmake unzip 7 | RUN dnf install -y yaml-cpp-devel 8 | 9 | # Prepare 10 | ################################################################## 11 | 12 | RUN git config --global user.email "you@example.com" 13 | RUN git config --global user.name "Your Name" 14 | 15 | # Copy 16 | ################################################################## 17 | 18 | RUN mkdir /slambench2 19 | COPY ./slambench2/ /slambench2/ 20 | RUN ls /slambench2 21 | 22 | 23 | # Build deps 24 | ################################################################## 25 | 26 | RUN make -C /slambench2 toon 27 | RUN make -C /slambench2 eigen3 28 | 29 | # Build slambench2 30 | ################################################################## 31 | 32 | RUN make -C /slambench2 slambench APPS=kfusion 33 | 34 | # Test slambench2 35 | ################################################################## 36 | 37 | RUN make -C /slambench2 datasets/TUM/freiburg1/rgbd_dataset_freiburg1_desk.slam 38 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/TUM/freiburg1/rgbd_dataset_freiburg1_desk.slam -load ./build/lib/libkfusion-cpp-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 39 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/TUM/freiburg1/rgbd_dataset_freiburg1_desk.slam -load ./build/lib/libkfusion-cpp-library.so=kf1 -load ./build/lib/libkfusion-openmp-library.so=kf2 -fl 30 -kf1-s 5 -kf2-s 5 -kf1-d 1.71,2.4,1.152 -kf1-z 8 -kf2-d 1.71,2.4,1.152 -kf2-z 8 40 | -------------------------------------------------------------------------------- /docker/github.docker: -------------------------------------------------------------------------------- 1 | FROM bbodin/slambench:travis-deps 2 | 3 | # Copy 4 | ################################################################## 5 | 6 | COPY ./slambench2/ /slambench2/ 7 | RUN ls /slambench2 8 | 9 | # Build slambench2 10 | ################################################################## 11 | 12 | RUN make -C /slambench2 slambench SBQUIET=1 13 | RUN make -C /slambench2 algorithms SBQUIET=1 14 | RUN make -C /slambench2 slambench SBQUIET=1 APPS=all 15 | 16 | RUN make -C /slambench2 datasets/ICL_NUIM/living_room_traj2_loop.slam SBQUIET=1 17 | 18 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libkfusion-cpp-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 19 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libkfusion-openmp-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 20 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/liblsdslam-cpp-library.so -fl 30 21 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libinfinitam-cpp-library.so -fl 30 22 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libmonoslam-cpp-library.so -fl 30 23 | #RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libptam-original_mp-library.so -fl 30 24 | #RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libokvis-original-library.so -fl 30 25 | 26 | -------------------------------------------------------------------------------- /docker/run_cuda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" = "$1"; } 4 | #docker_version=$(docker version | grep 'Client version' | awk '{split($0,a,":"); print a[2]}' | tr -d ' ') 5 | # Docker 1.3.0 or later is required for --device 6 | 7 | #if test $# -lt 1; then 8 | # Get the latest opengl-nvidia build 9 | # and start with an interactive terminal enabled 10 | # args="-i -t $(docker images | grep ^opengl-nvidia | head -n 1 | awk '{ print $1":"$2 }')" 11 | #else 12 | # Use this script with derived images, and pass your 'docker run' args 13 | # args="$@" 14 | #fi 15 | 16 | 17 | 18 | echo "preparation" 19 | 20 | XSOCK=/tmp/.X11-unix 21 | XAUTH=/tmp/.docker.xauth 22 | touch $XAUTH 23 | echo "XSOCK=${XSOCK}" 24 | echo "XAUTH=${XAUTH}" 25 | echo "xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -" 26 | xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge - 27 | 28 | echo "Run" 29 | 30 | echo docker run \ 31 | --runtime=nvidia \ 32 | -v $XSOCK:$XSOCK:rw \ 33 | -v $XAUTH:$XAUTH:rw \ 34 | --device=/dev/nvidia0:/dev/nvidia0 \ 35 | --device=/dev/nvidiactl:/dev/nvidiactl \ 36 | --device=/dev/nvidia-uvm:/dev/nvidia-uvm \ 37 | -e DISPLAY=$DISPLAY \ 38 | -e XAUTHORITY=$XAUTH \ 39 | -it \ 40 | bbodin/slambench:cuda-ubuntu-16.04 $@ 41 | 42 | docker run \ 43 | --runtime=nvidia \ 44 | -v $XSOCK:$XSOCK:rw \ 45 | -v $XAUTH:$XAUTH:rw \ 46 | --device=/dev/nvidia0:/dev/nvidia0 \ 47 | --device=/dev/nvidiactl:/dev/nvidiactl \ 48 | --device=/dev/nvidia-uvm:/dev/nvidia-uvm \ 49 | -e DISPLAY=$DISPLAY \ 50 | -e XAUTHORITY=$XAUTH \ 51 | -it \ 52 | bbodin/slambench:cuda-ubuntu-16.04 $@ 53 | -------------------------------------------------------------------------------- /docker/ubuntu-14.04-bitbucket.docker: -------------------------------------------------------------------------------- 1 | FROM bbodin/slambench:ubuntu-14.04-deps 2 | 3 | # Copy 4 | ################################################################## 5 | 6 | COPY ./slambench2/ /slambench2/ 7 | RUN ls /slambench2 8 | 9 | # Build slambench2 10 | ################################################################## 11 | 12 | RUN make -C /slambench2 slambench 13 | RUN make -C /slambench2 slambench APPS=okvis 14 | RUN make -C /slambench2 slambench APPS=ptam 15 | RUN make -C /slambench2 slambench APPS=kfusion 16 | RUN make -C /slambench2 slambench APPS=monoslam 17 | RUN make -C /slambench2 slambench APPS=lsdslam 18 | RUN make -C /slambench2 slambench APPS=efusion 19 | RUN make -C /slambench2 slambench APPS=infinitam 20 | 21 | RUN make -C /slambench2 datasets/ICL_NUIM/living_room_traj2_loop.slam 22 | 23 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libkfusion-cpp-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 24 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libkfusion-openmp-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 25 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libkfusion-notoon-library.so -fl 30 -s 5 -d 1.71,2.4,1.152 -z 8 26 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/liblsdslam-cpp-library.so -fl 30 27 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libinfinitam-cuda-library.so -fl 30 28 | RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libmonoslam-sequential-library.so -fl 30 29 | #RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libptam-original_mp-library.so -fl 30 30 | #RUN cd /slambench2 && ./build/bin/benchmark_loader -i ./datasets/ICL_NUIM/living_room_traj2_loop.slam -load ./build/lib/libokvis-original-library.so -fl 30 31 | 32 | -------------------------------------------------------------------------------- /docker/ubuntu-14.04-deps.docker: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | # Dependencies 4 | ################################################################## 5 | 6 | RUN apt-get -y update && apt-get -y install unzip libflann-dev wget libyaml-cpp-dev mercurial git gcc cmake python-numpy freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev libxmu-dev libxi-dev libboost-all-dev cvs gfortran libatlas-base-dev libgoogle-glog-dev libgtk2.0-dev libvtk5.8 libvtk5-dev 7 | RUN apt-get -y update && apt-get -y install dictionaries-common 8 | RUN /usr/share/debconf/fix_db.pl 9 | RUN dpkg-reconfigure dictionaries-common 10 | RUN apt-get -y update && apt-get -y install gtk2.0 11 | 12 | 13 | # Copy 14 | ################################################################## 15 | 16 | RUN mkdir /slambench2 17 | COPY ./slambench2/ /slambench2/ 18 | RUN ls /slambench2 19 | 20 | 21 | # Build deps 22 | ################################################################## 23 | 24 | RUN make -C /slambench2 toon 25 | RUN make -C /slambench2 eigen3 26 | RUN make -C /slambench2 cvd 27 | RUN make -C /slambench2 flann 28 | RUN make -C /slambench2 freeimage 29 | RUN make -C /slambench2 g2o 30 | RUN make -C /slambench2 gvars 31 | RUN make -C /slambench2 opencv 32 | RUN make -C /slambench2 opengv 33 | RUN make -C /slambench2 opentuner 34 | RUN make -C /slambench2 pangolin 35 | RUN make -C /slambench2 pcl 36 | RUN make -C /slambench2 suitesparse 37 | RUN make -C /slambench2 brisk 38 | RUN make -C /slambench2 ceres 39 | 40 | 41 | # Keep only deps 42 | ################################################################## 43 | 44 | RUN rm -rf /slambench2/CMakeLists.txt /slambench2/benchmarks /slambench2/cmake /slambench2/interfaces /slambench2/frontends /slambench2/framework /slambench2/Makefile /slambench2/build 45 | RUN rm -rf /slambench2/deps/repos 46 | RUN rm -rf /slambench2/datasets 47 | RUN rm -rf /slambench2/install 48 | RUN rm -rf /slambench2/temp 49 | RUN ls /slambench2 50 | 51 | -------------------------------------------------------------------------------- /framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ####################################################### 2 | # This file is the CMAKE script for SLAMBench Libraries 3 | ####################################################### 4 | cmake_minimum_required(VERSION 3.0) 5 | project(slambench) 6 | # Find most common packages 7 | ####################################################### 8 | find_package(GLUT) 9 | find_package(OpenGL) 10 | find_package(Eigen3 REQUIRED) 11 | find_package(PAPI) 12 | 13 | #### BUILD SLAMBENCH AND TOOLS #### 14 | add_subdirectory(shared) # SLAMBench Shared library 15 | IF(NOT ANDROID) 16 | add_subdirectory(tools) # SLAMBench Tools 17 | ENDIF() 18 | 19 | -------------------------------------------------------------------------------- /framework/makefiles/brisk.make: -------------------------------------------------------------------------------- 1 | BRISK_INCLUDE_DIR=${DEPS_DIR}/brisk/include 2 | BRISK_DIR=${DEPS_DIR}/brisk/lib/CMake/brisk/ 3 | 4 | ${REPOS_DIR}/brisk : 5 | mkdir ${REPOS_DIR} -p 6 | rm $@ -rf 7 | mkdir $@ -p 8 | cd $@ ; wget --no-check-certificate https://www.doc.ic.ac.uk/~sleutene/software/brisk-2.0.5.zip 9 | cd $@ ; unzip *.zip ; rm brisk-2.0.5.zip; 10 | sed -i.bak "s/[#]include [<]algo/#include\\n#include 3 | Date: Fri, 23 Feb 2018 17:06:37 -0800 4 | Subject: [PATCH 1/1] fix float usage in powf64 5 | 6 | Signed-off-by: Ryan Coe 7 | --- 8 | Source/LibRawLite/internal/dcraw_common.cpp | 11 +++++++++-- 9 | 1 file changed, 9 insertions(+), 2 deletions(-) 10 | 11 | diff --git a/Source/LibRawLite/internal/dcraw_common.cpp b/Source/LibRawLite/internal/dcraw_common.cpp 12 | index 217133a9f9a1caccb77eae946b3af073f660b1cf..cde8e420ad66508feb1222b5fde7166104f6ff1a 100644 13 | --- a/Source/LibRawLite/internal/dcraw_common.cpp 14 | +++ b/Source/LibRawLite/internal/dcraw_common.cpp 15 | @@ -5543,11 +5543,18 @@ static float powf_lim(float a, float b, float limup) 16 | { 17 | return (b>limup || b < -limup)?0.f:powf(a,b); 18 | } 19 | -static float powf64(float a, float b) 20 | +static float powf64(const float a, const float b) 21 | { 22 | return powf_lim(a,b,64.f); 23 | } 24 | - 25 | +static float powf64(const int a, const int b) 26 | +{ 27 | + return powf_lim((float)a,(float)b,64.f); 28 | +} 29 | +static float powf64(const double a, const double b) 30 | +{ 31 | + return powf_lim((float)a,(float)b,64.f); 32 | +} 33 | 34 | #ifdef LIBRAW_LIBRARY_BUILD 35 | 36 | -- 37 | 2.16.1 38 | 39 | -------------------------------------------------------------------------------- /framework/shared/include/ParameterComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_SHARED_INCLUDE_PARAMETERCOMPONENT_H_ 11 | #define FRAMEWORK_SHARED_INCLUDE_PARAMETERCOMPONENT_H_ 12 | 13 | #include 14 | #include 15 | 16 | struct Parameter; 17 | class ParameterComponent; 18 | 19 | typedef std::vector arguments_vector ; 20 | typedef std::vector components_vector ; 21 | 22 | 23 | class ParameterComponent 24 | { 25 | public: 26 | ParameterComponent(std::string name) : name_(name) {} 27 | 28 | virtual ~ParameterComponent(); 29 | 30 | const arguments_vector &getParameters() const { 31 | return arguments_; 32 | } 33 | 34 | const components_vector &getComponents() const { 35 | return components_; 36 | } 37 | 38 | std::string getName() const { 39 | return name_; 40 | } 41 | 42 | template 43 | void addParameter(T p) { 44 | T * param_ptr = new T (p); 45 | this->arguments_.push_back(param_ptr); 46 | param_ptr->resetValue(); 47 | 48 | 49 | } 50 | 51 | void AddComponent(ParameterComponent *component) { 52 | components_.push_back(component); 53 | } 54 | 55 | private: 56 | std::string name_; 57 | arguments_vector arguments_; 58 | components_vector components_; 59 | 60 | }; 61 | #endif 62 | -------------------------------------------------------------------------------- /framework/shared/include/ParameterManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef PARAMETERMANAGER_H 13 | #define PARAMETERMANAGER_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | typedef std::pair param_info_t; 21 | namespace slambench { 22 | class ParameterManager : public ParameterComponent { 23 | public : 24 | ParameterManager() : 25 | ParameterComponent("") {} 26 | void ClearComponents() { components_.clear(); }; 27 | void PrintValues(std::ostream &str, const ParameterComponent* c = nullptr) const; 28 | void PrintArguments(std::ostream &str, const ParameterComponent* c = nullptr) const; 29 | bool BuildArgumentsList(ParameterComponent *callback_data); 30 | bool ReadArgumentsOrQuit(unsigned int argc, const char * const * const argv); 31 | bool ReadArguments(unsigned int argc, const char * const * const argv); 32 | 33 | private: 34 | std::map params_long_, params_short_; 35 | std::vector components_; 36 | }; 37 | } 38 | 39 | #endif /* PARAMETERMANAGER_H */ 40 | 41 | -------------------------------------------------------------------------------- /framework/shared/include/ResultWriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 Intel Corp. 4 | 5 | This code is licensed under the MIT License. 6 | 7 | */ 8 | 9 | 10 | #ifndef RESULT_WRITER_H_ 11 | #define RESULT_WRITER_H_ 12 | 13 | #include 14 | #include 15 | 16 | class ResultWriter { 17 | public: 18 | ResultWriter(std::ofstream &stream); 19 | 20 | void WriteKV(std::string key, std::string value); 21 | 22 | void WriteKV(std::string key, std::vector values, std::string separator=","); 23 | 24 | void WriteTrajectory(slambench::outputs::BaseOutput::value_map_t traj); 25 | 26 | static std::string GetCPUModel(); 27 | 28 | static std::string GetMemorySize(); 29 | 30 | private: 31 | std::ofstream &out_; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /framework/shared/include/SLAMBenchAPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef FRAMEWORK_SHARED_INCLUDE_SLAMBENCHAPI_H_ 12 | #define FRAMEWORK_SHARED_INCLUDE_SLAMBENCHAPI_H_ 13 | 14 | #include 15 | #include 16 | 17 | 18 | namespace slambench { 19 | namespace io { 20 | class SLAMFrame; 21 | } 22 | } 23 | 24 | /* 25 | * Those functions define SLAMBenchConfiguration and reuse it after parameters parsing 26 | * sb_new_slam_configuration: allocate slam_settings 27 | * sb_init_slam_system: retrieve arguments from slam_settings 28 | * */ 29 | 30 | bool sb_new_slam_configuration(SLAMBenchLibraryHelper * slam_settings) ; 31 | bool sb_init_slam_system(SLAMBenchLibraryHelper * slam_settings) ; 32 | 33 | 34 | /* 35 | * Every frame we update the sensors and we process 36 | * sb_update_frame: update information for a specific sensor, must be call for each sensor 37 | * sb_process_once: once every sensor are updated slam process them 38 | * */ 39 | 40 | bool sb_update_frame (SLAMBenchLibraryHelper * slam_settings, slambench::io::SLAMFrame * type) ; 41 | bool sb_relocalize (SLAMBenchLibraryHelper * slam_settings) ; 42 | bool sb_process_once (SLAMBenchLibraryHelper * slam_settings) ; 43 | 44 | 45 | /* 46 | * At any time, the SLAM system needs to provide its outputs 47 | * */ 48 | 49 | bool sb_update_outputs(SLAMBenchLibraryHelper *lib, const slambench::TimeStamp *latest_output); 50 | 51 | /* 52 | * At the end of the process the SLAM system can be ask to save the volume in a file and to clean memory 53 | * */ 54 | bool sb_clean_slam_system(); 55 | 56 | /* 57 | * C equivalent of each function (not used) 58 | * */ 59 | 60 | 61 | 62 | extern "C" { 63 | bool c_sb_new_slam_configuration(void * slam_settings) ; 64 | bool c_sb_init_slam_system(void* slam_settings) ; 65 | bool c_sb_update_frame (void * slam_settings, void * type) ; 66 | bool c_sb_relocalize (void * slam_settings) ; 67 | bool c_sb_process_once (void * slam_settings) ; 68 | bool c_sb_update_outputs(void *lib, void *timestamp); 69 | bool c_sb_clean_slam_system(); 70 | 71 | } 72 | 73 | #endif /* FRAMEWORK_SHARED_INCLUDE_SLAMBENCHAPI_H_ */ 74 | -------------------------------------------------------------------------------- /framework/shared/include/SLAMBenchException.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_SHARED_INCLUDE_SLAMBENCHEXCEPTION_H_ 11 | #define FRAMEWORK_SHARED_INCLUDE_SLAMBENCHEXCEPTION_H_ 12 | 13 | #include 14 | #include 15 | 16 | class SLAMBenchException : public std::exception { 17 | private: 18 | std::string err_msg_; 19 | 20 | public: 21 | SLAMBenchException(const char *msg) : err_msg_(msg) {}; 22 | ~SLAMBenchException() throw() {}; 23 | const char *what() const throw() { return this->err_msg_.c_str(); }; 24 | }; 25 | 26 | 27 | #endif /* FRAMEWORK_SHARED_INCLUDE_SLAMBENCHEXCEPTION_H_ */ 28 | -------------------------------------------------------------------------------- /framework/shared/include/SLAMBenchUI.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SLAMBENCHUI_H_ 3 | #define SLAMBENCHUI_H_ 4 | 5 | // #define DEBUG_MUTEXES 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #ifdef DEBUG_MUTEXES 17 | #include 18 | #endif 19 | #include 20 | 21 | 22 | /* 23 | * ************************************************************************************************ 24 | * ********************** SLAMBenchUI 25 | * ************************************************************************************************ 26 | */ 27 | 28 | class SLAMBenchUI 29 | { 30 | 31 | protected : 32 | int frame = 0; 33 | int width = 0; 34 | int height = 0; 35 | float cx = 0,cy = 0,fx = 0,fy = 0; 36 | 37 | 38 | public : 39 | typedef std::vector> output_manager_container; 40 | 41 | virtual ~SLAMBenchUI() {}; 42 | 43 | virtual bool process() = 0; 44 | 45 | virtual void stepFrame() { this->frame += 1; } 46 | virtual bool IsFreeRunning() { return true; } 47 | virtual bool CanFreeRun() { return true; } 48 | virtual bool SetFreeRunning() { return true; } 49 | virtual bool ClearFreeRunning() { return false; } 50 | virtual bool WaitForFrame() { return false; } 51 | virtual bool CanStep() { return false; } 52 | 53 | inline void update_camera(int height , int width, float fx, float fy , float cx , float cy ) { 54 | this->width = width; 55 | this->height = height; 56 | this->fx = fx; 57 | this->fy = fy; 58 | this->cx = cx; 59 | this->cy = cy; 60 | }; 61 | 62 | 63 | void AddOutputManager(const std::string &name, slambench::outputs::OutputManager *mgr) { output_managers_.push_back(std::make_pair(name, mgr)); } 64 | const output_manager_container &GetOutputManagers() { return output_managers_; } 65 | private : 66 | output_manager_container output_managers_; 67 | 68 | }; 69 | #endif 70 | -------------------------------------------------------------------------------- /framework/shared/include/io/Event.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_EVENT_H 11 | #define IO_EVENT_H 12 | 13 | #include 14 | 15 | namespace slambench { 16 | namespace io { 17 | 18 | struct Event { 19 | TimeStamp ts; 20 | uint16_t x; 21 | uint16_t y; 22 | bool polarity; 23 | 24 | Event(TimeStamp ts, uint16_t x, uint16_t y, bool polarity) : ts(ts), x(x), y(y), polarity(polarity) {} 25 | }; 26 | 27 | std::ostream& operator << (std::ostream &out, const Event &e) { 28 | out << e.ts.S << "." << e.ts.Ns << " = " << e.x << " " << e.y << " " << e.polarity; 29 | return out; 30 | } 31 | } 32 | } 33 | 34 | #endif // IO_EVENT_H 35 | -------------------------------------------------------------------------------- /framework/shared/include/io/FrameBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_FRAMEBUFFER_H 12 | #define IO_FRAMEBUFFER_H 13 | 14 | #include 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | class FrameBuffer { 20 | public: 21 | FrameBuffer(); 22 | ~FrameBuffer(); 23 | 24 | void Acquire(); 25 | bool TryAcquire(); 26 | void Release(); 27 | void ResetBuffer(); 28 | bool Busy(); 29 | bool Reserve(size_t size); 30 | void *Data(); 31 | void resetLock() { 32 | lock_.exchange(false); 33 | } 34 | 35 | private: 36 | std::atomic lock_; 37 | size_t size_; 38 | void *data_; 39 | }; 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /framework/shared/include/io/FrameBufferSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_FRAMEBUFFERSOURCE_H 12 | #define IO_FRAMEBUFFERSOURCE_H 13 | 14 | #include 15 | 16 | namespace slambench { 17 | namespace io { 18 | class FrameBufferSource { 19 | public: 20 | virtual FrameBuffer *Next() = 0; 21 | virtual ~FrameBufferSource() {}; 22 | }; 23 | 24 | class SingleFrameBufferSource : public FrameBufferSource { 25 | public: 26 | FrameBuffer *Next() override; 27 | 28 | private: 29 | FrameBuffer fb_; 30 | }; 31 | } 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /framework/shared/include/io/FrameFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_FRAMEFORMAT_H 12 | #define IO_FRAMEFORMAT_H 13 | 14 | #include 15 | 16 | namespace slambench { 17 | namespace io { 18 | namespace frameformat { 19 | enum EFrameFormat { 20 | UNKNOWN, 21 | Raster, 22 | JPEG, 23 | PNG 24 | }; 25 | 26 | EFrameFormat Parse(const std::string &); 27 | } 28 | } 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /framework/shared/include/io/InputInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_INPUTINTERFACE_H 12 | #define IO_INPUTINTERFACE_H 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include "sensor/SensorCollection.h" 20 | #include "deserialisation/SLAMFrameDeserialiser.h" 21 | 22 | namespace slambench { 23 | namespace io { 24 | 25 | class InputInterface { 26 | public: 27 | virtual ~InputInterface(); 28 | virtual SensorCollection &GetSensors() = 0; 29 | virtual FrameStream &GetFrames() = 0; 30 | }; 31 | 32 | class BasicInputInterface : public InputInterface { 33 | public: 34 | BasicInputInterface(FrameStream &frames, SensorCollection &sensors); 35 | 36 | FrameStream& GetFrames() override; 37 | SensorCollection& GetSensors() override; 38 | private: 39 | FrameStream &frames_; 40 | SensorCollection &sensors_; 41 | }; 42 | 43 | class FileInputInterface : public InputInterface { 44 | public: 45 | FileInputInterface(SLAMFile &input_file); 46 | 47 | FrameStream& GetFrames() override; 48 | SensorCollection& GetSensors() override; 49 | private: 50 | SLAMFile &file_; 51 | FrameCollectionStream stream_; 52 | }; 53 | 54 | class FileStreamInputInterface : public InputInterface { 55 | public: 56 | FileStreamInputInterface(FILE* input_file, FrameBufferSource *fb_source); 57 | 58 | FrameStream &GetFrames() override; 59 | SensorCollection &GetSensors() override; 60 | private: 61 | SLAMFrameDeserialiser deserialiser_; 62 | SensorCollection sensors_; 63 | }; 64 | } 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /framework/shared/include/io/InputInterfaceManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2020 University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_INPUTINTERFACEMANAGER_H 12 | #define IO_INPUTINTERFACEMANAGER_H 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include "sensor/SensorCollection.h" 20 | #include "deserialisation/SLAMFrameDeserialiser.h" 21 | #include "InputInterface.h" 22 | #include 23 | namespace slambench { 24 | namespace io { 25 | 26 | class InputInterfaceManager { 27 | public: 28 | InputInterfaceManager(const std::vector& dataset_filenames); 29 | ~InputInterfaceManager(); 30 | 31 | slambench::io::InputInterface *GetCurrentInputInterface(); 32 | 33 | SLAMFrame* GetNextFrame() const; 34 | SLAMFrame* GetClosestGTFrameToTime(slambench::TimeStamp& ts) const; 35 | bool LoadNextInputInterface(); 36 | bool initialized() 37 | { 38 | return input_interfaces_.empty(); 39 | } 40 | slambench::io::FrameStream *input_stream_; 41 | bool updated_ = false; 42 | private: 43 | std::list input_interfaces_; 44 | slambench::io::SensorCollection* first_sensors_; 45 | 46 | }; 47 | } 48 | } 49 | 50 | #endif // IO_INPUTINTERFACEMANAGER_H 51 | -------------------------------------------------------------------------------- /framework/shared/include/io/PixelFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_PIXELFORMAT_H 12 | #define IO_PIXELFORMAT_H 13 | 14 | #include 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | namespace pixelformat { 20 | enum EPixelFormat { 21 | UNKNOWN, 22 | G_I_8, 23 | RGB_III_888, 24 | D_I_8, 25 | D_F_32, 26 | 27 | D_I_16, 28 | D_F_64, 29 | 30 | RGBA_IIII_8888 31 | }; 32 | 33 | EPixelFormat Parse(const std::string &fmt); 34 | std::string TypeOf(EPixelFormat); 35 | size_t GetPixelSize(EPixelFormat); 36 | bool IsRGB(EPixelFormat); 37 | bool IsGrey(EPixelFormat); 38 | bool ISDepth(EPixelFormat); 39 | } 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /framework/shared/include/io/SLAMFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_SLAMFILE_H 12 | #define IO_SLAMFILE_H 13 | 14 | #include "FrameSource.h" 15 | #include "sensor/SensorCollection.h" 16 | #include "serialisation/SLAMFileSerialiser.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace slambench { 22 | namespace io { 23 | class FrameBufferSource; 24 | class SLAMFrame; 25 | class Sensor; 26 | 27 | class SLAMFile : public FrameCollection 28 | { 29 | public: 30 | typedef SensorCollection sensor_container_t; 31 | typedef std::vector frame_container_t; 32 | 33 | typedef char magic_num_t[5]; 34 | typedef uint32_t version_t; 35 | 36 | sensor_container_t Sensors; 37 | 38 | static const int Version = 1; 39 | static const magic_num_t MagicNum; 40 | 41 | Sensor *GetSensor(const Sensor::sensor_type_t &type); 42 | 43 | SLAMFrame* GetFrame(unsigned int index) override; 44 | unsigned int GetFrameCount() override; 45 | 46 | void AddFrame(SLAMFrame *frame); 47 | 48 | static SLAMFile *Read(const std::string &filename, FrameBufferSource &fb_source); 49 | static bool Write(const std::string &filename, SLAMFile &file, SLAMFileSerialiser::frame_callback_t callback = nullptr); 50 | 51 | private: 52 | void AddGroundTruthFrame(SLAMFrame *frame); 53 | void AddRegularFrame(SLAMFrame *frame); 54 | 55 | frame_container_t frames_; 56 | }; 57 | } 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /framework/shared/include/io/SensorType.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_SENSORTYPE_H 12 | #define IO_SENSORTYPE_H 13 | 14 | namespace slambench { 15 | namespace io { 16 | namespace sensortype { 17 | 18 | } 19 | } 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /framework/shared/include/io/core/Core.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_CORE_H 12 | #define IO_CORE_H 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | namespace slambench { 22 | namespace io { 23 | namespace core { 24 | 25 | size_t FileSize(FILE *file); 26 | 27 | class MappedFile { 28 | public: 29 | MappedFile(void *mapped_ptr, size_t size); 30 | MappedFile(MappedFile && other); 31 | ~MappedFile(); 32 | 33 | const void *Get() { return ptr_; } 34 | size_t Size() { return size_; } 35 | 36 | private: 37 | void *ptr_; 38 | size_t size_; 39 | }; 40 | 41 | MappedFile ReadFile(const std::string &filename); 42 | } 43 | } 44 | } 45 | 46 | #endif /* IO_CORE_H */ 47 | 48 | -------------------------------------------------------------------------------- /framework/shared/include/io/deserialisation/Deserialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_DESERIALISER_H 11 | #define IO_DESERIALISER_H 12 | #include 13 | 14 | namespace slambench { 15 | namespace io { 16 | class Deserialiser { 17 | public: 18 | Deserialiser(FILE *target_file); 19 | 20 | FILE *File() const; 21 | bool Read(void *target, size_t bytes) const; 22 | bool Skip(size_t skip) const; 23 | size_t Offset() const; 24 | bool Good() const; 25 | 26 | private: 27 | FILE *target_file_; 28 | }; 29 | } 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /framework/shared/include/io/deserialisation/SLAMFileDeserialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFILEDESERIALISER_H 11 | #define IO_SLAMFILEDESERIALISER_H 12 | 13 | #include "io/deserialisation/Deserialiser.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class FrameBuffer; 18 | class FrameBufferSource; 19 | class SLAMFile; 20 | class SLAMFrame; 21 | 22 | class SLAMFileDeserialiser : public Deserialiser { 23 | public: 24 | SLAMFileDeserialiser(FILE *file, FrameBufferSource *framebuffer_source); 25 | bool Deserialise(SLAMFile &target) const; 26 | 27 | private: 28 | bool DeserialiseHeader(SLAMFile &target) const; 29 | bool DeserialiseFrames(SLAMFile &target) const; 30 | bool DeserialiseFrame(SLAMFile &file, SLAMFrame *&frame) const; 31 | FrameBuffer *GetNextFramebuffer() const; 32 | 33 | FrameBufferSource *fb_source_; 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /framework/shared/include/io/deserialisation/SLAMFileHeaderDeserialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFILEHEADERDESERIALISER_H 11 | #define IO_SLAMFILEHEADERDESERIALISER_H 12 | 13 | #include "io/deserialisation/Deserialiser.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | 18 | class SLAMFileHeaderDeserialiser : public Deserialiser { 19 | public: 20 | SLAMFileHeaderDeserialiser(std::FILE *_file); 21 | bool Deserialise(); 22 | }; 23 | } 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /framework/shared/include/io/deserialisation/SLAMFrameDeserialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFRAMEDESERIALISER_H 11 | #define IO_SLAMFRAMEDESERIALISER_H 12 | 13 | #include "io/deserialisation/Deserialiser.h" 14 | #include "io/FrameSource.h" 15 | 16 | namespace slambench { 17 | namespace io { 18 | class FrameBufferSource; 19 | class SensorCollection; 20 | 21 | class SLAMFrameDeserialiser : public Deserialiser, public slambench::io::FrameStream { 22 | public: 23 | SLAMFrameDeserialiser(FILE *file, SensorCollection &_sensors, FrameBufferSource *fb_source); 24 | SLAMFrame* GetNextFrame() override; 25 | bool HasNextFrame() override; 26 | 27 | private: 28 | SensorCollection &sensors_; 29 | FrameBufferSource *fb_source_; 30 | }; 31 | } 32 | } 33 | 34 | #endif /* SLAMFRAMEDESERIALISER_H */ 35 | 36 | -------------------------------------------------------------------------------- /framework/shared/include/io/deserialisation/SensorCollectionDeserialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_SENSORCOLLECTIONDESERIALISER_H 12 | #define IO_SENSORCOLLECTIONDESERIALISER_H 13 | 14 | #include "io/deserialisation/Deserialiser.h" 15 | 16 | namespace slambench { 17 | namespace io { 18 | class Sensor; 19 | class SensorCollection; 20 | 21 | class SensorCollectionDeserialiser : public Deserialiser { 22 | public: 23 | SensorCollectionDeserialiser(std::FILE *_file); 24 | bool Deserialise(SensorCollection &target) const; 25 | bool DeserialiseSensor(Sensor *&sensor) const; 26 | }; 27 | } 28 | } 29 | 30 | #endif /* SENSORCOLLECTIONDESERIALISER_H */ 31 | 32 | -------------------------------------------------------------------------------- /framework/shared/include/io/format/DataFormatter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_DATAFORMATTER_H 12 | #define IO_DATAFORMATTER_H 13 | 14 | namespace slambench { 15 | namespace io { 16 | class Sensor; 17 | 18 | class DataFormatter { 19 | public: 20 | DataFormatter(Sensor *sensor, void *data); 21 | 22 | Sensor *GetSensor() { return sensor_; } 23 | const Sensor *GetSensor() const { return sensor_; } 24 | 25 | protected: 26 | const void *Data() const { return data_; } 27 | void *Data() { return data_; } 28 | 29 | private: 30 | void *data_; 31 | Sensor *sensor_; 32 | }; 33 | } 34 | } 35 | 36 | #endif /* IO_DATAFORMATTER_H */ 37 | 38 | -------------------------------------------------------------------------------- /framework/shared/include/io/format/EventDataFormatter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_EVENTDATAFORMATTER_H 11 | #define IO_EVENTDATAFORMATTER_H 12 | 13 | #include "io/format/DataFormatter.h" 14 | #include "io/sensor/EventCameraSensor.h" 15 | 16 | #include 17 | 18 | namespace slambench { 19 | namespace io { 20 | class EventData { 21 | public: 22 | uint32_t X, Y; 23 | bool Raised; 24 | }; 25 | 26 | class EventDataFormatter : public DataFormatter { 27 | private: 28 | uint8_t coordsize_; 29 | public: 30 | EventDataFormatter(Sensor *sensor, void *data) : DataFormatter(sensor, data) { coordsize_ = ((EventCameraSensor*)sensor)->GetCoordinateSize(); } 31 | 32 | EventData Get() const { 33 | EventData data; 34 | const char *ptr = (const char*)Data(); 35 | switch(coordsize_) { 36 | case 1: 37 | data.X = *((uint8_t*)ptr++); 38 | data.Y = *((uint8_t*)ptr++); 39 | break; 40 | case 2: 41 | data.X = *((uint16_t*)ptr++); 42 | data.Y = *((uint16_t*)ptr++); 43 | break; 44 | case 4: 45 | data.X = *((uint32_t*)ptr++); 46 | data.Y = *((uint32_t*)ptr++); 47 | break; 48 | } 49 | data.Raised = *ptr; 50 | 51 | return data; 52 | } 53 | 54 | void Put(const EventData &data) { 55 | char *ptr = (char*)Data(); 56 | switch(coordsize_) { 57 | case 1: 58 | *((uint8_t*)ptr++) = data.X; 59 | *((uint8_t*)ptr++) = data.Y; 60 | break; 61 | case 2: 62 | *((uint16_t*)ptr++) = data.X; 63 | *((uint16_t*)ptr++) = data.Y; 64 | break; 65 | case 4: 66 | *((uint32_t*)ptr++) = data.X; 67 | *((uint32_t*)ptr++) = data.Y; 68 | break; 69 | } 70 | *ptr = data.Raised; 71 | } 72 | }; 73 | 74 | } 75 | } 76 | 77 | #endif /* IO_EVENTDATAFORMATTER_H */ 78 | 79 | -------------------------------------------------------------------------------- /framework/shared/include/io/format/PointCloud.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef IO_POINTCLOUD_H 12 | #define IO_POINTCLOUD_H 13 | 14 | #include 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | class Point { 20 | public: 21 | Point() : x(0), y(0), z(0) {} 22 | Point(float x, float y, float z) : x(x), y(y), z(z) {} 23 | 24 | float x, y, z; 25 | }; 26 | 27 | class PointCloud { 28 | public: 29 | typedef std::vector storage_t; 30 | 31 | storage_t &Get() { return points_; } 32 | const storage_t &Get() const { return points_; } 33 | 34 | static PointCloud *FromRaw(char*); 35 | std::vector ToRaw(); 36 | 37 | private: 38 | storage_t points_; 39 | }; 40 | 41 | class PlyReader { 42 | public: 43 | PointCloud *Read(std::istream &file); 44 | }; 45 | 46 | class PlyWriter { 47 | public: 48 | void Write(const PointCloud *cloud, std::ostream &file); 49 | }; 50 | } 51 | } 52 | 53 | #endif /* IO_POINTCLOUD_H */ 54 | 55 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni15/ONI15Frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_ONIFRAME15_H 11 | #define IO_ONIFRAME15_H 12 | 13 | #include "../SLAMFrame.h" 14 | 15 | #define linux true 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace slambench { 22 | namespace io { 23 | class Sensor; 24 | namespace openni15 { 25 | class ONI15Frame : public SLAMFrame { 26 | public: 27 | ONI15Frame(Sensor *sensor, const xn::OutputMetaData *frameref); 28 | ~ONI15Frame(); 29 | void* GetData() override; 30 | void FreeData() override; 31 | }; 32 | } 33 | } 34 | } 35 | 36 | #endif /* IO_ONIFRAME15_H */ 37 | 38 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni15/ONI15FrameStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_ONI15FRAMESTREAM_H 11 | #define IO_ONI15FRAMESTREAM_H 12 | 13 | #include "../FrameSource.h" 14 | 15 | #include 16 | #include 17 | 18 | namespace xn { 19 | class DepthGenerator; 20 | class ImageGenerator; 21 | class MapGenerator; 22 | class Context; 23 | class DepthMetaData; 24 | class ImageMetaData; 25 | } 26 | 27 | namespace slambench { 28 | namespace io { 29 | class Sensor; 30 | class CameraSensor; 31 | namespace openni15 { 32 | 33 | /* 34 | This class represents a stream of frames from OpenNI15 generators. 35 | Once the stream has been created, each desired sensor should be 36 | activated. 37 | */ 38 | class ONI15FrameStream : public FrameStream { 39 | public: 40 | ONI15FrameStream(xn::Context *context) ; 41 | 42 | bool ActivateSensor(CameraSensor *sensor); 43 | bool StartStreams(); 44 | 45 | SLAMFrame* GetNextFrame() override; 46 | bool HasNextFrame() override; 47 | 48 | private: 49 | xn::Context * context_; 50 | xn::DepthGenerator* depth_generator_; 51 | xn::ImageGenerator* image_generator_; 52 | xn::DepthMetaData* DMD_ ; 53 | xn::ImageMetaData* IMD_ ; 54 | std::map _sensor_map; 55 | }; 56 | } 57 | } 58 | } 59 | 60 | #endif /* IO_ONI2FRAMESTREAM_H */ 61 | 62 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni15/ONI15InputInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | #ifdef DO_OPENNI15 10 | #ifndef IO_ONI15INPUTINTERFACE_H 11 | #define IO_ONI15INPUTINTERFACE_H 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace xn { 19 | class Context; 20 | } 21 | namespace slambench { 22 | namespace io { 23 | class CameraSensor; 24 | class DepthSensor; 25 | namespace openni15 { 26 | class ONI15FrameStream; 27 | 28 | class ONI15InputInterface : public InputInterface { 29 | public: 30 | ONI15InputInterface(); 31 | 32 | FrameStream& GetFrames() override; 33 | SensorCollection& GetSensors() override; 34 | 35 | private: 36 | void BuildSensors(); 37 | CameraSensor *BuildCameraSensor() ; 38 | DepthSensor *BuildDepthSensor() ; 39 | 40 | void BuildStream(); 41 | 42 | xn::Context * context_; 43 | ONI15FrameStream *stream_; 44 | 45 | SensorCollection sensors_; 46 | bool sensors_ready_; 47 | }; 48 | } 49 | } 50 | } 51 | 52 | #endif /* IO_ONI15INPUTINTERFACE_H */ 53 | #endif /* DO_OPENNI15 */ 54 | 55 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni2/ONI2Frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_ONIFRAME_H 11 | #define IO_ONIFRAME_H 12 | 13 | #include "../SLAMFrame.h" 14 | 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | class Sensor; 20 | namespace openni2 { 21 | class ONI2Frame : public SLAMFrame { 22 | public: 23 | ONI2Frame(Sensor *sensor, const openni::VideoFrameRef &frameref); 24 | void* GetData() override; 25 | void FreeData() override; 26 | }; 27 | } 28 | } 29 | } 30 | 31 | #endif /* IO_ONIFRAME_H */ 32 | 33 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni2/ONI2FrameStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_ONI2FRAMESTREAM_H 11 | #define IO_ONI2FRAMESTREAM_H 12 | 13 | #include "../FrameSource.h" 14 | 15 | #include 16 | #include 17 | 18 | namespace openni { 19 | class Device; 20 | class VideoStream; 21 | } 22 | 23 | namespace slambench { 24 | namespace io { 25 | class Sensor; 26 | class CameraSensor; 27 | namespace openni2 { 28 | 29 | /* 30 | This class represents a stream of frames from an OpenNI2 device. 31 | Once the stream has been created, each desired sensor should be 32 | activated. 33 | */ 34 | 35 | class ONI2FrameStream : public FrameStream { 36 | public: 37 | ONI2FrameStream(openni::Device *device); 38 | 39 | bool ActivateSensor(CameraSensor *sensor); 40 | bool StartStreams(); 41 | 42 | SLAMFrame* GetNextFrame() override; 43 | bool HasNextFrame() override; 44 | 45 | private: 46 | openni::Device *device_; 47 | 48 | std::vector streams_; 49 | std::map sensor_map_; 50 | }; 51 | 52 | } 53 | } 54 | } 55 | 56 | #endif /* IO_ONI2FRAMESTREAM_H */ 57 | 58 | -------------------------------------------------------------------------------- /framework/shared/include/io/openni2/ONI2InputInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | #ifdef DO_OPENNI20 10 | #ifndef IO_ONI2INPUTINTERFACE_H 11 | #define IO_ONI2INPUTINTERFACE_H 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace openni { 19 | class Device; 20 | class SensorInfo; 21 | } 22 | 23 | namespace slambench { 24 | namespace io { 25 | class CameraSensor; 26 | class DepthSensor; 27 | namespace openni2 { 28 | class ONI2FrameStream; 29 | 30 | class ONI2InputInterface : public InputInterface { 31 | public: 32 | ONI2InputInterface(); 33 | ONI2InputInterface(const std::string& oni2_filename); 34 | 35 | FrameStream& GetFrames() override; 36 | SensorCollection& GetSensors() override; 37 | 38 | private: 39 | void BuildSensors(); 40 | void BuildStream(); 41 | CameraSensor *BuildCameraSensor(const openni::SensorInfo *sensor_info) ; 42 | DepthSensor *BuildDepthSensor(const openni::SensorInfo *sensor_info) ; 43 | 44 | 45 | openni::Device *device_; 46 | ONI2FrameStream *stream_; 47 | 48 | SensorCollection sensors_; 49 | bool sensors_ready_; 50 | }; 51 | } 52 | } 53 | } 54 | 55 | #endif /* IO_ONI2INPUTINTERFACE_H */ 56 | #endif /* DO_OPENNI20 */ -------------------------------------------------------------------------------- /framework/shared/include/io/realsense/RealSense2Frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_REALSENSE2FRAME_H 11 | #define IO_REALSENSE2FRAME_H 12 | 13 | #include "../SLAMFrame.h" 14 | #include 15 | 16 | 17 | namespace slambench { 18 | namespace io { 19 | class Sensor; 20 | namespace realsense { 21 | class RealSense2Frame : public SLAMFrame { 22 | public: 23 | RealSense2Frame(Sensor *sensor, const rs2::frame& frameref); 24 | void* GetData() override; 25 | void FreeData() override; 26 | }; 27 | } 28 | } 29 | } 30 | 31 | #endif /* IO_REALSENSE2FRAME_H */ 32 | 33 | -------------------------------------------------------------------------------- /framework/shared/include/io/realsense/RealSense2FrameStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_REALSENSE2FRAMESTREAM_H 11 | #define IO_REALSENSE2FRAMESTREAM_H 12 | 13 | #include "../FrameSource.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace slambench { 21 | namespace io { 22 | class Sensor; 23 | class CameraSensor; 24 | namespace realsense { 25 | 26 | /* 27 | This class represents a stream of frames from an OpenNI2 device. 28 | Once the stream has been created, each desired sensor should be 29 | activated. 30 | */ 31 | 32 | class RealSense2FrameStream : public FrameStream { 33 | public: 34 | RealSense2FrameStream(rs2::pipeline &pipe); 35 | ~RealSense2FrameStream(); 36 | bool ActivateSensor(rs2_stream stream, Sensor* sensor); 37 | SLAMFrame* GetNextFrame() override; 38 | bool HasNextFrame() override; 39 | // 40 | private: 41 | rs2::pipeline &pipe_; 42 | rs2::frameset frameset_; 43 | std::vector new_frames_; 44 | std::map sensor_map_; 45 | }; 46 | 47 | } 48 | } 49 | } 50 | 51 | #endif /* IO_REALSENSE2FRAMESTREAM_H */ 52 | 53 | -------------------------------------------------------------------------------- /framework/shared/include/io/realsense/RealSense2InputInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | #ifdef DO_REALSENSE 10 | #ifndef IO_REALSENSE2INPUTINTERFACE_H 11 | #define IO_REALSENSE2INPUTINTERFACE_H 12 | 13 | #include 14 | #include 15 | #include "RealSense2FrameStream.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace slambench { 22 | namespace io { 23 | class CameraSensor; 24 | class DepthSensor; 25 | namespace realsense { 26 | class RealSense2FrameStream; 27 | 28 | class RealSense2InputInterface : public InputInterface { 29 | public: 30 | RealSense2InputInterface(); 31 | FrameStream& GetFrames() override; 32 | SensorCollection& GetSensors() override; 33 | inline RealSense2FrameStream& GetStream() {return *stream_;} 34 | 35 | private: 36 | void BuildRGBSensor(const rs2::stream_profile& color_profile); 37 | void BuildDepthSensor(const rs2::stream_profile& depth_profile); 38 | void BuildAccelerometerGyroSensor(const rs2::stream_profile& motion_profile); 39 | void BuildStream(); 40 | 41 | RealSense2FrameStream* stream_; 42 | SensorCollection sensors_; 43 | bool sensors_ready_; 44 | rs2::pipeline pipe_; 45 | //rs2::frameset frameset_; 46 | }; 47 | } 48 | } 49 | } 50 | 51 | #endif /* IO_REALSENSE2INPUTINTERFACE_H */ 52 | #endif /* DO_REALSENSE */ 53 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/AccelerometerSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_ACCELEROMETERSENSOR_H 11 | #define IO_ACCELEROMETERSENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class AccelerometerSensor : public Sensor { 18 | public: 19 | typedef float accel_intrinsic_t[12]; 20 | typedef float accel_noise_variances_t[3]; 21 | typedef float accel_bias_variances_t[3]; 22 | const static sensor_type_t kAccType; 23 | 24 | accel_intrinsic_t Intrinsic; 25 | accel_noise_variances_t NoiseVariances; 26 | accel_bias_variances_t BiasVariances; 27 | 28 | AccelerometerSensor(const sensor_name_t &sensor_name); 29 | size_t GetFrameSize(const SLAMFrame *frame) const override; 30 | 31 | }; 32 | } 33 | } 34 | 35 | #endif /* IO_ACCELEROMETERSENSOR_H */ 36 | 37 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/CameraSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_CAMERA_SENSOR_H 11 | #define IO_CAMERA_SENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | #include "io/FrameFormat.h" 15 | #include "io/PixelFormat.h" 16 | 17 | 18 | namespace slambench { 19 | namespace io { 20 | class CameraSensor : public Sensor { 21 | public: 22 | 23 | 24 | // Intrisics as "Focal Length" and "Principal Point Offset" : fx, fy, cx, cy 25 | typedef float intrinsics_t[4]; 26 | 27 | 28 | // Distortion parameters : radial and tangential factors = k1, k2, p1, p2, p3 29 | // More infos: https://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html 30 | typedef enum {NoDistortion, RadialTangential, Equidistant, KannalaBrandt} distortion_type_t; 31 | typedef float distortion_coefficients_t[5]; 32 | 33 | const static sensor_type_t kCameraType; 34 | CameraSensor(const sensor_name_t &name, const sensor_type_t &type = kCameraType); 35 | 36 | // Resolution 37 | uint32_t Width; 38 | uint32_t Height; 39 | 40 | // Color setting 41 | frameformat::EFrameFormat FrameFormat; 42 | pixelformat::EPixelFormat PixelFormat; 43 | 44 | 45 | 46 | intrinsics_t Intrinsics; 47 | distortion_type_t DistortionType; 48 | distortion_coefficients_t RadialTangentialDistortion; 49 | distortion_coefficients_t EquidistantDistortion; 50 | distortion_coefficients_t Distortion; 51 | 52 | 53 | size_t GetFrameSize(const SLAMFrame *frame) const override; 54 | void CopyIntrinsics(const CameraSensor *other); 55 | void CopyIntrinsics(const intrinsics_t &other); 56 | void CopyRadialTangentialDistortion(const distortion_coefficients_t &other); 57 | void CopyEquidistantDistortion(const distortion_coefficients_t &other); 58 | void CopyDistortion(const distortion_coefficients_t &other, const distortion_type_t& type); 59 | }; 60 | } 61 | } 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/CameraSensorFinder.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_CAMERASENSORFINDER_H 11 | #define IO_CAMERASENSORFINDER_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace slambench { 19 | namespace io { 20 | class SensorCollection; 21 | class CameraSensor; 22 | 23 | typedef std::pair CameraSensorFilter; 24 | 25 | class CameraSensorFinder { 26 | public: 27 | typedef std::function filter_lambda_t; 28 | 29 | CameraSensorFinder(); 30 | 31 | bool TestFilter(const CameraSensor *sensor, const CameraSensorFilter &filter); 32 | std::vector Find(const SensorCollection& sensors, const std::initializer_list &filters); 33 | CameraSensor *FindOne(const SensorCollection &sensors, const std::initializer_list &filters); 34 | 35 | private: 36 | void PrepareEvaluators(); 37 | 38 | std::map filter_evaluators_; 39 | }; 40 | } 41 | } 42 | 43 | #endif /* IO_CAMERASENSORFINDER_H */ 44 | 45 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/DepthSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_DEPTH_SENSOR_H 11 | #define IO_DEPTH_SENSOR_H 12 | 13 | #include "io/sensor/CameraSensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class DepthSensor : public CameraSensor { 18 | public: 19 | DepthSensor(const Sensor::sensor_name_t &sensor_name); 20 | static const sensor_type_t kDepthType; 21 | 22 | typedef float disparity_params_t[2]; 23 | typedef enum 24 | { 25 | affine_disparity = 0x00000000, 26 | kinect_disparity = 0X00000001, 27 | } disparity_type_t; 28 | 29 | disparity_type_t DisparityType; 30 | disparity_params_t DisparityParams; 31 | 32 | void CopyDisparityParams(const DepthSensor *other); 33 | void CopyDisparityParams(const disparity_params_t &other); 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/EventCameraSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_EVENTCAMERASENSOR_H 11 | #define IO_EVENTCAMERASENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class EventCameraSensor : public Sensor { 18 | public: 19 | EventCameraSensor(const sensor_name_t &sensor_name); 20 | static const sensor_type_t kEventCameraType; 21 | 22 | int Width; 23 | int Height; 24 | 25 | size_t GetCoordinateSize() const; 26 | size_t GetFrameSize(const SLAMFrame *frame) const override; 27 | }; 28 | } 29 | } 30 | 31 | #endif /* IO_EVENTCAMERASENSOR_H */ 32 | 33 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/GroundTruthSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_GROUNDTRUTHSENSOR_H 11 | #define IO_GROUNDTRUTHSENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class GroundTruthSensor : public Sensor { 18 | public: 19 | const static sensor_type_t kGroundTruthTrajectoryType; 20 | 21 | GroundTruthSensor(const Sensor::sensor_name_t &sensor_name); 22 | typedef Eigen::Matrix4f pose_t; 23 | size_t GetFrameSize(const SLAMFrame *frame) const override; 24 | 25 | }; 26 | } 27 | } 28 | 29 | #endif /* IO_GROUNDTRUTHSENSOR_H */ 30 | 31 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/GyroSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 Intel Corp. 4 | 5 | This code is licensed under the MIT License. 6 | 7 | */ 8 | 9 | #ifndef IO_GYROSENSOR_H 10 | #define IO_GYROSENSOR_H 11 | 12 | #include "io/sensor/Sensor.h" 13 | 14 | namespace slambench { 15 | namespace io { 16 | class GyroSensor : public Sensor { 17 | public: 18 | typedef float gyro_intrinsic_t[12]; 19 | typedef float gyro_noise_variances_t[3]; 20 | typedef float gyro_bias_variances_t[3]; 21 | const static sensor_type_t kGyroType; 22 | 23 | gyro_intrinsic_t Intrinsic; 24 | gyro_noise_variances_t NoiseVariances; 25 | gyro_bias_variances_t BiasVariances; 26 | 27 | GyroSensor(const sensor_name_t &sensor_name); 28 | size_t GetFrameSize(const SLAMFrame *frame) const override; 29 | 30 | }; 31 | } 32 | } 33 | 34 | #endif /* IO_GYROSENSOR_H */ -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/IMUSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_IMUSENSOR_H 11 | #define IO_IMUSENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class IMUSensor : public Sensor { 18 | public: 19 | static const sensor_type_t kIMUType; 20 | 21 | float GyroscopeNoiseDensity; 22 | float GyroscopeDriftNoiseDensity; 23 | float GyroscopeBiasDiffusion; 24 | 25 | float AcceleratorNoiseDensity; 26 | float AcceleratorBiasDiffusion; 27 | 28 | float AcceleratorSaturation; 29 | float GyroscopeSaturation; 30 | float AcceleratorDriftNoiseDensity; 31 | 32 | IMUSensor(const Sensor::sensor_name_t &sensor_name); 33 | size_t GetFrameSize(const SLAMFrame *frame) const override; 34 | 35 | }; 36 | } 37 | } 38 | 39 | #endif /* IO_IMUSENSOR_H */ 40 | 41 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/OdomSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 Intel Corp. 4 | 5 | This code is licensed under the MIT License. 6 | 7 | */ 8 | 9 | 10 | #ifndef IO_ODOMSENSOR_H 11 | #define IO_ODOMSENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class OdomSensor : public Sensor { 18 | public: 19 | const static sensor_type_t kOdomType; 20 | 21 | OdomSensor(const sensor_name_t &sensor_name); 22 | size_t GetFrameSize(const SLAMFrame *frame) const override; 23 | 24 | }; 25 | } 26 | } 27 | 28 | #endif /* IO_ODOMSENSOR_H */ -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/PointCloudSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_POINTCLOUDSENSOR_H 11 | #define IO_POINTCLOUDSENSOR_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class PointCloudSensor : public Sensor { 18 | public: 19 | static const sensor_type_t kPointCloudType; 20 | 21 | PointCloudSensor(const sensor_name_t &sensor_name); 22 | size_t GetFrameSize(const SLAMFrame *frame) const override; 23 | }; 24 | } 25 | } 26 | 27 | #endif /* IO_POINTCLOUDSENSOR_H */ 28 | 29 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/Sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SENSOR_SENSOR_H 11 | #define IO_SENSOR_SENSOR_H 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | class Serialiser; 20 | class Deserialiser; 21 | class SLAMFrame; 22 | 23 | class Sensor : public ParameterComponent { 24 | public: 25 | typedef std::string sensor_name_t; 26 | typedef std::string sensor_type_t; 27 | typedef Eigen::Matrix4f pose_t; 28 | typedef uint8_t sensor_base_t; 29 | 30 | Sensor(const sensor_name_t &sensor_name, const sensor_type_t &sensor_type); 31 | virtual ~Sensor() = default; 32 | 33 | std::string Description; 34 | uint8_t Index; 35 | pose_t Pose; 36 | float Rate; 37 | float Delay; // Delay between sensor and baseline 38 | 39 | virtual size_t GetFrameSize(const SLAMFrame *frame) const = 0; 40 | const sensor_type_t &GetType() const; 41 | const sensor_name_t &GetName() const; 42 | 43 | void CopyPose(const Sensor *other); 44 | void CopyPose(const pose_t &other); 45 | 46 | bool IsVariableSize() const; 47 | bool IsGroundTruth() const; 48 | 49 | private: 50 | const sensor_name_t sensor_name_; 51 | const sensor_type_t sensor_type_; 52 | }; 53 | 54 | class SensorSerialiser { 55 | public: 56 | virtual ~SensorSerialiser() = default; 57 | bool Serialise(Serialiser *serialiser, const Sensor *sensor); 58 | virtual bool SerialiseSensorSpecific(Serialiser *serialiser, const Sensor *sensor) = 0; 59 | }; 60 | 61 | class SensorDeserialiser { 62 | public: 63 | virtual ~SensorDeserialiser() = default; 64 | bool Deserialise(const Sensor::sensor_name_t &sensor_name, const Sensor::sensor_type_t &type, const Deserialiser *d, Sensor **s); 65 | 66 | virtual bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name, const Sensor::sensor_type_t & type, Sensor **s) = 0; 67 | virtual bool DeserialiseSensorSpecific(const Deserialiser *d, Sensor *s) = 0; 68 | }; 69 | 70 | } 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/SensorCollection.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SENSOR_SENSORCOLLECTION_H 11 | #define IO_SENSOR_SENSORCOLLECTION_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | #include 16 | #include 17 | 18 | namespace slambench { 19 | namespace io { 20 | 21 | class Sensor; 22 | 23 | class SensorCollection { 24 | protected: 25 | typedef std::vector container_t; 26 | 27 | public: 28 | container_t::iterator begin() { return container_.begin(); } 29 | container_t::iterator end() { return container_.end(); } 30 | 31 | container_t::const_iterator begin() const { return container_.begin(); } 32 | container_t::const_iterator end() const { return container_.end(); } 33 | 34 | Sensor &at(unsigned int sensor_idx); 35 | size_t size() const; 36 | 37 | Sensor *GetSensor(const Sensor::sensor_type_t &type); 38 | const Sensor *GetSensor(const Sensor::sensor_type_t &type) const; 39 | 40 | std::vector GetSensors(const Sensor::sensor_type_t & type); 41 | 42 | void AddSensor(Sensor *sensor); 43 | 44 | private: 45 | container_t container_; 46 | 47 | }; 48 | 49 | } 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /framework/shared/include/io/sensor/SensorDatabase.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SENSORDATABASE_H 11 | #define IO_SENSORDATABASE_H 12 | 13 | #include "io/sensor/Sensor.h" 14 | 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | 20 | class SensorDatabaseEntry { 21 | public: 22 | SensorDatabaseEntry(SensorSerialiser *s, SensorDeserialiser *ds, bool ground_truth = false, bool variable_size = false); 23 | 24 | SensorSerialiser *GetSerialiser() const { return serialiser_; } 25 | SensorDeserialiser *GetDeserialiser() const {return deserialiser_; } 26 | bool IsGroundTruth() const { return is_ground_truth_; } 27 | bool IsVariableSize() const { return is_variable_size_; } 28 | 29 | private: 30 | SensorSerialiser *serialiser_; 31 | SensorDeserialiser *deserialiser_; 32 | bool is_ground_truth_; 33 | bool is_variable_size_; 34 | }; 35 | 36 | class SensorDatabase { 37 | public: 38 | SensorDatabaseEntry &Get(const Sensor::sensor_type_t &sensor_name); 39 | 40 | void RegisterSensor(const Sensor::sensor_type_t &sensor_name, const SensorDatabaseEntry &entry); 41 | static SensorDatabase *Singleton(void); 42 | 43 | private: 44 | std::map registrations_; 45 | static SensorDatabase *singleton_; 46 | }; 47 | 48 | class SensorDatabaseRegistration { 49 | public: 50 | SensorDatabaseRegistration(const Sensor::sensor_type_t &name, const SensorDatabaseEntry &entry); 51 | }; 52 | } 53 | } 54 | 55 | #endif /* IO_SENSORDATABASE_H */ 56 | 57 | -------------------------------------------------------------------------------- /framework/shared/include/io/serialisation/SLAMFileHeaderSerialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFILEHEADERSERIALISER_H 11 | #define IO_SLAMFILEHEADERSERIALISER_H 12 | 13 | #include "io/serialisation/Serialiser.h" 14 | 15 | namespace slambench { 16 | namespace io { 17 | class SLAMFile; 18 | class Sensor; 19 | 20 | class SLAMFileHeaderSerialiser : public Serialiser { 21 | public: 22 | SLAMFileHeaderSerialiser(FILE *target); 23 | 24 | bool Serialise(const SLAMFile &file); 25 | 26 | private: 27 | bool SerialiseHeader(const SLAMFile &file); 28 | bool SerialiseSensor(const Sensor &sensor); 29 | }; 30 | } 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /framework/shared/include/io/serialisation/SLAMFileSerialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFILESERIALISER_H 11 | #define IO_SLAMFILESERIALISER_H 12 | 13 | #include "io/serialisation/Serialiser.h" 14 | 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | class SLAMFile; 20 | 21 | class SLAMFileSerialiser : public Serialiser { 22 | public: 23 | SLAMFileSerialiser(FILE *target); 24 | 25 | bool Serialise(SLAMFile &file); 26 | 27 | typedef void (*frame_callback_t)(int frame_num, int frame_count); 28 | frame_callback_t FrameCallback; 29 | 30 | private: 31 | bool SerialiseHeader(const SLAMFile &file); 32 | 33 | bool SerialiseFrames(SLAMFile &file); 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /framework/shared/include/io/serialisation/SLAMFrameSerialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SLAMFRAMESERIALISER_H 11 | #define IO_SLAMFRAMESERIALISER_H 12 | 13 | #include "io/serialisation/Serialiser.h" 14 | 15 | #include 16 | 17 | namespace slambench { 18 | namespace io { 19 | 20 | class SLAMFrame; 21 | 22 | class SLAMFrameSerialiser : public Serialiser { 23 | public: 24 | SLAMFrameSerialiser(FILE *target); 25 | 26 | bool Serialise(SLAMFrame &frame); 27 | }; 28 | 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /framework/shared/include/io/serialisation/Serialiser.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef IO_SERIALISER_H 11 | #define IO_SERIALISER_H 12 | 13 | #include 14 | 15 | namespace slambench { 16 | namespace io { 17 | class Serialiser { 18 | public: 19 | Serialiser(FILE *target_file); 20 | bool Write(const void *data, size_t size); 21 | protected: 22 | FILE *File(); 23 | 24 | private: 25 | FILE *_file; 26 | }; 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /framework/shared/include/math_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef MATH_TYPES_H_ 12 | #define MATH_TYPES_H_ 13 | 14 | 15 | typedef struct sb_int2 { 16 | int x,y; 17 | } sb_int2; 18 | 19 | 20 | typedef struct sb_uint2 { 21 | unsigned int x,y; 22 | } sb_uint2; 23 | 24 | 25 | typedef struct sb_uint3 { 26 | unsigned int x,y,z; 27 | } sb_int3; 28 | 29 | typedef struct sb_uchar3 { 30 | unsigned char x,y,z; 31 | } sb_uchar3; 32 | 33 | typedef struct sb_uchar4 { 34 | unsigned char x,y,z,w; 35 | } sb_uchar4; 36 | 37 | 38 | typedef struct sb_float3 { 39 | float x,y,z; 40 | } sb_float3; 41 | 42 | 43 | typedef struct sb_float4 { 44 | float x,y,z,w; 45 | } sb_float4; 46 | 47 | 48 | 49 | inline sb_int2 make_sb_int2( int a, int b) {return {a,b};} 50 | 51 | inline sb_uint2 make_sb_uint2(unsigned int a,unsigned int b) {return {a,b};} 52 | 53 | inline sb_uchar3 make_sb_uchar3(unsigned char a,unsigned char b, unsigned char c) {return {a,b,c};} 54 | 55 | inline sb_uchar4 make_sb_uchar4(unsigned char a,unsigned char b, unsigned char c, unsigned char d) {return {a,b,c,d};} 56 | 57 | inline sb_uint3 make_sb_uint3(unsigned int a,unsigned int b, unsigned int c) {return {a,b,c};} 58 | 59 | inline sb_float3 make_sb_float3(float a,float b, float c) {return {a,b,c};} 60 | 61 | inline sb_float4 make_sb_float4(float a,float b, float c, float d) {return {a,b,c,d};} 62 | 63 | 64 | #endif /* MATH_TYPES_H_ */ 65 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/ATEMetric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef ATEMETRIC_H 13 | #define ATEMETRIC_H 14 | 15 | #include "metrics/Metric.h" 16 | 17 | namespace slambench { 18 | namespace outputs { 19 | class TrajectoryInterface; 20 | } 21 | } 22 | 23 | namespace slambench { 24 | namespace metrics { 25 | class ATEMetric : public Metric { 26 | public: 27 | ATEMetric(const slambench::outputs::TrajectoryInterface *tested_trajectory, const slambench::outputs::TrajectoryInterface *ground_truth); 28 | const slambench::values::ValueDescription& GetValueDescription() const override; 29 | const std::string& GetDescription() const override; 30 | void MeasureStart(Phase* phase) override; 31 | void MeasureEnd(Phase* phase) override; 32 | Value *GetValue(Phase* phase) override; 33 | 34 | private: 35 | const outputs::TrajectoryInterface *trajectory_; 36 | const outputs::TrajectoryInterface *ground_truth_; 37 | values::TrajectoryValue::pose_container_t latest_trajectory_; 38 | slambench::TimeStamp next_gt_ts_; 39 | }; 40 | } 41 | } 42 | 43 | #endif /* ATEMETRIC_H */ 44 | 45 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/DepthEstimationMetric.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPTHESTIMATIONMETRIC_H 2 | #define DEPTHESTIMATIONMETRIC_H 3 | #include "Metric.h" 4 | #include 5 | 6 | namespace slambench { 7 | namespace metrics { 8 | 9 | using slambench::values::FrameValue; 10 | 11 | class DepthEstimationMetric : public Metric { 12 | 13 | public: 14 | DepthEstimationMetric(const slambench::outputs::BaseOutput * const tested, 15 | const slambench::outputs::BaseOutput * const gt); 16 | 17 | ~DepthEstimationMetric() = default; 18 | 19 | const slambench::values::ValueDescription& GetValueDescription() const override; 20 | const std::string& GetDescription() const override; 21 | void MeasureStart(Phase* phase) override; 22 | void MeasureEnd(Phase* phase) override; 23 | Value *GetValue(Phase* phase) override; 24 | 25 | private: 26 | const slambench::outputs::BaseOutput * const tested_; 27 | const slambench::outputs::BaseOutput * const gt_; 28 | 29 | }; 30 | } 31 | } 32 | 33 | #endif //DEPTHESTIMATIONMETRIC_H 34 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/DurationMetric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef DURATIONMETRIC_H 13 | #define DURATIONMETRIC_H 14 | 15 | #include "Metric.h" 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace slambench { 23 | namespace values { 24 | class Value; 25 | } 26 | namespace metrics { 27 | class Phase; 28 | 29 | class DurationMetric : public Metric { 30 | public: 31 | DurationMetric(); 32 | 33 | virtual void MeasureStart(Phase* phase) override; 34 | virtual void MeasureEnd(Phase* phase) override; 35 | values::Value *GetValue(Phase *phase) override; 36 | const slambench::values::ValueDescription& GetValueDescription() const override; 37 | const std::string &GetDescription() const override; 38 | 39 | private: 40 | std::unordered_map phase_start_; 41 | std::unordered_map phase_end_; 42 | uint64_t getTime() const; 43 | }; 44 | 45 | } 46 | } 47 | 48 | #endif /* DURATIONMETRIC_H */ 49 | 50 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/FrameData.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEDATA_H 11 | #define FRAMEDATA_H 12 | 13 | #include 14 | 15 | namespace slambench { 16 | namespace values { 17 | class Value; 18 | } 19 | namespace metrics { 20 | class Metric; 21 | class Phase; 22 | 23 | typedef std::map PhaseData; 24 | 25 | class FrameData { 26 | public: 27 | FrameData() = default; 28 | ~FrameData() {phase_data_.clear();frame_data_.clear();}; 29 | PhaseData &GetPhaseData(Phase *p) { return phase_data_[p]; } 30 | PhaseData &GetFrameData() { return frame_data_; } 31 | void Clear() { phase_data_.clear(); frame_data_.clear(); } 32 | 33 | private: 34 | std::map phase_data_; 35 | PhaseData frame_data_; 36 | }; 37 | } 38 | } 39 | 40 | #endif /* FRAMEDATA_H */ 41 | 42 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/MemoryMetric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef MEMORYMETRIC_H 11 | #define MEMORYMETRIC_H 12 | 13 | #include "Metric.h" 14 | #include "memory_utils/CUDAMonitor.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace slambench { 21 | namespace metrics { 22 | class Phase; 23 | 24 | class MemoryMetric : public Metric { 25 | public: 26 | MemoryMetric(); 27 | ~MemoryMetric(); 28 | 29 | virtual void MeasureStart(Phase* phase) override; 30 | virtual void MeasureEnd(Phase* phase) override; 31 | values::Value *GetValue(Phase* phase) override; 32 | const values::ValueDescription &GetValueDescription() const override; 33 | const std::string &GetDescription() const override; 34 | 35 | private: 36 | // CUDAMonitor cuda_monitor; 37 | slambench::values::ValueDescription desc_; 38 | std::unordered_map CPU_Usage_; 39 | std::unordered_map GPU_Usage_; 40 | 41 | }; 42 | } 43 | } 44 | 45 | #endif /* CPUMEMORYMETRIC_H */ 46 | 47 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/Metric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef METRIC_H 13 | #define METRIC_H 14 | 15 | #include "MetricValue.h" 16 | #include "SLAMBenchLibraryHelper.h" 17 | #include "io/SLAMFrame.h" 18 | #include "values/Value.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace slambench { 25 | namespace metrics { 26 | class Phase; 27 | using values::Value; 28 | 29 | // Class representing a metric such as power, time, memory usage, etc. 30 | class Metric { 31 | public: 32 | Metric(const std::string &name); 33 | virtual ~Metric(); 34 | 35 | virtual void MeasureStart(Phase *phase) = 0; 36 | virtual void MeasureEnd(Phase *phase) = 0; 37 | 38 | virtual Value *GetValue(Phase *phase) = 0; 39 | virtual const values::ValueDescription &GetValueDescription() const = 0; 40 | 41 | const std::string &GetName() const { return name_; } 42 | virtual const std::string &GetDescription() const = 0; 43 | 44 | private: 45 | const std::string name_; 46 | 47 | }; 48 | } 49 | } 50 | 51 | #endif /* METRIC_H */ 52 | 53 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/MetricValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef METRICVALUE_H 13 | #define METRICVALUE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace slambench { 21 | namespace metrics { 22 | class MetricValue { 23 | private: 24 | MetricValue(size_t size, void *data) { data_.resize(size); memcpy(data_.data(), data, size); } 25 | public: 26 | MetricValue(const MetricValue &other) : data_(other.data_) {} 27 | 28 | template MetricValue(T value) : MetricValue(sizeof(value), &value) {} 29 | 30 | const void *GetStorage() const { return (void*)data_.data(); } 31 | template T As() const { assert(sizeof(T) == data_.size()); return *(T*)GetStorage(); } 32 | private: 33 | std::vector data_; 34 | }; 35 | } 36 | } 37 | 38 | #endif /* METRICVALUE_H */ 39 | 40 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/Phase.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef PHASE_H 13 | #define PHASE_H 14 | 15 | #include "MetricValue.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace slambench { 21 | namespace metrics { 22 | class Metric; 23 | class MetricManager; 24 | 25 | // Class representing a phase (i.e., a duration) of an algorithm 26 | class Phase { 27 | public: 28 | Phase(MetricManager *mgr, const std::string &phasename); 29 | 30 | void Begin(); 31 | void End(); 32 | const std::string &GetName() { return name_; } 33 | 34 | private: 35 | const std::string name_; 36 | MetricManager *manager_; 37 | }; 38 | } 39 | } 40 | 41 | #endif /* PHASE_H */ 42 | 43 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/PointCloudMetric.h: -------------------------------------------------------------------------------- 1 | #ifndef POINTCLOUDMETRIC_H 2 | #define POINTCLOUDMETRIC_H 3 | 4 | #include "metrics/Metric.h" 5 | #include "outputs/Output.h" 6 | 7 | namespace slambench { 8 | namespace metrics { 9 | 10 | using slambench::values::PointCloudValue; 11 | 12 | class PointCloudMetric : public Metric { 13 | private: 14 | const slambench::outputs::BaseOutput * const heatmap_pointcloud; 15 | 16 | slambench::TimeStamp lastMeasurement; 17 | 18 | public: 19 | PointCloudMetric(const slambench::outputs::BaseOutput * const heatmap_pointcloud); 20 | 21 | ~PointCloudMetric() = default; 22 | 23 | const slambench::values::ValueDescription& GetValueDescription() const override; 24 | const std::string& GetDescription() const override; 25 | void MeasureStart(Phase* phase) override; 26 | void MeasureEnd(Phase* phase) override; 27 | Value *GetValue(Phase* phase) override; 28 | }; 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/PowerMetric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef POWERMETRIC_H 13 | #define POWERMETRIC_H 14 | 15 | #include "metrics/Metric.h" 16 | #include "metrics/power_utils/PowerMonitor.h" 17 | 18 | namespace slambench { 19 | namespace metrics { 20 | class PowerMetric : public Metric { 21 | 22 | public: 23 | PowerMetric(); 24 | 25 | const slambench::values::ValueDescription& GetValueDescription() const override; 26 | const std::string& GetDescription() const override; 27 | void MeasureStart(Phase* phase) override; 28 | void MeasureEnd(Phase* phase) override; 29 | slambench::values::Value *GetValue(Phase* phase) override; 30 | 31 | private : 32 | PowerMonitor *pm_ = nullptr; 33 | slambench::values::Value *last_res_; 34 | }; 35 | } 36 | } 37 | 38 | #endif /* POWERMETRIC_H */ 39 | 40 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/RPEMetric.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef RPEMETRIC_H 11 | #define RPEMETRIC_H 12 | 13 | #include "metrics/Metric.h" 14 | #include "outputs/TrajectoryAlignmentMethod.h" 15 | #include "outputs/TrajectoryInterface.h" 16 | 17 | namespace slambench { 18 | namespace metrics { 19 | class RPEMetric : public Metric { 20 | public: 21 | RPEMetric(const slambench::outputs::TrajectoryInterface *tested_trajectory, const slambench::outputs::TrajectoryInterface *ground_truth); 22 | 23 | const slambench::values::ValueDescription& GetValueDescription() const override; 24 | const std::string& GetDescription() const override; 25 | void MeasureStart(Phase* phase) override; 26 | void MeasureEnd(Phase* phase) override; 27 | Value *GetValue(Phase* phase) override; 28 | 29 | private: 30 | const outputs::TrajectoryInterface *trajectory_; 31 | const outputs::TrajectoryInterface *ground_truth_; 32 | values::TrajectoryValue::pose_container_t latest_trajectory_; 33 | slambench::TimeStamp next_gt_ts_; 34 | }; 35 | } 36 | } 37 | 38 | #endif /* RPEMETRIC_H */ 39 | 40 | -------------------------------------------------------------------------------- /framework/shared/include/metrics/power_utils/PowerMonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_SHARED_INCLUDE_METRICS_POWER_UTILS_POWERMONITOR_H_ 11 | #define FRAMEWORK_SHARED_INCLUDE_METRICS_POWER_UTILS_POWERMONITOR_H_ 12 | 13 | class PowerMonitor { 14 | public: 15 | virtual ~PowerMonitor() {}; 16 | virtual const slambench::values::ValueDescription& GetType () const = 0 ; 17 | virtual slambench::values::Value* endSample() = 0; 18 | virtual void startSample() = 0; 19 | 20 | }; 21 | #endif /* FRAMEWORK_SHARED_INCLUDE_METRICS_POWER_UTILS_POWERMONITOR_H_ */ 22 | -------------------------------------------------------------------------------- /framework/shared/include/outputs/OutputManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef OUTPUTMANAGER_H 13 | #define OUTPUTMANAGER_H 14 | 15 | #include "utils.h" 16 | #include "Output.h" 17 | 18 | #include "io/SLAMFile.h" 19 | #include "io/SLAMFrame.h" 20 | #include "io/sensor/SensorCollection.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace slambench { 27 | namespace outputs { 28 | class Output; 29 | 30 | class OutputManager { 31 | public: 32 | typedef std::map output_map_t; 33 | typedef output_map_t::iterator output_map_iterator_t; 34 | 35 | ~OutputManager(); 36 | 37 | 38 | void LoadGTOutputsFromSLAMFile(io::SLAMFile *file); 39 | void LoadGTOutputsFromSLAMFile(io::SensorCollection &sensors, io::FrameCollection *gt_frames, bool with_point_cloud); 40 | 41 | void RegisterOutput(BaseOutput *output); 42 | 43 | BaseOutput *GetOutput(const std::string &outputname); 44 | BaseOutput *GetMainOutput(slambench::values::ValueType); 45 | 46 | output_map_iterator_t begin() { return output_map_.begin(); } 47 | output_map_iterator_t end() { return output_map_.end(); } 48 | 49 | bool WriteFile(const std::string &filename); 50 | size_t OutputCount() const { return output_map_.size(); } 51 | 52 | FastLock &GetLock() { return lock_; } 53 | private: 54 | std::map output_map_; 55 | FastLock lock_; 56 | }; 57 | } 58 | } 59 | 60 | #endif /* OUTPUTMANAGER_H */ 61 | -------------------------------------------------------------------------------- /framework/shared/include/outputs/OutputManagerWriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef OUTPUTMANAGERWRITER_H 13 | #define OUTPUTMANAGERWRITER_H 14 | 15 | #include "io/SLAMFile.h" 16 | #include "TimeStamp.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace slambench { 22 | namespace values { 23 | class Value; 24 | class PoseValue; 25 | class PointCloudValue; 26 | } 27 | namespace outputs { 28 | class BaseOutput; 29 | class OutputManager; 30 | 31 | class OutputManagerWriter { 32 | public: 33 | slambench::io::SLAMFile *GetFile(OutputManager &outman); 34 | bool Write(OutputManager &outman, const std::string &filename); 35 | 36 | private: 37 | bool CreateSensors(OutputManager &outman, slambench::io::SLAMFile &file); 38 | 39 | bool CreateFrames(OutputManager &outman, slambench::io::SLAMFile &file); 40 | slambench::io::SLAMFrame *CreateFrame(BaseOutput *output, TimeStamp ts,const values::Value* value); 41 | slambench::io::SLAMFrame *CreatePoseFrame(BaseOutput *output, TimeStamp ts,const values::PoseValue* value); 42 | slambench::io::SLAMFrame *CreatePointCloudFrame(BaseOutput *output, TimeStamp ts,const values::PointCloudValue* value); 43 | 44 | slambench::io::Sensor *CreateSensor(const BaseOutput *output); 45 | slambench::io::Sensor *CreatePoseSensor(const BaseOutput *output); 46 | slambench::io::Sensor *CreatePointCloudSensor(const BaseOutput *output); 47 | 48 | bool SerialiseFile(slambench::io::SLAMFile &file, const std::string &filename); 49 | 50 | std::map output_map_; 51 | }; 52 | } 53 | } 54 | 55 | #endif /* OUTPUTMANAGERWRITER_H */ 56 | 57 | -------------------------------------------------------------------------------- /framework/shared/include/outputs/PoseOutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef POSEOUTPUT_H 13 | #define POSEOUTPUT_H 14 | 15 | namespace slambench { 16 | namespace outputs { 17 | class PoseOutput { 18 | public: 19 | 20 | private: 21 | 22 | }; 23 | } 24 | } 25 | 26 | #endif /* POSEOUTPUT_H */ 27 | 28 | -------------------------------------------------------------------------------- /framework/shared/include/outputs/TrajectoryAlignmentMethod.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef TRAJECTORYALIGNMENTMETHOD_H 13 | #define TRAJECTORYALIGNMENTMETHOD_H 14 | 15 | #include "values/Value.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace slambench { 21 | namespace outputs { 22 | 23 | class Output; 24 | 25 | class TrajectoryAlignmentMethod { 26 | public: 27 | typedef slambench::values::TrajectoryValue::pose_container_t trajectory_t; 28 | virtual Eigen::Matrix4f operator()(const trajectory_t &ground_truth, const trajectory_t &trajectory) = 0; 29 | virtual ~TrajectoryAlignmentMethod() {}; 30 | }; 31 | 32 | class OriginalTrajectoryAlignmentMethod : public TrajectoryAlignmentMethod { 33 | public: 34 | virtual Eigen::Matrix4f operator()(const trajectory_t &ground_truth, const trajectory_t &trajectory) override; 35 | }; 36 | 37 | 38 | class UmeyamaTrajectoryAlignmentMethod : public TrajectoryAlignmentMethod { 39 | public: 40 | Eigen::Matrix4f operator()(const trajectory_t &ground_truth, const trajectory_t &trajectory) override; 41 | }; 42 | 43 | class NewTrajectoryAlignmentMethod : public TrajectoryAlignmentMethod { 44 | public: 45 | virtual Eigen::Matrix4f operator()(const trajectory_t &ground_truth, const trajectory_t &trajectory) override; 46 | }; 47 | } 48 | } 49 | 50 | #endif /* TRAJECTORYALIGNMENTMETHOD_H */ 51 | 52 | -------------------------------------------------------------------------------- /framework/shared/include/outputs/TrajectoryInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef TRAJECTORYINTERFACE_H 11 | #define TRAJECTORYINTERFACE_H 12 | 13 | #include "outputs/Output.h" 14 | #include "values/Value.h" 15 | 16 | namespace slambench { 17 | namespace outputs { 18 | 19 | /** 20 | * We want to treat multiple things as trajectories so we need a way 21 | * of interfacing with these things in a consistent way. 22 | */ 23 | class TrajectoryInterface { 24 | public: 25 | virtual values::PoseValue Get(const TimeStamp &when) const = 0; 26 | virtual values::TrajectoryValue::pose_container_t GetAll() const = 0; 27 | }; 28 | 29 | class PoseOutputTrajectoryInterface : public TrajectoryInterface { 30 | public: 31 | PoseOutputTrajectoryInterface(BaseOutput *pose_output); 32 | ~PoseOutputTrajectoryInterface() = default; 33 | 34 | values::PoseValue Get(const TimeStamp& when) const override; 35 | values::TrajectoryValue::pose_container_t GetAll() const override; 36 | 37 | private: 38 | void recalculate() const; 39 | BaseOutput *pose_output_; 40 | mutable TimeStamp newest_point_; 41 | mutable values::TrajectoryValue::pose_container_t cached_traj_; 42 | }; 43 | 44 | /** 45 | * Wrapper for TrajectoryValue to implement the TrajectoryInterface 46 | **/ 47 | class TrajectoryValueWrapper : public TrajectoryInterface { 48 | private: 49 | const values::TrajectoryValue *trajectoryValue_; 50 | 51 | public: 52 | TrajectoryValueWrapper(const values::TrajectoryValue *t); 53 | 54 | values::PoseValue Get(const TimeStamp &when) const override; 55 | values::TrajectoryValue::pose_container_t GetAll() const override; 56 | }; 57 | 58 | class TrajectoryOutputInterface : public TrajectoryInterface { 59 | private: 60 | const BaseOutput *trajectory_output_; 61 | public: 62 | TrajectoryOutputInterface(const BaseOutput *t); 63 | 64 | values::PoseValue Get(const TimeStamp &when) const override; 65 | values::TrajectoryValue::pose_container_t GetAll() const override; 66 | }; 67 | } 68 | } 69 | 70 | #endif /* TRAJECTORYINTERFACE_H */ 71 | 72 | -------------------------------------------------------------------------------- /framework/shared/include/sysutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef SYSUTILS_H_ 11 | #define SYSUTILS_H_ 12 | 13 | #include "sys/types.h" 14 | #include "sys/sysinfo.h" 15 | 16 | inline int parseLine(char* line){ 17 | int i = strlen(line); 18 | while (*line < '0' || *line > '9') line++; 19 | line[i-3] = '\0'; 20 | i = atoi(line); 21 | return i; 22 | } 23 | 24 | inline int getValueVmSize(){ //Note: this value is in KB! 25 | FILE* file = fopen("/proc/self/status", "r"); 26 | int result = -1; 27 | char line[128]; 28 | 29 | 30 | while (fgets(line, 128, file) != NULL){ 31 | if (strncmp(line, "VmSize:", 7) == 0){ 32 | result = parseLine(line); 33 | break; 34 | } 35 | } 36 | fclose(file); 37 | return result; 38 | } 39 | 40 | inline int getValueVmRSS(){ //Note: this value is in KB! 41 | FILE* file = fopen("/proc/self/status", "r"); 42 | int result = -1; 43 | char line[128]; 44 | 45 | 46 | while (fgets(line, 128, file) != NULL){ 47 | if (strncmp(line, "VmRSS:", 6) == 0){ 48 | result = parseLine(line); 49 | break; 50 | } 51 | } 52 | fclose(file); 53 | return result; 54 | } 55 | #endif /* SYSUTILS_H_ */ 56 | -------------------------------------------------------------------------------- /framework/shared/include/timings.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef TIMINGS_H 12 | #define TIMINGS_H 13 | 14 | #ifdef __APPLE__ 15 | #include /* clock_t, clock, CLOCKS_PER_SEC */ 16 | #else 17 | #include 18 | #include 19 | 20 | #endif 21 | 22 | 23 | inline float tick() { 24 | std::chrono::time_point tickdata; 25 | tickdata = std::chrono::high_resolution_clock::now(); 26 | static struct timeval t; 27 | 28 | struct timeval diff = t; 29 | gettimeofday(&t, NULL); 30 | 31 | return ((t.tv_sec - diff.tv_sec) * 1000000u + t.tv_usec - diff.tv_usec) 32 | / 1.e6; 33 | 34 | } 35 | 36 | inline double tock() { 37 | #ifdef __APPLE__ 38 | clock_serv_t cclock; 39 | mach_timespec_t clockData; 40 | host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); 41 | clock_get_time(cclock, &clockData); 42 | mach_port_deallocate(mach_task_self(), cclock); 43 | return (double) clockData.tv_sec + clockData.tv_nsec / 1000000000.0; 44 | #else 45 | static auto base = std::chrono::high_resolution_clock::now(); 46 | auto end_of_computation = std::chrono::high_resolution_clock::now(); 47 | std::chrono::duration total_time = end_of_computation - base; 48 | return total_time.count(); 49 | #endif 50 | } 51 | //// this is duplicated to fix otherwise missing references in some of the algorithms 52 | //inline double TICK() 53 | //{ 54 | // return tock(); 55 | //} 56 | //inline double TOCK(std::string str="", int size=0) 57 | //{ 58 | // return tock(); 59 | //} 60 | 61 | #endif //TIMINGS_H 62 | -------------------------------------------------------------------------------- /framework/shared/include/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef FRAMEWORK_SHARED_INCLUDE_UTILS_H_ 12 | #define FRAMEWORK_SHARED_INCLUDE_UTILS_H_ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | inline std::string getFileExt(const std::string& s) { 19 | 20 | std::string str = ""; 21 | size_t i = s.rfind('.', s.length()); 22 | if (i != std::string::npos) { 23 | str = (s.substr(i+1, s.length() - i)); 24 | std::transform(str.begin(), str.end(),str.begin(), ::toupper); 25 | } 26 | return str; 27 | } 28 | 29 | class FastLock { 30 | public: 31 | FastLock() { flag_.clear(); } 32 | void lock() { while(flag_.test_and_set()) ; } 33 | void unlock() { flag_.clear(); } 34 | 35 | private: 36 | std::atomic_flag flag_; 37 | }; 38 | 39 | #endif /* FRAMEWORK_SHARED_INCLUDE_UTILS_H_ */ 40 | -------------------------------------------------------------------------------- /framework/shared/include/values/ValueDispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef VALUEDISPATCH_H 12 | #define VALUEDISPATCH_H 13 | 14 | #include "Value.h" 15 | 16 | namespace slambench { 17 | namespace values { 18 | class Value; 19 | 20 | class ValueDispatch { 21 | public: 22 | virtual ~ValueDispatch(); 23 | 24 | #define DISPATCH(vt) virtual void Dispatch(TypeForVT::type *value) = 0; 25 | DISPATCH(VT_COLLECTION); 26 | DISPATCH(VT_U64); 27 | DISPATCH(VT_DOUBLE); 28 | DISPATCH(VT_STRING); 29 | DISPATCH(VT_TRAJECTORY); 30 | DISPATCH(VT_POSE); 31 | DISPATCH(VT_POINTCLOUD); 32 | DISPATCH(VT_MATRIX); 33 | #undef DISPATCH 34 | }; 35 | 36 | class ConstValueDispatch { 37 | public: 38 | virtual ~ConstValueDispatch(); 39 | 40 | #define DISPATCH(vt) virtual void Dispatch(const TypeForVT::type *value) = 0; 41 | DISPATCH(VT_COLLECTION); 42 | DISPATCH(VT_U64); 43 | DISPATCH(VT_DOUBLE); 44 | DISPATCH(VT_STRING); 45 | DISPATCH(VT_TRAJECTORY); 46 | DISPATCH(VT_POSE); 47 | DISPATCH(VT_POINTCLOUD); 48 | DISPATCH(VT_MATRIX); 49 | #undef DISPATCH 50 | }; 51 | } 52 | } 53 | 54 | #endif /* VALUEDISPATCH_H */ 55 | 56 | -------------------------------------------------------------------------------- /framework/shared/include/values/ValueInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #ifndef VALUEINTERFACE_H 12 | #define VALUEINTERFACE_H 13 | 14 | #include "metrics/MetricManager.h" 15 | #include "metrics/Metric.h" 16 | #include "metrics/Phase.h" 17 | 18 | namespace slambench { 19 | namespace values { 20 | class ValueInterface { 21 | public: 22 | virtual ~ValueInterface(); 23 | virtual const values::Value *Get() = 0; 24 | virtual const values::ValueDescription &GetDescription() const = 0; 25 | }; 26 | 27 | class MetricValueInterface : public ValueInterface { 28 | public: 29 | MetricValueInterface(metrics::MetricManager &manager, metrics::Metric &metric, metrics::Phase &phase) : manager_(manager), metric_(metric), phase_(phase) {} 30 | virtual ~MetricValueInterface() {} 31 | const values::Value *Get() override { return manager_.GetLastFrame()->GetPhaseData(&phase_).at(&metric_); } 32 | const values::ValueDescription &GetDescription() const override { return metric_.GetValueDescription(); } 33 | 34 | private: 35 | metrics::MetricManager &manager_; 36 | metrics::Metric &metric_; 37 | metrics::Phase &phase_; 38 | }; 39 | 40 | class OutputValueInterface : public ValueInterface { 41 | public: 42 | OutputValueInterface(outputs::BaseOutput &output) : output_(output) {} 43 | virtual ~OutputValueInterface() {} 44 | const values::Value* Get() override { return output_.GetMostRecentValue().second; } 45 | const values::ValueDescription &GetDescription() const override { return output_.GetValueDescription(); } 46 | 47 | private: 48 | outputs::BaseOutput &output_; 49 | }; 50 | } 51 | } 52 | 53 | #endif /* VALUEINTERFACE_H */ 54 | 55 | -------------------------------------------------------------------------------- /framework/shared/include/values/ValuePrinter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #ifndef VALUEPRINTER_H 13 | #define VALUEPRINTER_H 14 | 15 | #include "ValueDispatch.h" 16 | 17 | #include 18 | 19 | namespace slambench { 20 | namespace values { 21 | 22 | class ValuePrinter : public ConstValueDispatch { 23 | public: 24 | ValuePrinter(std::ostream &str); 25 | virtual ~ValuePrinter(); 26 | 27 | void Dispatch(const TypeForVT::type* value) override; 28 | void Dispatch(const TypeForVT::type* value) override; 29 | void Dispatch(const TypeForVT::type* value) override; 30 | void Dispatch(const TypeForVT::type* value) override; 31 | void Dispatch(const TypeForVT::type* value) override; 32 | void Dispatch(const TypeForVT::type* value) override; 33 | void Dispatch(const TypeForVT::type* value) override; 34 | void Dispatch(const TypeForVT::type* value) override; 35 | 36 | private: 37 | std::ostream &str_; 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif /* VALUEPRINTER_H */ 44 | 45 | -------------------------------------------------------------------------------- /framework/shared/src/ParameterComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include 12 | #include 13 | 14 | 15 | ParameterComponent::~ParameterComponent() { 16 | 17 | 18 | for (Parameter* it : arguments_) { 19 | delete it; 20 | } 21 | arguments_.clear(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /framework/shared/src/dummy_library.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2014 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include 11 | 12 | bool sb_new_slam_configuration(SLAMBenchLibraryHelper * slam_settings) { 13 | return false; 14 | } 15 | 16 | bool sb_init_slam_system(SLAMBenchLibraryHelper * slam_settings) { 17 | return false; 18 | 19 | } 20 | 21 | bool sb_update_frame (SLAMBenchLibraryHelper * , slambench::io::SLAMFrame* s) { 22 | return false; 23 | } 24 | 25 | bool sb_process_once (SLAMBenchLibraryHelper * slam_settings) { 26 | return false; 27 | } 28 | 29 | bool sb_clean_slam_system() { 30 | return false; 31 | } 32 | 33 | bool sb_update_outputs(SLAMBenchLibraryHelper *lib, const slambench::TimeStamp *timestamp) { 34 | return false; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /framework/shared/src/io/FrameBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/FrameBuffer.h" 11 | 12 | #include 13 | #include 14 | 15 | using namespace slambench::io; 16 | 17 | FrameBuffer::FrameBuffer() : lock_(false), size_(0), data_(nullptr) { 18 | } 19 | 20 | FrameBuffer::~FrameBuffer() { 21 | // This is dangerous if the frame buffer hasn't been released 22 | if(data_) { 23 | free(data_); 24 | } 25 | } 26 | 27 | void FrameBuffer::Acquire() { 28 | if(lock_.exchange(true)) { 29 | throw std::logic_error("FrameBuffer is already locked"); 30 | } 31 | } 32 | 33 | bool FrameBuffer::TryAcquire() { 34 | if(lock_.exchange(true)) return false; 35 | return true; 36 | } 37 | 38 | void FrameBuffer::Release() { 39 | lock_ = false; 40 | } 41 | 42 | void FrameBuffer::ResetBuffer() { 43 | if(data_) { 44 | free(data_); 45 | data_ = malloc(0); 46 | } 47 | } 48 | 49 | bool FrameBuffer::Busy() { 50 | return lock_; 51 | } 52 | 53 | bool FrameBuffer::Reserve(size_t new_size) { 54 | if(new_size > size_) { 55 | size_ = new_size; 56 | } 57 | 58 | if(data_) { 59 | data_ = realloc(data_, size_); 60 | if(data_ == nullptr) return false; 61 | } 62 | 63 | return true; 64 | } 65 | 66 | void *FrameBuffer::Data() { 67 | if(data_ == nullptr) { 68 | data_ = malloc(size_); 69 | } 70 | return data_; 71 | } 72 | -------------------------------------------------------------------------------- /framework/shared/src/io/FrameBufferSource.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/FrameBufferSource.h" 11 | 12 | using namespace slambench::io; 13 | 14 | FrameBuffer *SingleFrameBufferSource::Next() { 15 | return &fb_; 16 | } 17 | -------------------------------------------------------------------------------- /framework/shared/src/io/FrameFormat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/FrameFormat.h" 11 | 12 | #include 13 | 14 | using namespace slambench::io; 15 | 16 | static std::map formats = { 17 | {"raster", frameformat::Raster}, 18 | {"jpeg", frameformat::JPEG}, 19 | {"png", frameformat::PNG} 20 | 21 | }; 22 | 23 | frameformat::EFrameFormat frameformat::Parse(const std::string& str) { 24 | if(formats.count(str)) { 25 | return formats.at(str); 26 | } 27 | return frameformat::UNKNOWN; 28 | } 29 | -------------------------------------------------------------------------------- /framework/shared/src/io/InputInterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "io/InputInterface.h" 12 | #include "io/SLAMFile.h" 13 | #include "io/FrameBufferSource.h" 14 | #include "io/deserialisation/SLAMFileHeaderDeserialiser.h" 15 | #include "io/deserialisation/SensorCollectionDeserialiser.h" 16 | 17 | using namespace slambench::io; 18 | 19 | InputInterface::~InputInterface() { 20 | 21 | } 22 | 23 | BasicInputInterface::BasicInputInterface(FrameStream& frames, SensorCollection& sensors) : frames_(frames), sensors_(sensors) { 24 | 25 | } 26 | 27 | FrameStream& BasicInputInterface::GetFrames() { 28 | return frames_; 29 | } 30 | 31 | SensorCollection& BasicInputInterface::GetSensors() { 32 | return sensors_; 33 | } 34 | 35 | FileInputInterface::FileInputInterface(SLAMFile& input_file) : file_(input_file), stream_(input_file) { 36 | 37 | } 38 | 39 | FrameStream& FileInputInterface::GetFrames() { 40 | return stream_; 41 | } 42 | 43 | SensorCollection& FileInputInterface::GetSensors() { 44 | return file_.Sensors; 45 | } 46 | 47 | FileStreamInputInterface::FileStreamInputInterface(FILE* input_file, FrameBufferSource *fb_source) : deserialiser_(input_file, sensors_, fb_source) { 48 | // deserialise header and sensors 49 | 50 | if (input_file == nullptr) { 51 | throw std::exception(); 52 | } 53 | 54 | SLAMFileHeaderDeserialiser hdr(input_file); 55 | if(!hdr.Deserialise()) { 56 | throw std::exception(); 57 | } 58 | 59 | SensorCollectionDeserialiser scd(input_file); 60 | if(!scd.Deserialise(sensors_)) { 61 | throw std::exception(); 62 | } 63 | } 64 | 65 | 66 | FrameStream& FileStreamInputInterface::GetFrames() { 67 | return deserialiser_; 68 | } 69 | 70 | SensorCollection& FileStreamInputInterface::GetSensors() { 71 | return sensors_; 72 | } 73 | -------------------------------------------------------------------------------- /framework/shared/src/io/core/Core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #include "io/core/Core.h" 13 | 14 | using namespace slambench::io::core; 15 | 16 | size_t slambench::io::core::FileSize(FILE *file) 17 | { 18 | struct stat st; 19 | fstat(fileno(file), &st); 20 | return st.st_size; 21 | } 22 | 23 | MappedFile::MappedFile(void* mapped_ptr, size_t size) : ptr_(mapped_ptr), size_(size) 24 | { 25 | } 26 | 27 | MappedFile::MappedFile(MappedFile&& other) : ptr_(other.ptr_), size_(other.size_) 28 | { 29 | other.ptr_ = nullptr; 30 | } 31 | 32 | MappedFile::~MappedFile() 33 | { 34 | if (ptr_) { 35 | munmap(ptr_, size_); 36 | } 37 | } 38 | 39 | MappedFile slambench::io::core::ReadFile(const std::string &filename) 40 | { 41 | FILE *file = fopen(filename.c_str(), "r"); 42 | size_t size = FileSize(file); 43 | 44 | void *data = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fileno(file), 0); 45 | if(data == MAP_FAILED) { 46 | throw std::logic_error(""); 47 | } 48 | 49 | fclose(file); 50 | 51 | return MappedFile(data, size); 52 | } 53 | -------------------------------------------------------------------------------- /framework/shared/src/io/deserialisation/Deserialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/deserialisation/Deserialiser.h" 11 | 12 | using namespace slambench::io; 13 | 14 | Deserialiser::Deserialiser(FILE *file) : target_file_(file) {} 15 | 16 | FILE *Deserialiser::File() const { 17 | return target_file_; 18 | } 19 | 20 | bool Deserialiser::Read(void *target, size_t bytes) const { 21 | return fread(target, bytes, 1, File()) == 1; 22 | } 23 | 24 | bool Deserialiser::Skip(size_t bytes) const { 25 | fseek(File(), bytes, SEEK_CUR); 26 | return true; 27 | } 28 | 29 | size_t Deserialiser::Offset() const { 30 | return ftello(File()); 31 | } 32 | 33 | bool Deserialiser::Good() const { 34 | return feof(File()) == 0; 35 | } 36 | -------------------------------------------------------------------------------- /framework/shared/src/io/deserialisation/SLAMFileDeserialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/deserialisation/SLAMFileDeserialiser.h" 11 | #include "io/deserialisation/SLAMFileHeaderDeserialiser.h" 12 | #include "io/deserialisation/SensorCollectionDeserialiser.h" 13 | 14 | #include "io/FrameBuffer.h" 15 | #include "io/FrameBufferSource.h" 16 | #include "io/SLAMFile.h" 17 | #include "io/SLAMFrame.h" 18 | #include "io/sensor/Sensor.h" 19 | 20 | using namespace slambench::io; 21 | 22 | SLAMFileDeserialiser::SLAMFileDeserialiser(FILE *file, FrameBufferSource *fb_source) : Deserialiser(file), fb_source_(fb_source) { 23 | 24 | } 25 | 26 | bool SLAMFileDeserialiser::Deserialise(SLAMFile &target) const { 27 | if(!DeserialiseHeader(target)) return false; 28 | if(!DeserialiseFrames(target)) return false; 29 | return true; 30 | } 31 | 32 | bool SLAMFileDeserialiser::DeserialiseHeader(SLAMFile &target) const { 33 | SLAMFileHeaderDeserialiser d(File()); 34 | if(!d.Deserialise()) { 35 | return false; 36 | } 37 | 38 | SensorCollectionDeserialiser sensor_deserialiser(File()); 39 | if(!sensor_deserialiser.Deserialise(target.Sensors)) { 40 | return false; 41 | } 42 | 43 | return true; 44 | } 45 | 46 | bool SLAMFileDeserialiser::DeserialiseFrames(SLAMFile &target) const { 47 | SLAMFrame *frame; 48 | 49 | while(DeserialiseFrame(target, frame)) { 50 | target.AddFrame(frame); 51 | } 52 | 53 | return true; 54 | } 55 | 56 | bool SLAMFileDeserialiser::DeserialiseFrame(SLAMFile &file, SLAMFrame *&target) const { 57 | DeserialisedFrame *dsf = new DeserialisedFrame(*GetNextFramebuffer(), File()); 58 | 59 | if(!Read(&dsf->Timestamp, sizeof(dsf->Timestamp))) { 60 | delete dsf; 61 | return false; 62 | } 63 | 64 | uint8_t sensor_index = 0; 65 | Read(&sensor_index, sizeof(sensor_index)); 66 | dsf->FrameSensor = &file.Sensors.at(sensor_index); 67 | if(dsf->FrameSensor->IsVariableSize()) { 68 | uint32_t framesize; 69 | Read(&framesize, sizeof(framesize)); 70 | dsf->SetVariableSize(framesize); 71 | } 72 | 73 | dsf->SetOffset(Offset()); 74 | Skip(dsf->FrameSensor->GetFrameSize(dsf)); 75 | 76 | target = dsf; 77 | 78 | return true; 79 | } 80 | 81 | FrameBuffer *SLAMFileDeserialiser::GetNextFramebuffer() const { 82 | return fb_source_->Next(); 83 | } 84 | -------------------------------------------------------------------------------- /framework/shared/src/io/deserialisation/SLAMFileHeaderDeserialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/deserialisation/SLAMFileHeaderDeserialiser.h" 11 | #include "io/SLAMFile.h" 12 | #include "io/sensor/Sensor.h" 13 | #include "io/SensorType.h" 14 | #include "io/sensor/SensorDatabase.h" 15 | #include 16 | #include "io/sensor/GroundTruthSensor.h" 17 | #include "io/deserialisation/SensorCollectionDeserialiser.h" 18 | 19 | using namespace slambench::io; 20 | 21 | SLAMFileHeaderDeserialiser::SLAMFileHeaderDeserialiser(FILE *file) : Deserialiser(file) { 22 | 23 | } 24 | 25 | bool SLAMFileHeaderDeserialiser::Deserialise() { 26 | // check magic number 27 | SLAMFile::magic_num_t mnum; 28 | if(!Read(mnum, sizeof(mnum))) { 29 | fprintf(stderr, "Read failed\n"); 30 | return false; 31 | } 32 | if(strcmp(mnum, SLAMFile::MagicNum) != 0) { 33 | fprintf(stderr, "SLAM file does not have correct magic number (expected %s, got %c%c%c%c)\n", SLAMFile::MagicNum, mnum[0],mnum[1],mnum[2],mnum[3]); 34 | return false; 35 | } 36 | 37 | SLAMFile::version_t version; 38 | Read(&version, sizeof(SLAMFile::version_t)); 39 | if(version != SLAMFile::Version) { 40 | fprintf(stderr, "SLAM file is not correct version (expected %u, got %u)\n", SLAMFile::Version, version); 41 | return false; 42 | } 43 | 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /framework/shared/src/io/deserialisation/SLAMFrameDeserialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "io/deserialisation/SLAMFrameDeserialiser.h" 12 | #include "io/FrameBufferSource.h" 13 | #include "io/SLAMFrame.h" 14 | #include "io/sensor/SensorCollection.h" 15 | #include "io/sensor/Sensor.h" 16 | #include "io/deserialisation/SLAMFileHeaderDeserialiser.h" 17 | 18 | using namespace slambench::io; 19 | 20 | SLAMFrameDeserialiser::SLAMFrameDeserialiser(FILE* file, SensorCollection& sensors, FrameBufferSource *fb_source) : Deserialiser(file), sensors_(sensors), fb_source_(fb_source) { 21 | 22 | } 23 | 24 | SLAMFrame* SLAMFrameDeserialiser::GetNextFrame() { 25 | DeserialisedFrame *dsf = new DeserialisedFrame(*fb_source_->Next(), File()); 26 | 27 | if(!Read(&dsf->Timestamp, sizeof(dsf->Timestamp))) { 28 | delete dsf; 29 | return nullptr; 30 | } 31 | 32 | uint8_t sensor_index = 0; 33 | if (!Read(&sensor_index, sizeof(sensor_index))) { 34 | printf("Could not read sensor data"); 35 | delete dsf; 36 | return nullptr; 37 | } 38 | 39 | if (sensor_index >= sensors_.size()) { 40 | printf("Invalid sensor index (%d), max value is (%d).", 41 | sensor_index, sensors_.size() - 1 ); 42 | delete dsf; 43 | return nullptr; 44 | } 45 | 46 | dsf->FrameSensor = &sensors_.at(sensor_index); 47 | if(dsf->FrameSensor->IsVariableSize()) { 48 | uint32_t framesize; 49 | if (!Read(&framesize, sizeof(framesize))) { 50 | printf("Could not read frame size"); 51 | delete dsf; 52 | return nullptr; 53 | } 54 | dsf->SetVariableSize(framesize); 55 | } 56 | 57 | dsf->SetOffset(Offset()); 58 | Skip(dsf->GetSize()); 59 | 60 | return dsf; 61 | } 62 | 63 | bool SLAMFrameDeserialiser::HasNextFrame() { 64 | return Good(); 65 | } 66 | -------------------------------------------------------------------------------- /framework/shared/src/io/deserialisation/SensorCollectionDeserialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | 12 | #include "io/deserialisation/SensorCollectionDeserialiser.h" 13 | #include "io/sensor/SensorCollection.h" 14 | #include "io/sensor/SensorDatabase.h" 15 | #include "io/sensor/Sensor.h" 16 | #include 17 | 18 | using namespace slambench::io; 19 | 20 | SensorCollectionDeserialiser::SensorCollectionDeserialiser(std::FILE* _file) : Deserialiser(_file) { 21 | 22 | } 23 | 24 | bool SensorCollectionDeserialiser::Deserialise(SensorCollection& target) const { 25 | uint32_t sensor_count; 26 | Read(&sensor_count, sizeof(sensor_count)); 27 | 28 | for(uint32_t i = 0; i < sensor_count; ++i) { 29 | Sensor *sensor; 30 | if(!DeserialiseSensor(sensor)) { 31 | return false; 32 | } 33 | 34 | target.AddSensor(sensor); 35 | } 36 | 37 | return true; 38 | } 39 | 40 | bool SensorCollectionDeserialiser::DeserialiseSensor(Sensor*& sensor) const { 41 | uint8_t sensor_name_size; 42 | Read(&sensor_name_size, sizeof(sensor_name_size)); 43 | std::vector namedata(sensor_name_size); 44 | Read(namedata.data(), sensor_name_size); 45 | 46 | uint8_t sensor_type_size; 47 | Read(&sensor_type_size, sizeof(sensor_type_size)); 48 | std::vector typedata(sensor_type_size); 49 | Read(typedata.data(), sensor_type_size); 50 | 51 | 52 | auto deserialiser = SensorDatabase::Singleton()->Get(typedata.data()).GetDeserialiser(); 53 | return deserialiser->Deserialise(namedata.data(), typedata.data(), this, &sensor); 54 | } 55 | -------------------------------------------------------------------------------- /framework/shared/src/io/format/DataFormatter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "io/format/DataFormatter.h" 12 | 13 | using namespace slambench::io; 14 | 15 | DataFormatter::DataFormatter(Sensor* sensor, void* data) : data_(data), sensor_(sensor) { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /framework/shared/src/io/openni/ONI2Frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/openni2/ONI2Frame.h" 11 | 12 | using namespace slambench::io::openni2; 13 | 14 | ONI2Frame::ONI2Frame(Sensor *sensor, const openni::VideoFrameRef& frameref) { 15 | FrameSensor = sensor; 16 | Timestamp.Ns = frameref.getTimestamp() % 1000000000; 17 | Timestamp.S = frameref.getTimestamp() / 1000000000; 18 | data_ = malloc(frameref.getDataSize()); 19 | memcpy(data_, frameref.getData(), frameref.getDataSize()); 20 | } 21 | 22 | void* ONI2Frame::GetData() { 23 | return data_; 24 | } 25 | 26 | void ONI2Frame::FreeData() { 27 | free(data_); 28 | data_ = nullptr; 29 | } 30 | -------------------------------------------------------------------------------- /framework/shared/src/io/openni15/ONI15Frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/openni15/ONI15Frame.h" 11 | #include 12 | 13 | using namespace slambench::io::openni15; 14 | 15 | ONI15Frame::ONI15Frame(Sensor * sensor, const xn::OutputMetaData * md) { 16 | 17 | FrameSensor = sensor; 18 | Timestamp.Ns = md->Timestamp() % 1000000000; 19 | Timestamp.S = md->Timestamp() / 1000000000; 20 | 21 | size_t size = md->DataSize(); 22 | data_ = malloc(size); 23 | const XnUInt8* ptr = md->Data(); 24 | if (ptr) { 25 | memcpy(data_, ptr, size); 26 | } 27 | } 28 | 29 | ONI15Frame::~ONI15Frame() { 30 | FreeData(); 31 | } 32 | 33 | void* ONI15Frame::GetData() { 34 | assert(data_); 35 | return data_; 36 | } 37 | 38 | void ONI15Frame::FreeData() { 39 | free(data_); 40 | data_ = nullptr; 41 | } 42 | -------------------------------------------------------------------------------- /framework/shared/src/io/realsense/RealSense2Frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2020 University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/realsense/RealSense2Frame.h" 11 | 12 | using namespace slambench::io::realsense; 13 | 14 | RealSense2Frame::RealSense2Frame(Sensor *sensor, const rs2::frame& frameref) { 15 | FrameSensor = sensor; 16 | Timestamp.Ns = (int)frameref.get_timestamp() % 1000000000; 17 | Timestamp.S = frameref.get_timestamp() / 1000000000; 18 | data_ = malloc(frameref.get_data_size()); 19 | memcpy(data_, frameref.get_data(), frameref.get_data_size()); 20 | } 21 | 22 | void* RealSense2Frame::GetData() { 23 | return data_; 24 | } 25 | 26 | void RealSense2Frame::FreeData() { 27 | free(data_); 28 | data_ = nullptr; 29 | } 30 | -------------------------------------------------------------------------------- /framework/shared/src/io/realsense/RealSense2FrameStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/realsense/RealSense2FrameStream.h" 11 | #include "io/realsense/RealSense2Frame.h" 12 | #include "io/sensor/CameraSensor.h" 13 | #include "io/sensor/DepthSensor.h" 14 | #include "io/sensor/Sensor.h" 15 | 16 | #include 17 | #include 18 | 19 | using namespace slambench::io::realsense; 20 | using namespace slambench::io; 21 | 22 | RealSense2FrameStream:: 23 | RealSense2FrameStream(rs2::pipeline &pipe) : pipe_(pipe) {} 24 | 25 | RealSense2FrameStream::~RealSense2FrameStream() {} 26 | 27 | SLAMFrame* RealSense2FrameStream::GetNextFrame() { 28 | for(auto frame = new_frames_.begin(); frame < new_frames_.end() ; frame++) 29 | { 30 | auto it = sensor_map_.find(frame->get_profile().stream_type()); 31 | if(it != sensor_map_.end()) 32 | { auto fr = new RealSense2Frame(it->second, *frame); 33 | new_frames_.erase(frame); 34 | return fr; 35 | } 36 | } 37 | return nullptr; 38 | } 39 | 40 | bool RealSense2FrameStream::ActivateSensor(rs2_stream stream, Sensor* sensor) { 41 | sensor_map_[stream] = sensor; 42 | return true; 43 | } 44 | 45 | bool RealSense2FrameStream::HasNextFrame() { 46 | if(!new_frames_.empty()) 47 | return true; 48 | 49 | rs2::frameset frameset; 50 | pipe_.poll_for_frames(&frameset); 51 | for (const rs2::frame& f : frameset) 52 | new_frames_.push_back(f); 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/AccelerometerSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "io/sensor/AccelerometerSensor.h" 12 | #include "io/sensor/SensorDatabase.h" 13 | #include "io/serialisation/Serialiser.h" 14 | #include "io/deserialisation/Deserialiser.h" 15 | 16 | using namespace slambench::io; 17 | 18 | const Sensor::sensor_type_t AccelerometerSensor::kAccType = "Accelerometer"; 19 | 20 | AccelerometerSensor::AccelerometerSensor(const sensor_name_t &sensor_name) : Sensor(sensor_name, kAccType) { 21 | 22 | } 23 | size_t AccelerometerSensor::GetFrameSize(const SLAMFrame *frame) const { 24 | (void)frame; 25 | return 3 * sizeof(float); 26 | } 27 | 28 | class ACCSerialiser : public SensorSerialiser { 29 | bool SerialiseSensorSpecific(Serialiser* serialiser, const Sensor* s) override { 30 | AccelerometerSensor *sensor = (AccelerometerSensor*)s; 31 | 32 | serialiser->Write(&sensor->Intrinsic , sizeof(sensor->Intrinsic)); 33 | serialiser->Write(&sensor->NoiseVariances, sizeof(sensor->NoiseVariances)); 34 | serialiser->Write(&sensor->BiasVariances, sizeof(sensor->BiasVariances)); 35 | 36 | return true; 37 | } 38 | }; 39 | 40 | class ACCDeserialiser : public SensorDeserialiser { 41 | bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name,const Sensor::sensor_type_t &type, Sensor** s) override { 42 | if(type != AccelerometerSensor::kAccType) { 43 | return false; 44 | } 45 | 46 | *s = new AccelerometerSensor(sensor_name); 47 | 48 | return true; 49 | } 50 | 51 | bool DeserialiseSensorSpecific(const Deserialiser* d, Sensor* s) override { 52 | AccelerometerSensor *sensor = (AccelerometerSensor*)s; 53 | 54 | d->Read(&sensor->Intrinsic , sizeof(sensor->Intrinsic)); 55 | d->Read(&sensor->NoiseVariances, sizeof(sensor->NoiseVariances)); 56 | d->Read(&sensor->BiasVariances, sizeof(sensor->BiasVariances)); 57 | 58 | return true; 59 | } 60 | }; 61 | 62 | static slambench::io::SensorDatabaseRegistration acc_reg(AccelerometerSensor::kAccType, slambench::io::SensorDatabaseEntry(new ACCSerialiser(), new ACCDeserialiser(), false, false)); 63 | 64 | 65 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/GroundTruthSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "io/sensor/GroundTruthSensor.h" 12 | #include "io/sensor/SensorDatabase.h" 13 | 14 | using namespace slambench::io; 15 | 16 | const Sensor::sensor_type_t GroundTruthSensor::kGroundTruthTrajectoryType = "GroundTruthTrajectory"; 17 | 18 | GroundTruthSensor::GroundTruthSensor(const Sensor::sensor_name_t &sensor_name) : Sensor(sensor_name, kGroundTruthTrajectoryType) { 19 | } 20 | 21 | size_t GroundTruthSensor::GetFrameSize(const SLAMFrame *frame) const { 22 | (void)frame; 23 | return sizeof(pose_t); 24 | } 25 | 26 | class GTSerialiser : public SensorSerialiser { 27 | bool SerialiseSensorSpecific(Serialiser* serialiser, const Sensor* sensor) override { 28 | // nothing to do 29 | (void)serialiser; 30 | (void)sensor; 31 | return true; 32 | } 33 | }; 34 | 35 | class GTDeserialiser : public SensorDeserialiser { 36 | bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name, const Sensor::sensor_type_t &type, Sensor** s) override { 37 | if(type != GroundTruthSensor::kGroundTruthTrajectoryType) { 38 | return false; 39 | } 40 | 41 | *s = new GroundTruthSensor(sensor_name); 42 | 43 | return true; 44 | } 45 | 46 | bool DeserialiseSensorSpecific(const Deserialiser* d, Sensor* s) override { 47 | // nothing to do 48 | (void)d; 49 | (void)s; 50 | return true; 51 | } 52 | }; 53 | 54 | static slambench::io::SensorDatabaseRegistration gt_reg(GroundTruthSensor::kGroundTruthTrajectoryType, slambench::io::SensorDatabaseEntry(new GTSerialiser(), new GTDeserialiser(), true, false)); 55 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/GyroSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 Intel Corp. 4 | 5 | This code is licensed under the MIT License. 6 | 7 | */ 8 | 9 | 10 | #include "io/sensor/GyroSensor.h" 11 | #include "io/sensor/SensorDatabase.h" 12 | #include "io/serialisation/Serialiser.h" 13 | #include "io/deserialisation/Deserialiser.h" 14 | 15 | using namespace slambench::io; 16 | 17 | const Sensor::sensor_type_t GyroSensor::kGyroType = "Gyro"; 18 | 19 | GyroSensor::GyroSensor(const sensor_name_t &sensor_name) : Sensor(sensor_name, kGyroType) { 20 | 21 | } 22 | size_t GyroSensor::GetFrameSize(const SLAMFrame *frame) const { 23 | (void)frame; 24 | return 3 * sizeof(float); 25 | } 26 | 27 | class GyroSerialiser : public SensorSerialiser { 28 | bool SerialiseSensorSpecific(Serialiser* serialiser, const Sensor* s) override { 29 | GyroSensor *sensor = (GyroSensor*)s; 30 | 31 | serialiser->Write(&sensor->Intrinsic , sizeof(sensor->Intrinsic)); 32 | serialiser->Write(&sensor->NoiseVariances, sizeof(sensor->NoiseVariances)); 33 | serialiser->Write(&sensor->BiasVariances, sizeof(sensor->BiasVariances)); 34 | 35 | return true; 36 | } 37 | }; 38 | 39 | class GyroDeserialiser : public SensorDeserialiser { 40 | bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name,const Sensor::sensor_type_t &type, Sensor** s) override { 41 | if(type != GyroSensor::kGyroType) { 42 | return false; 43 | } 44 | 45 | *s = new GyroSensor(sensor_name); 46 | 47 | return true; 48 | } 49 | 50 | bool DeserialiseSensorSpecific(const Deserialiser* d, Sensor* s) override { 51 | GyroSensor *sensor = (GyroSensor*)s; 52 | 53 | d->Read(&sensor->Intrinsic , sizeof(sensor->Intrinsic)); 54 | d->Read(&sensor->NoiseVariances, sizeof(sensor->NoiseVariances)); 55 | d->Read(&sensor->BiasVariances, sizeof(sensor->BiasVariances)); 56 | 57 | return true; 58 | } 59 | }; 60 | 61 | static slambench::io::SensorDatabaseRegistration gyro_reg(GyroSensor::kGyroType, slambench::io::SensorDatabaseEntry(new GyroSerialiser(), new GyroDeserialiser(), false, false)); 62 | 63 | 64 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/OdomSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 Intel Corp. 4 | 5 | This code is licensed under the MIT License. 6 | 7 | */ 8 | 9 | 10 | #include "io/sensor/OdomSensor.h" 11 | #include "io/sensor/SensorDatabase.h" 12 | 13 | using namespace slambench::io; 14 | 15 | const Sensor::sensor_type_t OdomSensor::kOdomType = "Odom"; 16 | 17 | OdomSensor::OdomSensor(const sensor_name_t &sensor_name) : Sensor(sensor_name, kOdomType) { 18 | 19 | } 20 | size_t OdomSensor::GetFrameSize(const SLAMFrame *frame) const { 21 | (void)frame; 22 | return 13 * sizeof(float); 23 | } 24 | 25 | class OdomSerialiser : public SensorSerialiser { 26 | bool SerialiseSensorSpecific(Serialiser* serialiser, const Sensor* sensor) override { 27 | // nothing to do 28 | (void)serialiser; 29 | (void)sensor; 30 | return true; 31 | } 32 | }; 33 | 34 | class OdomDeserialiser : public SensorDeserialiser { 35 | bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name,const Sensor::sensor_type_t &type, Sensor** s) override { 36 | if(type != OdomSensor::kOdomType) { 37 | return false; 38 | } 39 | 40 | *s = new OdomSensor(sensor_name); 41 | 42 | return true; 43 | } 44 | 45 | bool DeserialiseSensorSpecific(const Deserialiser* d, Sensor* s) override { 46 | // nothing to do 47 | (void)d; 48 | (void)s; 49 | return true; 50 | } 51 | }; 52 | 53 | static slambench::io::SensorDatabaseRegistration odom_reg(OdomSensor::kOdomType, slambench::io::SensorDatabaseEntry(new OdomSerialiser(), new OdomDeserialiser(), false, false)); 54 | 55 | 56 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/PointCloudSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/SLAMFrame.h" 11 | #include "io/sensor/PointCloudSensor.h" 12 | #include "io/sensor/SensorDatabase.h" 13 | 14 | using namespace slambench::io; 15 | 16 | const Sensor::sensor_type_t PointCloudSensor::kPointCloudType = "PointCloud"; 17 | 18 | PointCloudSensor::PointCloudSensor(const sensor_name_t &sensor_name) : Sensor(sensor_name, kPointCloudType) 19 | {} 20 | 21 | size_t PointCloudSensor::GetFrameSize(const SLAMFrame *frame) const { 22 | return frame->GetVariableSize(); 23 | } 24 | 25 | class PCSerialiser : public SensorSerialiser { 26 | bool SerialiseSensorSpecific(Serialiser* serialiser, const Sensor* sensor) override { 27 | // nothing to do 28 | (void)serialiser; 29 | (void)sensor; 30 | return true; 31 | } 32 | }; 33 | 34 | class PCDeserialiser : public SensorDeserialiser { 35 | bool InstantiateSensor(const Sensor::sensor_name_t &sensor_name, const Sensor::sensor_type_t &type, Sensor** s) override { 36 | if(type != PointCloudSensor::kPointCloudType) { 37 | return false; 38 | } 39 | 40 | *s = new PointCloudSensor(sensor_name); 41 | 42 | return true; 43 | } 44 | 45 | bool DeserialiseSensorSpecific(const Deserialiser* d, Sensor* s) override { 46 | // nothing to do 47 | (void)d; 48 | (void)s; 49 | return true; 50 | } 51 | }; 52 | 53 | static slambench::io::SensorDatabaseRegistration rgb_reg(PointCloudSensor::kPointCloudType, slambench::io::SensorDatabaseEntry(new PCSerialiser(), new PCDeserialiser(), true, true)); 54 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/SensorCollection.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/sensor/SensorCollection.h" 11 | #include "io/sensor/Sensor.h" 12 | 13 | #include 14 | 15 | using namespace slambench::io; 16 | 17 | Sensor &SensorCollection::at(unsigned int sensor_idx) { 18 | return *container_.at(sensor_idx); 19 | } 20 | 21 | size_t SensorCollection::size() const { 22 | return container_.size(); 23 | } 24 | 25 | void SensorCollection::AddSensor(Sensor* sensor) { 26 | if(sensor == nullptr) { 27 | throw std::logic_error("Cannot add a null sensor to SensorCollection"); 28 | } 29 | sensor->Index = container_.size(); 30 | container_.push_back(sensor); 31 | } 32 | 33 | Sensor* SensorCollection::GetSensor(const Sensor::sensor_type_t & type) { 34 | for(auto &i : container_) { 35 | if(i->GetType() == type) { 36 | return i; 37 | } 38 | } 39 | 40 | return nullptr; 41 | } 42 | 43 | const Sensor* SensorCollection::GetSensor(const Sensor::sensor_type_t & type) const { 44 | for(auto &i : container_) { 45 | if(i->GetType() == type) { 46 | return i; 47 | } 48 | } 49 | 50 | return nullptr; 51 | } 52 | 53 | std::vector SensorCollection::GetSensors(const Sensor::sensor_type_t & type) { 54 | std::vector output; 55 | for(auto &i : container_) { 56 | if(i->GetType() == type) { 57 | output.push_back(i); 58 | } 59 | } 60 | return output; 61 | } 62 | -------------------------------------------------------------------------------- /framework/shared/src/io/sensor/SensorDatabase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/sensor/SensorDatabase.h" 11 | 12 | #include 13 | 14 | using namespace slambench::io; 15 | 16 | SensorDatabase *SensorDatabase::singleton_; 17 | 18 | SensorDatabase* SensorDatabase::Singleton() 19 | { 20 | if(singleton_ == nullptr) { 21 | singleton_ = new SensorDatabase(); 22 | } 23 | return singleton_; 24 | } 25 | 26 | SensorDatabaseEntry::SensorDatabaseEntry(SensorSerialiser* s, SensorDeserialiser* ds, bool ground_truth, bool variable_size) : serialiser_(s), deserialiser_(ds), is_ground_truth_(ground_truth), is_variable_size_(variable_size) 27 | { 28 | 29 | } 30 | 31 | SensorDatabaseEntry& SensorDatabase::Get(const Sensor::sensor_type_t& sensor_name) 32 | { 33 | return registrations_.at(sensor_name); 34 | } 35 | 36 | void SensorDatabase::RegisterSensor(const Sensor::sensor_type_t& sensor_name, const SensorDatabaseEntry& entry) 37 | { 38 | registrations_.insert({sensor_name, entry}); 39 | } 40 | 41 | SensorDatabaseRegistration::SensorDatabaseRegistration(const Sensor::sensor_type_t& name, const SensorDatabaseEntry& entry) 42 | { 43 | SensorDatabase::Singleton()->RegisterSensor(name, entry); 44 | } 45 | -------------------------------------------------------------------------------- /framework/shared/src/io/serialisation/SLAMFileHeaderSerialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/serialisation/SLAMFileHeaderSerialiser.h" 11 | #include "io/SLAMFile.h" 12 | #include "io/sensor/Sensor.h" 13 | #include "io/sensor/SensorDatabase.h" 14 | 15 | using namespace slambench::io; 16 | 17 | SLAMFileHeaderSerialiser::SLAMFileHeaderSerialiser(FILE *file) : Serialiser(file) { 18 | 19 | } 20 | 21 | bool SLAMFileHeaderSerialiser::Serialise(const SLAMFile &file) { 22 | if(!SerialiseHeader(file)) return false; 23 | 24 | for(const auto &sensor : file.Sensors) { 25 | if(!SerialiseSensor(*sensor)) { 26 | printf("Could not serialise sensor %s\n", sensor->Description.c_str()); 27 | return false; 28 | } 29 | } 30 | 31 | return true; 32 | } 33 | 34 | bool SLAMFileHeaderSerialiser::SerialiseHeader(const SLAMFile &file) { 35 | Write(SLAMFile::MagicNum, sizeof(SLAMFile::MagicNum)); 36 | 37 | uint32_t version = SLAMFile::Version; 38 | Write(&version, sizeof(version)); 39 | 40 | uint32_t sensorcount = file.Sensors.size(); 41 | Write(&sensorcount, sizeof(sensorcount)); 42 | 43 | return true; 44 | } 45 | 46 | bool SLAMFileHeaderSerialiser::SerialiseSensor(const Sensor &sensor) { 47 | if(!SensorDatabase::Singleton()->Get(sensor.GetType()).GetSerialiser()->Serialise(this, &sensor)) return false; 48 | 49 | return true; 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /framework/shared/src/io/serialisation/SLAMFileSerialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/serialisation/SLAMFileSerialiser.h" 11 | #include "io/serialisation/SLAMFileHeaderSerialiser.h" 12 | #include "io/serialisation/SLAMFrameSerialiser.h" 13 | 14 | #include "io/SLAMFile.h" 15 | 16 | #include 17 | #include 18 | 19 | using namespace slambench::io; 20 | 21 | SLAMFileSerialiser::SLAMFileSerialiser(FILE *target) : Serialiser(target), FrameCallback(nullptr) { 22 | 23 | } 24 | 25 | bool SLAMFileSerialiser::Serialise(SLAMFile &file) { 26 | if(!SerialiseHeader(file)) return false; 27 | if(!SerialiseFrames(file)) return false; 28 | return true; 29 | } 30 | 31 | bool SLAMFileSerialiser::SerialiseHeader(const SLAMFile &file) { 32 | SLAMFileHeaderSerialiser sfhs(File()); 33 | 34 | return sfhs.Serialise(file); 35 | } 36 | 37 | bool SLAMFileSerialiser::SerialiseFrames(SLAMFile &file) { 38 | SLAMFrameSerialiser sfs(File()); 39 | 40 | uint32_t frame_idx = 0; 41 | 42 | for(unsigned int i = 0; i < file.GetFrameCount(); ++i) { 43 | SLAMFrame *frame = file.GetFrame(i); 44 | 45 | if(!sfs.Serialise(*frame)) { 46 | std::cerr<<"Failed to serialise frame"; 47 | return false; 48 | } 49 | if(FrameCallback != nullptr) { 50 | FrameCallback(frame_idx, file.GetFrameCount()); 51 | } 52 | frame_idx++; 53 | } 54 | 55 | return true; 56 | } 57 | -------------------------------------------------------------------------------- /framework/shared/src/io/serialisation/SLAMFrameSerialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/serialisation/SLAMFrameSerialiser.h" 11 | 12 | #include "io/SLAMFrame.h" 13 | #include "io/sensor/Sensor.h" 14 | 15 | using namespace slambench::io; 16 | 17 | SLAMFrameSerialiser::SLAMFrameSerialiser(FILE *target) : Serialiser(target) { 18 | 19 | } 20 | 21 | bool SLAMFrameSerialiser::Serialise(SLAMFrame &frame) { 22 | void *frame_data = frame.GetData(); 23 | if(frame_data == nullptr) { 24 | printf("Could not get frame data\n"); 25 | return false; 26 | } 27 | struct { 28 | decltype(frame.Timestamp) timestamp; 29 | decltype(frame.FrameSensor->Index) index; 30 | } __attribute__((packed)) data; 31 | 32 | data.timestamp = frame.Timestamp; 33 | data.index = frame.FrameSensor->Index; 34 | 35 | if (!Write(&data, sizeof(data))) { 36 | printf("Could not write frame header\n"); 37 | return false; 38 | } 39 | if(frame.FrameSensor->IsVariableSize()) { 40 | uint32_t data_size = frame.GetSize(); 41 | 42 | if (!Write(&data_size, sizeof(data_size))) { 43 | printf("Could not write frame size data\n"); 44 | return false; 45 | } 46 | } 47 | if (!Write(frame_data, frame.GetSize())) { 48 | printf("Could not write frame data\n"); 49 | return false; 50 | } 51 | 52 | frame.FreeData(); 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /framework/shared/src/io/serialisation/Serialiser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/serialisation/Serialiser.h" 11 | 12 | using namespace slambench::io; 13 | 14 | Serialiser::Serialiser(FILE *target_file) : _file(target_file) { 15 | 16 | } 17 | 18 | FILE *Serialiser::File() { 19 | return _file; 20 | } 21 | 22 | bool Serialiser::Write(const void *data, size_t size) { 23 | return fwrite(data, size, 1, File()) == 1; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /framework/shared/src/library_wrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | extern "C" { 16 | 17 | bool c_sb_new_slam_configuration(void * slam_settings) { 18 | return sb_new_slam_configuration((SLAMBenchLibraryHelper *) slam_settings); 19 | } 20 | 21 | bool c_sb_init_slam_system(void * slam_settings) { 22 | return sb_init_slam_system((SLAMBenchLibraryHelper *) slam_settings); 23 | } 24 | 25 | bool c_sb_update_frame(void * slam_settings, void * type) { 26 | return sb_update_frame((SLAMBenchLibraryHelper *) slam_settings, (slambench::io::SLAMFrame *) type); 27 | } 28 | 29 | bool c_sb_relocalize(void * slam_settings) { 30 | return sb_relocalize((SLAMBenchLibraryHelper *) slam_settings); 31 | } 32 | 33 | bool c_sb_process_once (void * slam_settings){ 34 | return sb_process_once((SLAMBenchLibraryHelper *) slam_settings); 35 | } 36 | 37 | bool c_sb_clean_slam_system(){ 38 | return sb_clean_slam_system(); 39 | } 40 | 41 | bool c_sb_update_outputs(void *lib, void *timestamp) { 42 | return sb_update_outputs((SLAMBenchLibraryHelper*)lib, (const slambench::TimeStamp *)timestamp); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /framework/shared/src/metrics/DurationMetric.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "sb_malloc.h" 12 | #include "metrics/DurationMetric.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | using namespace slambench::metrics; 22 | 23 | /* Duration Metric */ 24 | 25 | DurationMetric::DurationMetric() : Metric("Duration") 26 | { 27 | 28 | } 29 | 30 | void DurationMetric::MeasureStart(Phase* phase) 31 | { 32 | assert(!phase_start_.count(phase)); 33 | phase_start_[phase] = getTime(); 34 | } 35 | 36 | void DurationMetric::MeasureEnd(Phase* phase) 37 | { 38 | assert(phase_start_.count(phase)); 39 | assert(!phase_end_.count(phase)); 40 | 41 | phase_end_[phase] = getTime(); 42 | } 43 | 44 | Value *DurationMetric::GetValue(Phase *phase) 45 | { 46 | auto value = phase_end_.at(phase) - phase_start_.at(phase); 47 | phase_end_.erase(phase); 48 | phase_start_.erase(phase); 49 | 50 | // time is recorded in microseconds but report it in full seconds 51 | return new values::TypedValue(value / 1000000.0); 52 | } 53 | 54 | 55 | const slambench::values::ValueDescription &DurationMetric::GetValueDescription() const { 56 | static const slambench::values::ValueDescription desc = slambench::values::VT_DOUBLE; 57 | return desc; 58 | } 59 | const std::string &DurationMetric::GetDescription() const 60 | { 61 | static std::string desc = "Duration of the phase in whole microseconds"; 62 | return desc; 63 | } 64 | 65 | uint64_t DurationMetric::getTime() const 66 | { 67 | auto now = std::chrono::high_resolution_clock::now().time_since_epoch(); 68 | 69 | // convert time into time in microseconds (1/1000000) 70 | return std::chrono::duration_cast>>(now).count(); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /framework/shared/src/metrics/Metric.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "sb_malloc.h" 12 | #include "metrics/Metric.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | using namespace slambench::metrics; 22 | 23 | /* Metric Base Class */ 24 | 25 | Metric::Metric(const std::string& name) : name_(name) 26 | { 27 | } 28 | 29 | Metric::~Metric() 30 | { 31 | 32 | } 33 | 34 | const std::string &Metric::GetDescription() const 35 | { 36 | static std::string desc = "No description for metric"; 37 | return desc; 38 | } 39 | -------------------------------------------------------------------------------- /framework/shared/src/metrics/Phase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "metrics/MetricManager.h" 12 | #include "metrics/Phase.h" 13 | 14 | using namespace slambench::metrics; 15 | 16 | Phase::Phase(MetricManager* mgr, const std::string &phasename) : name_(phasename), manager_(mgr) 17 | { 18 | 19 | } 20 | 21 | void Phase::Begin() 22 | { 23 | manager_->BeginPhase(this); 24 | } 25 | 26 | void Phase::End() 27 | { 28 | manager_->EndPhase(this); 29 | } 30 | -------------------------------------------------------------------------------- /framework/shared/src/metrics/PointCloudMetric.cpp: -------------------------------------------------------------------------------- 1 | #include "metrics/PointCloudMetric.h" 2 | #include "io/format/PointCloud.h" 3 | 4 | using slambench::values::PointCloudValue; 5 | using namespace slambench::metrics; 6 | 7 | PointCloudMetric::PointCloudMetric(const slambench::outputs::BaseOutput * const heatmap_pointcloud) : 8 | Metric("PointCloud_Metric"), heatmap_pointcloud(heatmap_pointcloud) 9 | { } 10 | 11 | const slambench::values::ValueDescription &PointCloudMetric::GetValueDescription() const { 12 | static const slambench::values::ValueDescription desc = slambench::values::ValueDescription({ 13 | {"PointCloud_Metric", slambench::values::VT_DOUBLE}}); 14 | return desc; 15 | } 16 | 17 | const std::string& PointCloudMetric::GetDescription() const { 18 | static std::string desc = "Point Cloud Reconstruction Accuracy"; 19 | return desc; 20 | } 21 | 22 | void PointCloudMetric::MeasureStart(Phase* /* unused */) { } 23 | 24 | void PointCloudMetric::MeasureEnd(Phase* /* unused */) { } 25 | 26 | constexpr int COMPUTE_EVERY_FRAMES = 20; 27 | 28 | Value *PointCloudMetric::GetValue(Phase* /* unused */) { 29 | 30 | if (heatmap_pointcloud->Empty()) 31 | return new slambench::values::TypeForVT::type(std::nan("")); 32 | 33 | const outputs::Output::value_map_t::value_type tested_frame = heatmap_pointcloud->GetMostRecentValue(); 34 | const auto pcv = reinterpret_cast(tested_frame.second); 35 | 36 | double total = 0; 37 | for (const auto &value : pcv->GetPoints()) { 38 | total += value.value; 39 | } 40 | 41 | const double average = total / pcv->GetPoints().size(); 42 | 43 | return new slambench::values::TypeForVT::type(average); 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /framework/shared/src/metrics/memory_utils/CUDAMonitor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "metrics/memory_utils/CUDAMonitor.h" 12 | #include 13 | #include 14 | 15 | bool CUDAMonitor::IsActive() { 16 | return libcuda_cudaMemGetInfo != nullptr; 17 | } 18 | 19 | bool CUDAMonitor::Init() { 20 | libcuda_cudaMemGetInfo = (cudaMemGetInfo_t)dlsym(RTLD_NEXT, "cudaMemGetInfo"); 21 | if (libcuda_cudaMemGetInfo == nullptr) { 22 | std::cerr << "*** CUDA Monitor: cudaMemGetInfo is not available" << std::endl; 23 | } 24 | libcuda_cudaGetDeviceProperties = (cudaGetDeviceProperties_t)dlsym(RTLD_NEXT, "cudaGetDeviceProperties"); 25 | if (libcuda_cudaGetDeviceProperties == nullptr) { 26 | std::cerr << "*** CUDA Monitor: cudaGetDeviceProperties is not available" << std::endl; 27 | } else { 28 | cudaDeviceProp prop; 29 | libcuda_cudaGetDeviceProperties(&prop, 0); 30 | device_name = prop.name; 31 | } 32 | return libcuda_cudaMemGetInfo != nullptr; 33 | } 34 | 35 | 36 | 37 | size_t CUDAMonitor::getUsedBytes() { 38 | 39 | if (libcuda_cudaMemGetInfo == nullptr) { 40 | return 0; 41 | } 42 | // show memory usage of GPU 43 | 44 | size_t free_byte ; 45 | 46 | size_t total_byte ; 47 | 48 | cudaError_t error = libcuda_cudaMemGetInfo(&free_byte, &total_byte); 49 | 50 | 51 | if (error != 0) { 52 | return 0.0; 53 | } 54 | 55 | double free_db = (double)free_byte ; 56 | 57 | double total_db = (double)total_byte ; 58 | 59 | double used_db = total_db - free_db ; 60 | 61 | return used_db ; 62 | 63 | } 64 | 65 | 66 | -------------------------------------------------------------------------------- /framework/shared/src/values/ValueDispatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "values/ValueDispatch.h" 11 | 12 | using namespace slambench::values; 13 | 14 | ValueDispatch::~ValueDispatch() 15 | { 16 | 17 | } 18 | 19 | ConstValueDispatch::~ConstValueDispatch() 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /framework/shared/src/values/ValueInterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "values/ValueInterface.h" 11 | 12 | using namespace slambench::values; 13 | 14 | ValueInterface::~ValueInterface() 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /framework/shared/src/values/ValuePrinter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | 11 | #include "values/ValuePrinter.h" 12 | 13 | using namespace slambench::values; 14 | 15 | ValuePrinter::ValuePrinter(std::ostream& str) : str_(str) 16 | { 17 | 18 | } 19 | 20 | ValuePrinter::~ValuePrinter() 21 | { 22 | 23 | } 24 | 25 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 26 | { 27 | str_ << value->GetValue(); 28 | } 29 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 30 | { 31 | str_ << value->GetValue(); 32 | } 33 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 34 | { 35 | str_ << value->GetValue(); 36 | } 37 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 38 | { 39 | (void)value; 40 | str_ << "(point cloud)"; 41 | } 42 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 43 | { 44 | (void)value; 45 | str_ << "(collection)"; 46 | } 47 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 48 | { 49 | (void)value; 50 | str_ << "(trajectory)"; 51 | } 52 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 53 | { 54 | // extract x, y, z 55 | auto &matrix = value->GetValue(); 56 | auto x = matrix(0, 3); 57 | auto y = matrix(1, 3); 58 | auto z = matrix(2, 3); 59 | str_ << x << ", " << y << ", " << z; 60 | } 61 | void ValuePrinter::Dispatch(const TypeForVT::type* value) 62 | { 63 | str_ << value->GetValue(); 64 | } 65 | -------------------------------------------------------------------------------- /framework/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | include_directories(${SLAMBENCH_INCLUDE_DIR}) 4 | 5 | add_subdirectory(accuracy-tools) # SLAMBench reconstruction Error etc... 6 | add_subdirectory(dataset-tools) # SLAMBench Dataset Generator 7 | add_subdirectory(profiling-tools) # SLAMBench Profiling 8 | add_subdirectory(loaders) # SLAMBench Loaders 9 | 10 | -------------------------------------------------------------------------------- /framework/tools/README.md: -------------------------------------------------------------------------------- 1 | # SLAMBench Tools # 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /framework/tools/accuracy-tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(accuracy_tools) 3 | find_package(PCL REQUIRED) 4 | get_directory_property(DirDefs COMPILE_DEFINITIONS) 5 | message(STATUS "VTK FIX:Previous properties=${DirDefs}") 6 | set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "") 7 | ###################################################################################### 8 | ################# COMMONS 9 | ###################################################################################### 10 | 11 | include_directories(. ../../shared/include) 12 | 13 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=c++14 -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=attributes") 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=attributes") 15 | 16 | 17 | find_package(Pangolin QUIET) 18 | IF(Pangolin_FOUND) 19 | set(main_common_libraries ${SLAMBENCH_LIBRARIES}) 20 | set(gui_pangolin_libraries ${main_common_libraries} slambench-ui-pangolin ${Pangolin_LIBRARIES} ${OPENGL_LIBRARIES} pthread) 21 | if (PCL_FOUND) 22 | include_directories(${PCL_INCLUDE_DIRS}) 23 | link_directories(${PCL_LIBRARY_DIRS}) 24 | add_definitions(${PCL_DEFINITIONS}) 25 | 26 | add_executable(pointcloud_aligner pointcloud_aligner.cpp) 27 | 28 | TARGET_INCLUDE_DIRECTORIES(pointcloud_aligner PUBLIC ${SLAMBENCH_INCLUDE_DIR}) 29 | TARGET_INCLUDE_DIRECTORIES(pointcloud_aligner PUBLIC ${Pangolin_INCLUDE_DIR}) 30 | TARGET_INCLUDE_DIRECTORIES(pointcloud_aligner PUBLIC ${TOON_INCLUDE_PATHS}) 31 | 32 | target_link_libraries(pointcloud_aligner PRIVATE ${gui_pangolin_libraries} ${PCL_LIBRARIES}) 33 | target_compile_options(pointcloud_aligner PRIVATE "-Wno-error=comment") 34 | if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) 35 | target_compile_options(pointcloud_aligner PRIVATE "-Wno-error=catch-value=") 36 | endif() 37 | 38 | 39 | install(TARGETS pointcloud_aligner DESTINATION bin/) 40 | 41 | 42 | else (PCL_FOUND) 43 | message(STATUS "Trajectory tool will not be compile, PCL not found.") 44 | endif(PCL_FOUND) 45 | 46 | 47 | ENDIF(Pangolin_FOUND) 48 | 49 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/ETHI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "include/ETHI.h" 11 | 12 | #include 13 | #include 14 | 15 | using namespace slambench::io; 16 | 17 | SLAMFile *ETHIReader::GenerateSLAMFile() {return nullptr;} 18 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/DatasetReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASETREADER_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASETREADER_H_ 12 | 13 | #include 14 | 15 | namespace slambench { 16 | namespace io { 17 | class SLAMFile; 18 | class DatasetReader : public ParameterComponent { 19 | public : 20 | typedef struct { 21 | const uint32_t width; 22 | const uint32_t height; 23 | const float rate; 24 | const float depthMapFactor; 25 | } image_params_t; 26 | DatasetReader(const std::string &name) : ParameterComponent(name) {} 27 | virtual slambench::io::SLAMFile *GenerateSLAMFile() = 0; 28 | }; 29 | } 30 | } 31 | #endif /* FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASETREADER_H_ */ 32 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/ETHI.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ETHI_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ETHI_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include "DatasetReader.h" 21 | 22 | namespace slambench { 23 | 24 | namespace io { 25 | 26 | class ETHIReader : public DatasetReader { 27 | 28 | public: 29 | 30 | std::string dataset = ""; 31 | explicit ETHIReader(const std::string &name) : DatasetReader(name) { 32 | this->addParameter(TypedParameter("dataset", "base-dataset", "If this is iclnuim or tum", 33 | &this->dataset, nullptr)); 34 | } 35 | 36 | SLAMFile *GenerateSLAMFile() override; 37 | }; 38 | 39 | } // namespace io 40 | } // namespace slambench 41 | 42 | #endif /* FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ETHI_H_ */ 43 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/ICL.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ICL_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ICL_H_ 12 | 13 | 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "../../dataset-tools/include/DatasetReader.h" 25 | 26 | namespace slambench { 27 | 28 | namespace io { 29 | 30 | class ICLReader : public DatasetReader { 31 | 32 | private : 33 | static constexpr CameraSensor::intrinsics_t fr1_intrinsics_rgb = { 0.9375, 1.25, 0.5, 0.5 }; 34 | static constexpr DepthSensor::intrinsics_t fr1_intrinsics_depth = { 0.9375, 1.25, 0.5, 0.5 }; 35 | 36 | public : 37 | std::string input; 38 | bool grey = true, rgb = true, depth = true, gt = true, accelerometer = false; 39 | 40 | ICLReader (std::string name) : DatasetReader(name) { 41 | 42 | this->addParameter(TypedParameter("i", "input-directory", "path of the ICL dataset directory", &this->input, NULL)); 43 | this->addParameter(TypedParameter("grey", "grey", "set to true or false to specify if the GREY stream need to be include in the slam file.", &this->grey, NULL)); 44 | this->addParameter(TypedParameter("rgb", "rgb", "set to true or false to specify if the RGB stream need to be include in the slam file.", &this->rgb, NULL)); 45 | this->addParameter(TypedParameter("depth", "depth", "set to true or false to specify if the DEPTH stream need to be include in the slam file.", &this->depth, NULL)); 46 | this->addParameter(TypedParameter("gt", "gt", "set to true or false to specify if the GROUNDTRUTH POSE stream need to be include in the slam file.", &this->gt, NULL)); 47 | this->addParameter(TypedParameter("acc", "accelerometer", "set to true or false to specify if the ACCELEROMETER stream need to be include in the slam file.", &this->accelerometer, NULL)); 48 | 49 | } 50 | 51 | SLAMFile* GenerateSLAMFile () ; 52 | 53 | }; 54 | 55 | } 56 | } 57 | 58 | 59 | 60 | 61 | #endif /* FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_ICL_H_ */ 62 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/SVO.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_SVO_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_SVO_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include "DatasetReader.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | namespace slambench { 28 | 29 | namespace io { 30 | 31 | class SVOReader : public DatasetReader { 32 | private: 33 | static constexpr CameraSensor::intrinsics_t svo_grey = {0.419547872, 0.657291667, 0.5, 0.5}; // ATAN 34 | // static constexpr CameraSensor::intrinsics_t svo_grey = { 315.5, 315.5, 376.0, 240.0 }; // Pinhole 35 | 36 | static constexpr float translation[] = {0.1131, 0.1131, 2.0}; // x, y, z 37 | static constexpr float rotation[] = {0.0, 0.9675388, 0.2527226, 0.0}; // w, x, y, z 38 | 39 | public: 40 | std::string input; 41 | 42 | explicit SVOReader(const std::string& name) : DatasetReader(name) { 43 | this->addParameter(TypedParameter( 44 | "i", "input-directory", 45 | "path of the SVO dataset directory", 46 | &this->input, nullptr)); 47 | } 48 | 49 | SLAMFile* GenerateSLAMFile() override; 50 | }; 51 | 52 | } // namespace io 53 | } // namespace slambench 54 | 55 | #endif /* FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_SVO_H_ */ 56 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/utils/RegexPattern.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of 4 | Manchester. Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_REGEXPATTERN_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_REGEXPATTERN_H_ 12 | 13 | class RegexPattern { 14 | public: 15 | // characters 16 | static constexpr auto start = "^"; 17 | static constexpr auto end = "$"; 18 | 19 | // components 20 | static constexpr auto whitespace = "\\s+"; 21 | static constexpr auto integer = "(\\d+)"; 22 | static constexpr auto decimal = "([-0-9.]+)"; 23 | static constexpr auto nanoseconds = "([0-9]+)"; 24 | static constexpr auto number = R"(([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?|[-0-9.]+))"; 25 | static constexpr auto timestamp = "([0-9]+)[.]([0-9]+)"; 26 | static constexpr auto filename = "(.*)"; 27 | static constexpr auto lowercase_key = "([a-z_]+)"; 28 | 29 | // full patterns 30 | static constexpr auto comment = "^\\s*#.*$"; 31 | }; 32 | 33 | #endif -------------------------------------------------------------------------------- /framework/tools/dataset-tools/include/utils/dataset_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2019 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #ifndef FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASET_UTILS_H_ 11 | #define FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASET_UTILS_H_ 12 | 13 | #include 14 | namespace slambench { 15 | namespace io { 16 | 17 | /** 18 | * Check for files and folders in a given directory and return true iff all exist 19 | * 20 | * @param directory_name directory to check for requirements 21 | * @param required vector of names of required files / folders 22 | */ 23 | inline bool checkRequirements(const std::string& directory_name, 24 | const std::vector& requirements) { 25 | 26 | try { 27 | if (!boost::filesystem::exists(directory_name)) return false; 28 | for (auto const &requirement : requirements) { 29 | auto fullpath = directory_name+"/"+requirement; 30 | if (!boost::filesystem::exists(fullpath)) { 31 | std::cout << "File not found:" << fullpath << std::endl; 32 | return false; 33 | } 34 | } 35 | } catch (boost::filesystem::filesystem_error &e) { 36 | std::cerr << "I/O Error with directory " << directory_name << std::endl; 37 | std::cerr << e.what() << std::endl; 38 | return false; 39 | } 40 | 41 | return true; 42 | } 43 | } // namespace io 44 | } // namespace slambench 45 | 46 | #endif // FRAMEWORK_TOOLS_DATASET_TOOLS_INCLUDE_DATASET_UTILS_H_ 47 | -------------------------------------------------------------------------------- /framework/tools/dataset-tools/io-readply.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2017 University of Edinburgh, Imperial College, University of Manchester. 4 | Developed in the PAMELA project, EPSRC Programme Grant EP/K008730/1 5 | 6 | This code is licensed under the MIT License. 7 | 8 | */ 9 | 10 | #include "io/format/PointCloud.h" 11 | 12 | #include 13 | 14 | int main(int argc, char **argv) { 15 | slambench::io::PlyReader reader; 16 | std::ifstream str (argv[1]); 17 | auto pc = reader.Read(str); 18 | 19 | if(pc == nullptr) { 20 | printf("Could not read pointcloud!\n"); 21 | return 1; 22 | } else { 23 | for(auto p : pc->Get()) { 24 | printf("%f %f %f\n", p.x, p.y, p.z); 25 | } 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /framework/tools/loaders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | add_executable(slambench slambench_app.cpp) 4 | target_include_directories(slambench PUBLIC ${SLAMBENCH_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/shared/include) 5 | target_link_libraries(slambench PRIVATE pthread ${SLAMBENCH_LIBRARIES}) 6 | 7 | find_package(Pangolin QUIET) 8 | find_package(TOON QUIET) 9 | IF(Pangolin_FOUND) 10 | set(gui_pangolin_libraries slambench-ui-pangolin ${Pangolin_LIBRARIES} ${OPENGL_LIBRARIES} pthread) 11 | TARGET_INCLUDE_DIRECTORIES(slambench PUBLIC ${Pangolin_INCLUDE_DIR}) 12 | TARGET_INCLUDE_DIRECTORIES(slambench PUBLIC ${TOON_INCLUDE_PATHS}) 13 | target_link_libraries(slambench PRIVATE ${gui_pangolin_libraries}) 14 | add_definitions(-DWITH_GUI=1) 15 | ENDIF(Pangolin_FOUND) 16 | -------------------------------------------------------------------------------- /framework/tools/profiling-tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | ###################################################################################### 4 | ########## OPENCL Wrapper for profiling (optional) 5 | ###################################################################################### 6 | find_package(OpenCL) 7 | 8 | if (OpenCL_FOUND) 9 | include_directories(${OPENCL_INCLUDE_DIRS}) 10 | add_library(oclwrapper SHARED OCLWrapper.cpp) 11 | target_link_libraries(oclwrapper ${OPENCL_LIBRARIES}) 12 | else (OpenCL_FOUND) 13 | message(STATUS "OpenCL wrapper cannot be build, OpenCL not found.") 14 | endif(OpenCL_FOUND) 15 | 16 | 17 | -------------------------------------------------------------------------------- /icra2018_results/Makefile: -------------------------------------------------------------------------------- 1 | 2 | run: 3 | mkdir output -p 4 | ./paper_run.sh output 5 | 6 | report.pdf : 1080_violins.pdf tegra_violins.pdf 7 | pdfunite 1080_violins.pdf tegra_violins.pdf $@ 8 | 9 | %_violins.pdf : % ./*.py 10 | ./violins.py $*/violons_* --plot $*_violins.pdf 11 | pdflatex $*_report.tex 12 | 13 | clean : 14 | rm *.aux *.pdf *.tex *.log -f 15 | -------------------------------------------------------------------------------- /icra2018_results/utils.py: -------------------------------------------------------------------------------- 1 | 2 | ######################################################################################### 3 | # UTILS SYSTEM 4 | ######################################################################################### 5 | 6 | import sys 7 | 8 | 9 | 10 | class shellcolors: 11 | GREEN = '\033[92m' 12 | YELLOW = '\033[93m' 13 | RED = '\033[91m' 14 | ENDC = '\033[0m' 15 | BOLD = '\033[1m' 16 | UNDERLINE = '\033[4m' 17 | 18 | WARNING_CODE = shellcolors.YELLOW + "[ERROR]" + shellcolors.ENDC 19 | ERROR_CODE = shellcolors.RED + "[ERROR]" + shellcolors.ENDC 20 | INVALID = shellcolors.RED + "[INVALID]" + shellcolors.ENDC 21 | VALID = shellcolors.GREEN + "[VALID]" + shellcolors.ENDC 22 | 23 | verbose_level = False 24 | 25 | def setverbose(v) : 26 | global verbose_level 27 | verbose_level = v 28 | 29 | def printwarning(msg) : 30 | sys.stderr.write(WARNING_CODE + " " + msg) 31 | 32 | 33 | def printerr(err) : 34 | sys.stderr.write(ERROR_CODE + " " + err) 35 | 36 | def printinfo(err) : 37 | global verbose_level 38 | if verbose_level : 39 | sys.stderr.write(shellcolors.GREEN + "[INFO]" + shellcolors.ENDC + " " + err) 40 | 41 | -------------------------------------------------------------------------------- /scripts/tum_evaluate_tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pamela-project/slambench/8a9deeaa5124e824fa7f8e16eea97ad0bd0404c6/scripts/tum_evaluate_tools/__init__.py --------------------------------------------------------------------------------