Skip to content

Commit

Permalink
Combined detection of cable and railway.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcserep committed Sep 19, 2022
1 parent 516f8e8 commit cc18442
Show file tree
Hide file tree
Showing 32 changed files with 951 additions and 552 deletions.
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
bin/
cmake-build-debug/
build/
build*/
*.laz
*.pcd

# JetBrains
.idea/

# Eclipse
.project

# Visual Studio
.vs/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2018-2020, Máté Cserép & Péter Hudoba
Copyright (c) 2018-2022, Máté Cserép & Péter Hudoba
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ Operating system
---------------

The project is built under Linux. It is recommended to use a 64-bit operating system.
Ubuntu 16.04 LTS and 18.04 LTS was used during development.
Ubuntu 20.04 LTS was used during development.

Dependencies
--------------

The project uses some third-party dependencies.
These can be installed from the official repository of the given Linux distribution.
* [GNU Make](https://www.gnu.org/software/make/)
* [CMake](https://cmake.org/)
* [PCL](http://pointclouds.org/)
* [OpenCV](https://opencv.org/)
* [CMake](https://cmake.org/), version >= 3.5
* [PCL](http://pointclouds.org/), version >= 1.7
* [OpenCV](https://opencv.org/), version >= 4.0

The following command installs the packages:
```bash
Expand Down
86 changes: 50 additions & 36 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,74 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "-pedantic -Wall -Wno-unused-result -Wno-strict-aliasing")
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX})

# Thread
find_package(Threads REQUIRED)
link_libraries(pthread)

# Boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
find_package(Boost REQUIRED COMPONENTS filesystem log program_options)
include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES})

# LAStools
include_directories(../vendor/LAStools/LASzip/src)
include_directories(../vendor/LAStools/LASlib/inc)
link_directories(../vendor/LAStools/LASlib/lib)
link_libraries(las)
find_package(LASlib PATHS ../vendor/LAStools/install)
if(LASlib_FOUND)
set(LASlib_LIBRARY_DIRS ${LASlib_INCLUDE_DIRS}/../../lib/LASlib/)
set(LASlib_LIBRARIES LASlib)
else()
message(SEND_ERROR "LASlib not found")
endif()
include_directories(${LASlib_INCLUDE_DIRS})
link_directories(${LASlib_LIBRARY_DIRS})
link_libraries(${LASlib_LIBRARIES})

# PCL
find_package(PCL 1.7 REQUIRED COMPONENTS common filters segmentation visualization recognition)
find_package(PCL 1.7 REQUIRED COMPONENTS common io filters segmentation visualization)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
link_libraries(${PCL_LIBRARIES})

# OpenCV
find_package(OpenCV REQUIRED)
find_package(OpenCV 4 REQUIRED)
link_libraries(${OpenCV_LIBS})

add_executable(railroad
main.cpp
filters/DensityFilter.cpp filters/DensityFilter.h
filters/AboveFilter.cpp filters/AboveFilter.h
filters/CylinderFilter.cpp filters/CylinderFilter.h
filters/GroundFilter.cpp filters/GroundFilter.h
filters/OutlierFilter.cpp filters/OutlierFilter.h
filters/CutFilter.cpp filters/CutFilter.h
filters/LimiterFilter.cpp filters/LimiterFilter.h
filters/RansacFilter.cpp filters/RansacFilter.h
filters/Hough3dFilter.cpp filters/Hough3dFilter.h
filters/GrowthFilter.cpp filters/GrowthFilter.h
filters/HeightFilter.cpp filters/HeightFilter.h
filters/WidthFilter.cpp filters/WidthFilter.h
filters/RailTrackFilter.cpp filters/RailTrackFilter.h
helpers/PCLHelper.cpp helpers/PCLHelper.h
helpers/LogHelper.cpp helpers/LogHelper.h
helpers/LASHelper.cpp helpers/LASHelper.h
helpers/HoughHelper.cpp helpers/HoughHelper.h
dim2/ImportantPartFinderProcessor.cpp dim2/ImportantPartFinderProcessor.h
dim2/Dim2Helper.cpp dim2/Dim2Helper.h
dim2/TrackFinderProcessor.cpp dim2/TrackFinderProcessor.h
dim2/Projection.cpp dim2/Projection.h
piping/ProcessorPipe.cpp piping/ProcessorPipe.h
piping/ProcessorPipeBunch.cpp piping/ProcessorPipeBunch.h
base/CloudProcessor.cpp base/CloudProcessor.h
Results.h)
add_library(railroad SHARED
base/CloudProcessor.cpp base/CloudProcessor.h
filters/DensityFilter.cpp filters/DensityFilter.h
filters/AboveFilter.cpp filters/AboveFilter.h
filters/CylinderFilter.cpp filters/CylinderFilter.h
filters/GroundFilter.cpp filters/GroundFilter.h
filters/OutlierFilter.cpp filters/OutlierFilter.h
filters/CutFilter.cpp filters/CutFilter.h
filters/LimiterFilter.cpp filters/LimiterFilter.h
filters/RansacFilter.cpp filters/RansacFilter.h
filters/Hough3dFilter.cpp filters/Hough3dFilter.h
filters/GrowthFilter.cpp filters/GrowthFilter.h
filters/HeightFilter.cpp filters/HeightFilter.h
filters/WidthFilter.cpp filters/WidthFilter.h
filters/RailTrackFilter.cpp filters/RailTrackFilter.h
dim2/ImportantPartFinderProcessor.cpp dim2/ImportantPartFinderProcessor.h
dim2/Dim2Helper.cpp dim2/Dim2Helper.h
dim2/TrackFinderProcessor.cpp dim2/TrackFinderProcessor.h
dim2/Projection.cpp dim2/Projection.h
helpers/PCLHelper.cpp helpers/PCLHelper.h
helpers/LogHelper.cpp helpers/LogHelper.h
helpers/LASHelper.cpp helpers/LASHelper.h helpers/LASClass.h
helpers/HoughHelper.cpp helpers/HoughHelper.h
piping/ProcessorPipe.cpp piping/ProcessorPipe.h
piping/ProcessorPipeBunch.cpp piping/ProcessorPipeBunch.h)
link_libraries(railroad)

add_executable(railroad_benchmark
main_benchmark.cpp
Results.h Pipes.h)

add_executable(railroad_combined
main_combined.cpp
Results.h Pipes.h)

install(TARGETS railroad_benchmark railroad_combined railroad
DESTINATION ${CMAKE_INSTALL_PREFIX})
190 changes: 190 additions & 0 deletions src/Pipes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* BSD 3-Clause License
* Copyright (c) 2018, Máté Cserép & Péter Hudoba
* All rights reserved.
*
* You may obtain a copy of the License at
* https://opensource.org/licenses/BSD-3-Clause
*/

#ifndef RAILROAD_PIPES_H
#define RAILROAD_PIPES_H

#include "filters/DensityFilter.h"
#include "filters/AboveFilter.h"
#include "filters/CylinderFilter.h"
#include "filters/GroundFilter.h"
#include "filters/OutlierFilter.h"
#include "filters/CutFilter.h"
#include "filters/LimiterFilter.h"
#include "filters/RansacFilter.h"
#include "filters/Hough3dFilter.h"
#include "filters/GrowthFilter.h"
#include "filters/RailTrackFilter.h"
#include "filters/HeightFilter.h"
#include "filters/WidthFilter.h"

#include "piping/ProcessorPipeBunch.h"
#include "piping/ProcessorPipe.h"

namespace railroad
{

ProcessorPipeBunch *generateTestPipes()
{
ProcessorPipeBunch *pipesHolder = (new ProcessorPipeBunch())

->add("Voronoi", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
)
->add("Skeleton", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::SKELETON))
)
->add("Angle", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
)
->add("Ground", LASClass::CABLE,
(new ProcessorPipe())
->add(new GroundFilter())
)
->add("Above", LASClass::CABLE,
(new ProcessorPipe())
->add(new AboveFilter())
)
->add("Density", LASClass::CABLE,
(new ProcessorPipe())
->add(new DensityFilter())
)
->add("AngleGround", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new GroundFilter())
)
->add("AngleGroundAbove", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new GroundFilter())
->add(new AboveFilter())
)
->add("AngleGroundAboveCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new GroundFilter())
->add(new AboveFilter())
->add(new CylinderFilter())
)
->add("AngleGroundCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new GroundFilter())
->add(new CylinderFilter())
)
->add("AngleAbove", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new AboveFilter())
)
->add("AngleAboveCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::ANGLE))
->add(new AboveFilter())
->add(new CylinderFilter())
)
->add("VoronoiGround", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new GroundFilter())
)
->add("VoronoiGroundAbove", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new GroundFilter())
->add(new AboveFilter())
)
->add("VoronoiGroundAboveCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new GroundFilter())
->add(new AboveFilter())
->add(new CylinderFilter())
)
->add("VoronoiGroundCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new GroundFilter())
->add(new CylinderFilter())
)
->add("VoronoiAbove", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new AboveFilter())
)
->add("VoronoiAboveCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new CutFilter(ImportantPartFinderProcessor::VORONOI))
->add(new AboveFilter())
->add(new CylinderFilter())
)
->add("GroundDensity", LASClass::CABLE,
(new ProcessorPipe())
->add(new GroundFilter())
->add(new DensityFilter())
)
->add("GroundDensityAbove", LASClass::CABLE,
(new ProcessorPipe())
->add(new GroundFilter())
->add(new DensityFilter())
->add(new AboveFilter())
)
->add("GroundDensityAboveCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new GroundFilter())
->add(new DensityFilter())
->add(new AboveFilter())
->add(new CylinderFilter())
)
->add("GroundDensityCylinder", LASClass::CABLE,
(new ProcessorPipe())
->add(new GroundFilter())
->add(new DensityFilter())
->add(new CylinderFilter())
)

// Author: Friderika Mayer
->add("Ransac", LASClass::CABLE,
(new ProcessorPipe())
->add(new HeightFilter())
->add(new WidthFilter())
->add(new RansacFilter())
)
->add("Hough", LASClass::CABLE,
(new ProcessorPipe())
->add(new HeightFilter())
->add(new Hough3dFilter())
)
->add("Growth", LASClass::CABLE,
(new ProcessorPipe())
->add(new HeightFilter())
->add(new GrowthFilter())
)

// Author: Adalbert Demján
->add("RailTrack", LASClass::RAIL,
(new ProcessorPipe())
->add(new RailTrackFilter())
)
->add("RailTrackWithSeed", LASClass::RAIL,
(new ProcessorPipe())
->add(new WidthFilter())
->add(new RailTrackFilter())
);

return pipesHolder;
}

} // railroad

#endif //RAILROAD_PIPES_H
9 changes: 8 additions & 1 deletion src/dim2/Dim2Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

#include <vector>

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui.hpp>

#include "Dim2Helper.h"
#include "../helpers/LogHelper.h"

using namespace cv;
using namespace std;
Expand Down Expand Up @@ -83,7 +84,13 @@ void saveImagesAsGridAndAloneAlso(const std::string &filename, const std::vector

void imwriteWithInverse(const std::string &filename, cv::Mat image)
{
if (image.total() == 0) {
LOG(warning) << filename << " skipped, would be empty";
return; // empty image
}

imwrite(filename, image);

Mat toDraw;
bitwise_not(image, toDraw);
imwrite("inverse_" + filename, toDraw);
Expand Down
2 changes: 1 addition & 1 deletion src/dim2/Dim2Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef RAILROAD_DIM2HELPER_H
#define RAILROAD_DIM2HELPER_H

#include <opencv2/core/core.hpp>
#include <opencv2/core.hpp>

namespace railroad
{
Expand Down
2 changes: 1 addition & 1 deletion src/dim2/ImageProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef RAILROAD_MATPROCESSOR_H
#define RAILROAD_MATPROCESSOR_H

#include <opencv2/core/core.hpp>
#include <opencv2/core.hpp>

namespace railroad
{
Expand Down
Loading

0 comments on commit cc18442

Please sign in to comment.