├── .gitignore ├── CMakeLists.txt ├── COPYING ├── COPYING.LESSER ├── INSTALL ├── README ├── cmake ├── Config.cmake.in ├── FindCairo.cmake ├── FindQwt.cmake └── FindQwt5.cmake ├── data ├── fr-clinic.log ├── fr079.log ├── intel-lab.log ├── kenmore_first_loop.log ├── mit-cscail.log └── victoria-park.log ├── doc └── Doxyfile.in ├── package.xml └── src ├── CMakeLists.txt ├── applications ├── CMakeLists.txt ├── FLIRTDemo.cpp ├── FLIRTDemo.h ├── RansacLoopClosureDrawMovie.cpp └── RansacLoopClosureTest.cpp ├── feature ├── AbstractFeatureSetMatcher.cpp ├── AbstractFeatureSetMatcher.h ├── BetaGrid.cpp ├── BetaGrid.h ├── CMakeLists.txt ├── CurvatureDetector.cpp ├── CurvatureDetector.h ├── Descriptor.h ├── Detector.h ├── InterestPoint.cpp ├── InterestPoint.h ├── MultiScaleDetector.cpp ├── MultiScaleDetector.h ├── NormalBlobDetector.cpp ├── NormalBlobDetector.h ├── NormalDetector.cpp ├── NormalDetector.h ├── NormalEdgeDetector.cpp ├── NormalEdgeDetector.h ├── RangeDetector.cpp ├── RangeDetector.h ├── RansacFeatureSetMatcher.cpp ├── RansacFeatureSetMatcher.h ├── RansacMultiFeatureSetMatcher.cpp ├── RansacMultiFeatureSetMatcher.h ├── ShapeContext.cpp ├── ShapeContext.h └── dijkstra_shortest_paths.hpp ├── geometry ├── CMakeLists.txt ├── point.cpp └── point.h ├── gui ├── AbstractRenderer.h ├── BetaGridPresenter.cpp ├── BetaGridPresenter.h ├── BoxParameterWidget.cpp ├── BoxParameterWidget.h ├── CMakeLists.txt ├── Color.cpp ├── Color.h ├── CorrespondenceRenderer.cpp ├── CorrespondenceRenderer.h ├── DescriptorChooserPresenter.cpp ├── DescriptorChooserPresenter.h ├── DescriptorPresenter.h ├── DescriptorWidget.cpp ├── DescriptorWidget.h ├── DetectorChooserPresenter.cpp ├── DetectorChooserPresenter.h ├── DetectorPresenter.h ├── FeatureSetMatcherPresenter.cpp ├── FeatureSetMatcherPresenter.h ├── InterestPointRenderer.cpp ├── InterestPointRenderer.h ├── LaserReadingRenderer.cpp ├── LaserReadingRenderer.h ├── MultiScaleCurvatureDetectorPresenter.cpp ├── MultiScaleCurvatureDetectorPresenter.h ├── MultiScaleDetectorPlotWidget.cpp ├── MultiScaleDetectorPlotWidget.h ├── MultiScaleDetectorPresenter.cpp ├── MultiScaleDetectorPresenter.h ├── MultiScaleNormalDetectorPresenter.cpp ├── MultiScaleNormalDetectorPresenter.h ├── ParameterWidget.cpp ├── ParameterWidget.h ├── PeakFinderPresenter.h ├── PolarGridGraphicsItem.cpp ├── PolarGridGraphicsItem.h ├── PolarGridRenderer.cpp ├── PolarGridRenderer.h ├── RansacPresenter.cpp ├── RansacPresenter.h ├── RendererWidget.cpp ├── RendererWidget.h ├── SensorStreamWidget.cpp ├── SensorStreamWidget.h ├── ShapeContextPresenter.cpp ├── ShapeContextPresenter.h ├── SimplePeakFinderPresenter.cpp ├── SimplePeakFinderPresenter.h ├── TabbedParameterWidget.cpp └── TabbedParameterWidget.h ├── insertLicense ├── mainpage.h ├── sensors ├── AbstractReading.cpp ├── AbstractReading.h ├── CMakeLists.txt ├── LaserReading.cpp └── LaserReading.h ├── sensorstream ├── CMakeLists.txt ├── CarmenLog.cpp ├── CarmenLog.h ├── LogReader.h ├── LogSensorStream.cpp ├── LogSensorStream.h ├── LogWriter.h └── SensorStream.h └── utils ├── CMakeLists.txt ├── Convolution.h ├── Convolution.hpp ├── HistogramDistances.h ├── HistogramDistances.hpp ├── PeakFinder.h ├── PoseEstimation.cpp ├── PoseEstimation.h ├── Regression.cpp ├── Regression.h ├── SimpleMinMaxPeakFinder.cpp ├── SimpleMinMaxPeakFinder.h ├── SimplePeakFinder.cpp └── SimplePeakFinder.h /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | lib* 3 | build 4 | *.kate-swp 5 | external/gefp 6 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This is the main CMake configuration file, you should always do "cmake ." from here and not from subdirs 2 | 3 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) 4 | 5 | PROJECT(FLIRT CXX C) 6 | 7 | SET(CMAKE_VERBOSE_MAKEFILE 0) 8 | 9 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 10 | 11 | add_subdirectory(src) 12 | 13 | option(BUILD_DOC "Build the documentation " ON) 14 | 15 | #-- Add the doc target to generate the API documentation 16 | if(BUILD_DOC) 17 | FIND_PACKAGE(Doxygen) 18 | if (NOT DOXYGEN_FOUND) 19 | message(WARNING "Doxygen is needed to build the documentation. Please install it correctly") 20 | else() 21 | configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) 22 | add_custom_target (doc COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile SOURCES ${PROJECT_BINARY_DIR}/Doxyfile) 23 | message(STATUS ${PROJECT_BINARY_DIR}) 24 | install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target doc)") 25 | message(STATUS ${PROJECT_BINARY_DIR}) 26 | install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/html DESTINATION share/flirtlib/doc) 27 | endif() 28 | endif() 29 | # Install the licenses and the README 30 | install(FILES ${PROJECT_SOURCE_DIR}/COPYING ${PROJECT_SOURCE_DIR}/COPYING.LESSER ${PROJECT_SOURCE_DIR}/README DESTINATION share/flirtlib) 31 | 32 | # Install the datasets 33 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION share/flirtlib PATTERN ".svn" EXCLUDE) 34 | 35 | # Install the cmake config 36 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY) 37 | install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION share/flirtlib/cmake) 38 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | The library relies on cmake to generate the Makefiles. 2 | 3 | Go to the src/ directory. Do 4 | 5 | cmake . 6 | make 7 | 8 | For a more verbose output do 9 | 10 | VERBOSE=1 cmake . 11 | VERBOSE=1 make 12 | 13 | The software depends on the following external libraries 14 | 15 | * Boost >= 1.36 (submodules math and graph) 16 | * Qt4 (for the gui) 17 | * Qwt5 for Qt4 (for the gui) 18 | * OpenGL (for the gui) 19 | * Cairo (for drwaing the ransac results) 20 | -------------------------------------------------------------------------------- /cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for @CMAKE_PROJECT_NAME@ 2 | # 3 | # It defines the following variables: 4 | # @CMAKE_PROJECT_NAME@_INCLUDE_DIRS - Include directories for @CMAKE_PROJECT_NAME@ 5 | # @CMAKE_PROJECT_NAME@_LIBRARIES - Libraries for @CMAKE_PROJECT_NAME@ 6 | 7 | set(FLIRT_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include/flirtlib) 8 | 9 | foreach(lib feature geometry gui sensors sensorstream utils) 10 | list(APPEND FLIRT_LIBRARIES @CMAKE_INSTALL_PREFIX@/lib/libflirtlib_${lib}.so) 11 | endforeach() 12 | -------------------------------------------------------------------------------- /cmake/FindCairo.cmake: -------------------------------------------------------------------------------- 1 | # - try to find Cairo 2 | # Once done this will define 3 | # 4 | # CAIRO_FOUND - system has Cairo 5 | # CAIRO_CFLAGS - the Cairo CFlags 6 | # CAIRO_INCLUDE_DIR - the Cairo include directories 7 | # CAIRO_LIBRARIES - Link these to use Cairo 8 | # 9 | # Copyright (C) 2007, 2010, Pino Toscano, 10 | # 11 | # Redistribution and use is allowed according to the terms of the BSD license. 12 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 13 | 14 | if(CAIRO_INCLUDE_DIR AND CAIRO_LIBRARIES) 15 | 16 | # in cache already 17 | set(CAIRO_FOUND TRUE) 18 | 19 | else(CAIRO_INCLUDE_DIR AND CAIRO_LIBRARIES) 20 | 21 | if(NOT WIN32) 22 | # use pkg-config to get the directories and then use these values 23 | # in the FIND_PATH() and FIND_LIBRARY() calls 24 | include(FindPkgConfig) 25 | if(PACKAGE_FIND_VERSION_COUNT GREATER 0) 26 | set(_cairo_version_cmp ">=${PACKAGE_FIND_VERSION}") 27 | endif(PACKAGE_FIND_VERSION_COUNT GREATER 0) 28 | pkg_check_modules(_pc_cairo cairo${_cairo_version_cmp}) 29 | if(_pc_cairo_FOUND) 30 | set(CAIRO_FOUND TRUE) 31 | endif(_pc_cairo_FOUND) 32 | else(NOT WIN32) 33 | # assume so, for now 34 | set(CAIRO_FOUND TRUE) 35 | endif(NOT WIN32) 36 | 37 | if(CAIRO_FOUND) 38 | # set it back as false 39 | set(CAIRO_FOUND FALSE) 40 | 41 | find_library(CAIRO_LIBRARY cairo 42 | HINTS ${_pc_cairo_LIBRARY_DIRS} 43 | ) 44 | set(CAIRO_LIBRARIES "${CAIRO_LIBRARY}") 45 | 46 | find_path(CAIRO_INCLUDE_DIR cairo.h 47 | HINTS ${_pc_cairo_INCLUDE_DIRS} 48 | PATH_SUFFIXES cairo 49 | ) 50 | include(FindPackageHandleStandardArgs) 51 | find_package_handle_standard_args(Cairo DEFAULT_MSG CAIRO_LIBRARIES CAIRO_INCLUDE_DIR) 52 | endif(CAIRO_FOUND) 53 | 54 | endif(CAIRO_INCLUDE_DIR AND CAIRO_LIBRARIES) 55 | 56 | mark_as_advanced( 57 | CAIRO_CFLAGS 58 | CAIRO_INCLUDE_DIR 59 | CAIRO_LIBRARIES 60 | ) 61 | -------------------------------------------------------------------------------- /cmake/FindQwt.cmake: -------------------------------------------------------------------------------- 1 | # Find the Qwt includes and library, either the version linked to Qt3 or the version linked to Qt4 2 | # 3 | # On Windows it makes these assumptions: 4 | # - the Qwt DLL is where the other DLLs for Qt are (QT_DIR\bin) or in the path 5 | # - the Qwt .h files are in QT_DIR\include\Qwt or in the path 6 | # - the Qwt .lib is where the other LIBs for Qt are (QT_DIR\lib) or in the path 7 | # 8 | # Qwt_INCLUDE_DIR - Where to find qwt.h if Qwt 9 | # Qwt_VERSION - The version of the library installed 10 | # Qwt-Qt4_LIBRARY - The Qwt library linked against Qt4 (if it exists) 11 | # Qwt-Qt3_LIBRARY - The Qwt library linked against Qt3 (if it exists) 12 | # Qwt-Qt4_FOUND - Qwt was found and uses Qt4 13 | # Qwt-Qt3_FOUND - Qwt was found and uses Qt3 14 | # Qwt_FOUND - Set to TRUE if Qwt was found (linked either to Qt3 or Qt4) 15 | 16 | # Copyright (c) 2012, Gian Diego Tipaldi, 17 | # Copyright (c) 2007, Pau Garcia i Quiles, 18 | # 19 | # Redistribution and use is allowed according to the terms of the BSD license. 20 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 21 | 22 | # Condition is "(A OR B) AND C", CMake does not support parentheses but it evaluates left to right 23 | IF(Qwt-Qt4_LIBRARY OR Qwt-Qt3_LIBRARY AND Qwt_INCLUDE_DIR) 24 | SET(Qwt_FIND_QUIETLY TRUE) 25 | ENDIF(Qwt-Qt4_LIBRARY OR Qwt-Qt3_LIBRARY AND Qwt_INCLUDE_DIR) 26 | 27 | FIND_PACKAGE( Qt4 REQUIRED QUIET ) 28 | 29 | # Is Qwt installed? Look for header files 30 | FIND_PATH( Qwt_INCLUDE_DIR qwt.h PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES qwt qwt5 qwt-qt4 qwt5-qt4 qwt-qt3 qwt5-qt3 include qwt/include qwt5/include qwt-qt4/include qwt5-qt4/include qwt-qt3/include qwt5-qt3/include ENV PATH) 31 | 32 | # Find Qwt version 33 | IF( Qwt_INCLUDE_DIR ) 34 | IF( QT4_FOUND ) 35 | FILE( READ ${Qwt_INCLUDE_DIR}/qwt_global.h QWT_GLOBAL_H ) 36 | STRING(REGEX REPLACE ".*#define *QWT_VERSION *(0x0[0-9]*).*" "\\1" Qwt_VERSION ${QWT_GLOBAL_H}) 37 | 38 | # Find Qwt library linked to Qt4 39 | FIND_LIBRARY( Qwt-Qt4_TENTATIVE_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt5 qwt ) 40 | IF( UNIX AND NOT CYGWIN) 41 | IF( Qwt-Qt4_TENTATIVE_LIBRARY ) 42 | #MESSAGE("Qwt-Qt4_TENTATIVE_LIBRARY = ${Qwt-Qt4_TENTATIVE_LIBRARY}") 43 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt-Qt4_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt4_LIBRARIES_LINKED_TO ) 44 | STRING( REGEX MATCH "QtCore" Qwt_IS_LINKED_TO_Qt4 ${Qwt-Qt4_LIBRARIES_LINKED_TO}) 45 | IF( Qwt_IS_LINKED_TO_Qt4 ) 46 | SET( Qwt-Qt4_LIBRARY ${Qwt-Qt4_TENTATIVE_LIBRARY} ) 47 | SET( Qwt-Qt4_FOUND TRUE ) 48 | IF (NOT Qwt_FIND_QUIETLY) 49 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" ) 50 | ENDIF (NOT Qwt_FIND_QUIETLY) 51 | ENDIF( Qwt_IS_LINKED_TO_Qt4 ) 52 | ENDIF( Qwt-Qt4_TENTATIVE_LIBRARY ) 53 | ELSE( UNIX AND NOT CYGWIN) 54 | # Assumes qwt.dll is in the Qt dir 55 | SET( Qwt-Qt4_LIBRARY ${Qwt-Qt4_TENTATIVE_LIBRARY} ) 56 | SET( Qwt-Qt4_FOUND TRUE ) 57 | IF (NOT Qwt_FIND_QUIETLY) 58 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" ) 59 | ENDIF (NOT Qwt_FIND_QUIETLY) 60 | ENDIF( UNIX AND NOT CYGWIN) 61 | 62 | ELSE( QT4_FOUND ) 63 | # Find Qwt library linked to Qt3 64 | FIND_LIBRARY( Qwt-Qt3_TENTATIVE_LIBRARY NAMES qwt-qt3 qwt qwt5-qt3 qwt5 ) 65 | IF( UNIX AND NOT CYGWIN) 66 | IF( Qwt-Qt3_TENTATIVE_LIBRARY ) 67 | #MESSAGE("Qwt-Qt3_TENTATIVE_LIBRARY = ${Qwt-Qt3_TENTATIVE_LIBRARY}") 68 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt-Qt3_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt3_LIBRARIES_LINKED_TO ) 69 | STRING( REGEX MATCH "qt-mt" Qwt_IS_LINKED_TO_Qt3 ${Qwt-Qt3_LIBRARIES_LINKED_TO}) 70 | IF( Qwt_IS_LINKED_TO_Qt3 ) 71 | SET( Qwt-Qt3_LIBRARY ${Qwt-Qt3_TENTATIVE_LIBRARY} ) 72 | SET( Qwt-Qt3_FOUND TRUE ) 73 | IF (NOT Qwt_FIND_QUIETLY) 74 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" ) 75 | ENDIF (NOT Qwt_FIND_QUIETLY) 76 | ENDIF( Qwt_IS_LINKED_TO_Qt3 ) 77 | ENDIF( Qwt-Qt3_TENTATIVE_LIBRARY ) 78 | ELSE( UNIX AND NOT CYGWIN) 79 | SET( Qwt-Qt3_LIBRARY ${Qwt-Qt3_TENTATIVE_LIBRARY} ) 80 | SET( Qwt-Qt3_FOUND TRUE ) 81 | IF (NOT Qwt_FIND_QUIETLY) 82 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" ) 83 | ENDIF (NOT Qwt_FIND_QUIETLY) 84 | ENDIF( UNIX AND NOT CYGWIN) 85 | 86 | IF( Qwt-Qt4_FOUND OR Qwt-Qt3_FOUND ) 87 | SET( Qwt_FOUND TRUE ) 88 | ENDIF( Qwt-Qt4_FOUND OR Qwt-Qt3_FOUND ) 89 | 90 | MARK_AS_ADVANCED( Qwt_INCLUDE_DIR Qwt-Qt4_LIBRARY Qwt-Qt3_LIBRARY ) 91 | 92 | ENDIF( QT4_FOUND ) 93 | IF (NOT Qwt_FOUND AND Qwt_FIND_REQUIRED) 94 | MESSAGE(FATAL_ERROR "Could not find Qwt") 95 | ENDIF (NOT Qwt_FOUND AND Qwt_FIND_REQUIRED) 96 | ENDIF( Qwt_INCLUDE_DIR ) 97 | -------------------------------------------------------------------------------- /cmake/FindQwt5.cmake: -------------------------------------------------------------------------------- 1 | # Find the Qwt includes and library, either the version linked to Qt3 or the version linked to Qt4 2 | # 3 | # On Windows it makes these assumptions: 4 | # - the Qwt DLL is where the other DLLs for Qt are (QT_DIR\bin) or in the path 5 | # - the Qwt .h files are in QT_DIR\include\Qwt or in the path 6 | # - the Qwt .lib is where the other LIBs for Qt are (QT_DIR\lib) or in the path 7 | # 8 | # Qwt_INCLUDE_DIR - Where to find qwt.h if Qwt 9 | # Qwt_VERSION - The version of the library installed 10 | # Qwt-Qt4_LIBRARY - The Qwt library linked against Qt4 (if it exists) 11 | # Qwt-Qt3_LIBRARY - The Qwt library linked against Qt3 (if it exists) 12 | # Qwt-Qt4_FOUND - Qwt was found and uses Qt4 13 | # Qwt-Qt3_FOUND - Qwt was found and uses Qt3 14 | # Qwt_FOUND - Set to TRUE if Qwt was found (linked either to Qt3 or Qt4) 15 | 16 | # Copyright (c) 2012, Gian Diego Tipaldi, 17 | # Copyright (c) 2007, Pau Garcia i Quiles, 18 | # 19 | # Redistribution and use is allowed according to the terms of the BSD license. 20 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 21 | 22 | # Condition is "(A OR B) AND C", CMake does not support parentheses but it evaluates left to right 23 | IF(Qwt-Qt4_LIBRARY OR Qwt-Qt3_LIBRARY AND Qwt_INCLUDE_DIR) 24 | SET(Qwt_FIND_QUIETLY TRUE) 25 | ENDIF(Qwt-Qt4_LIBRARY OR Qwt-Qt3_LIBRARY AND Qwt_INCLUDE_DIR) 26 | 27 | FIND_PACKAGE( Qt4 REQUIRED QUIET ) 28 | 29 | # Is Qwt installed? Look for header files 30 | FIND_PATH( Qwt_INCLUDE_DIR qwt.h PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES qwt qwt5 qwt-qt4 qwt5-qt4 qwt-qt3 qwt5-qt3 include qwt/include qwt5/include qwt-qt4/include qwt5-qt4/include qwt-qt3/include qwt5-qt3/include ENV PATH) 31 | 32 | # Find Qwt version 33 | IF( Qwt_INCLUDE_DIR ) 34 | IF( QT4_FOUND ) 35 | FILE( READ ${Qwt_INCLUDE_DIR}/qwt_global.h QWT_GLOBAL_H ) 36 | STRING(REGEX REPLACE ".*#define *QWT_VERSION *(0x0[0-9]*).*" "\\1" Qwt_VERSION ${QWT_GLOBAL_H}) 37 | 38 | # Find Qwt library linked to Qt4 39 | FIND_LIBRARY( Qwt-Qt4_TENTATIVE_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt5 qwt ) 40 | IF( UNIX AND NOT CYGWIN) 41 | IF( Qwt-Qt4_TENTATIVE_LIBRARY ) 42 | #MESSAGE("Qwt-Qt4_TENTATIVE_LIBRARY = ${Qwt-Qt4_TENTATIVE_LIBRARY}") 43 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt-Qt4_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt4_LIBRARIES_LINKED_TO ) 44 | STRING( REGEX MATCH "QtCore" Qwt_IS_LINKED_TO_Qt4 ${Qwt-Qt4_LIBRARIES_LINKED_TO}) 45 | IF( Qwt_IS_LINKED_TO_Qt4 ) 46 | SET( Qwt-Qt4_LIBRARY ${Qwt-Qt4_TENTATIVE_LIBRARY} ) 47 | SET( Qwt-Qt4_FOUND TRUE ) 48 | IF (NOT Qwt_FIND_QUIETLY) 49 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" ) 50 | ENDIF (NOT Qwt_FIND_QUIETLY) 51 | ENDIF( Qwt_IS_LINKED_TO_Qt4 ) 52 | ENDIF( Qwt-Qt4_TENTATIVE_LIBRARY ) 53 | ELSE( UNIX AND NOT CYGWIN) 54 | # Assumes qwt.dll is in the Qt dir 55 | SET( Qwt-Qt4_LIBRARY ${Qwt-Qt4_TENTATIVE_LIBRARY} ) 56 | SET( Qwt-Qt4_FOUND TRUE ) 57 | IF (NOT Qwt_FIND_QUIETLY) 58 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" ) 59 | ENDIF (NOT Qwt_FIND_QUIETLY) 60 | ENDIF( UNIX AND NOT CYGWIN) 61 | 62 | ELSE( QT4_FOUND ) 63 | # Find Qwt library linked to Qt3 64 | FIND_LIBRARY( Qwt-Qt3_TENTATIVE_LIBRARY NAMES qwt-qt3 qwt qwt5-qt3 qwt5 ) 65 | IF( UNIX AND NOT CYGWIN) 66 | IF( Qwt-Qt3_TENTATIVE_LIBRARY ) 67 | #MESSAGE("Qwt-Qt3_TENTATIVE_LIBRARY = ${Qwt-Qt3_TENTATIVE_LIBRARY}") 68 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt-Qt3_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt3_LIBRARIES_LINKED_TO ) 69 | STRING( REGEX MATCH "qt-mt" Qwt_IS_LINKED_TO_Qt3 ${Qwt-Qt3_LIBRARIES_LINKED_TO}) 70 | IF( Qwt_IS_LINKED_TO_Qt3 ) 71 | SET( Qwt-Qt3_LIBRARY ${Qwt-Qt3_TENTATIVE_LIBRARY} ) 72 | SET( Qwt-Qt3_FOUND TRUE ) 73 | IF (NOT Qwt_FIND_QUIETLY) 74 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" ) 75 | ENDIF (NOT Qwt_FIND_QUIETLY) 76 | ENDIF( Qwt_IS_LINKED_TO_Qt3 ) 77 | ENDIF( Qwt-Qt3_TENTATIVE_LIBRARY ) 78 | ELSE( UNIX AND NOT CYGWIN) 79 | SET( Qwt-Qt3_LIBRARY ${Qwt-Qt3_TENTATIVE_LIBRARY} ) 80 | SET( Qwt-Qt3_FOUND TRUE ) 81 | IF (NOT Qwt_FIND_QUIETLY) 82 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" ) 83 | ENDIF (NOT Qwt_FIND_QUIETLY) 84 | ENDIF( UNIX AND NOT CYGWIN) 85 | 86 | IF( Qwt-Qt4_FOUND OR Qwt-Qt3_FOUND ) 87 | SET( Qwt_FOUND TRUE ) 88 | ENDIF( Qwt-Qt4_FOUND OR Qwt-Qt3_FOUND ) 89 | 90 | MARK_AS_ADVANCED( Qwt_INCLUDE_DIR Qwt-Qt4_LIBRARY Qwt-Qt3_LIBRARY ) 91 | 92 | ENDIF( QT4_FOUND ) 93 | IF (NOT Qwt_FOUND AND Qwt_FIND_REQUIRED) 94 | MESSAGE(FATAL_ERROR "Could not find Qwt") 95 | ENDIF (NOT Qwt_FOUND AND Qwt_FIND_REQUIRED) 96 | ENDIF( Qwt_INCLUDE_DIR ) 97 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | flirtlib 4 | 1.1.0 5 | FLIRTlib 6 | 7 | Enrique Fernandez 8 | Gian Diego Tipaldi 9 | Kai O. Arras 10 | 11 | LGPL 12 | 13 | cmake 14 | 15 | boost 16 | libcairo2-dev 17 | libqwt6 18 | 19 | libqt4-dev 20 | libqt4-opengl-dev 21 | doxygen 22 | 23 | libqt4 24 | libqt4-opengl 25 | 26 | 27 | 28 | cmake 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_EXECUTABLE(ransacLoopClosureTest RansacLoopClosureTest.cpp) 2 | TARGET_LINK_LIBRARIES(ransacLoopClosureTest flirtlib_feature flirtlib_sensorstream flirtlib_sensors flirtlib_utils) 3 | 4 | install(TARGETS ransacLoopClosureTest 5 | RUNTIME DESTINATION bin 6 | LIBRARY DESTINATION lib/flirtlib 7 | ARCHIVE DESTINATION lib/flirtlib) 8 | 9 | IF(CAIRO_FOUND) 10 | ADD_EXECUTABLE(ransacLoopClosureDraw RansacLoopClosureDrawMovie.cpp) 11 | TARGET_LINK_LIBRARIES(ransacLoopClosureDraw flirtlib_feature flirtlib_sensorstream flirtlib_sensors flirtlib_utils ${CAIRO_LIBRARIES}) 12 | install(TARGETS ransacLoopClosureDraw 13 | RUNTIME DESTINATION bin 14 | LIBRARY DESTINATION lib/flirtlib 15 | ARCHIVE DESTINATION lib/flirtlib) 16 | ENDIF(CAIRO_FOUND) 17 | 18 | if(BUILD_GUI) 19 | QT4_AUTOMOC( 20 | FLIRTDemo.cpp 21 | ) 22 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 23 | ADD_EXECUTABLE(flirtDemo FLIRTDemo.cpp) 24 | TARGET_LINK_LIBRARIES(flirtDemo flirtlib_gui) 25 | install(TARGETS flirtDemo 26 | RUNTIME DESTINATION bin 27 | LIBRARY DESTINATION lib/flirtlib 28 | ARCHIVE DESTINATION lib/flirtlib) 29 | endif() 30 | 31 | -------------------------------------------------------------------------------- /src/feature/AbstractFeatureSetMatcher.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "AbstractFeatureSetMatcher.h" 23 | 24 | AbstractFeatureSetMatcher::AbstractFeatureSetMatcher(double acceptanceThreshold): 25 | m_acceptanceThreshold(acceptanceThreshold) 26 | { 27 | 28 | } 29 | 30 | OrientedPoint2D AbstractFeatureSetMatcher::generateHypothesis(const std::pair< std::pair, std::pair > &correspondences) const 31 | { 32 | Point2D baseDelta = correspondences.first.first->getPosition() - correspondences.second.first->getPosition(); 33 | Point2D transformedDelta = correspondences.first.second->getPosition() - correspondences.second.second->getPosition(); 34 | const Point2D& baseSecond = correspondences.second.first->getPosition(); 35 | const Point2D& transformedSecond = correspondences.second.second->getPosition(); 36 | double denominator = 1. / (baseDelta * baseDelta); 37 | double cosalpha = denominator * (baseDelta * transformedDelta); 38 | double sinalpha = - denominator * (baseDelta.ortho() * transformedDelta); 39 | double x = transformedSecond.x - cosalpha * baseSecond.x + sinalpha * baseSecond.y; 40 | double y = transformedSecond.y - cosalpha * baseSecond.y - sinalpha * baseSecond.x; 41 | return OrientedPoint2D(x, y, atan2(sinalpha, cosalpha)); 42 | } 43 | 44 | double AbstractFeatureSetMatcher::verifyHypothesis(const std::vector &reference, const std::vector &data, const OrientedPoint2D& transformation, 45 | std::vector< std::pair > &inlierSet) const 46 | { 47 | // double maxCorrespondences = reference.size() < data.size() ? reference.size() : data.size(); 48 | double maxCorrespondences = data.size(); 49 | double score = 0.; 50 | inlierSet.clear(); 51 | inlierSet.reserve(maxCorrespondences); 52 | for(unsigned int i = 0; i < data.size(); i++){ 53 | double minDistance = 1e17; 54 | unsigned int minIndex = 0; 55 | const Point2D point1 = transformation.oplus(data[i]->getPosition()); 56 | for(unsigned int j = 0; j < reference.size(); j++){ 57 | const Point2D& point2 = reference[j]->getPosition(); 58 | double currentDistance = (point1 - point2) * (point1 - point2); 59 | if(currentDistance < minDistance) { 60 | minDistance = currentDistance; 61 | minIndex = j; 62 | } 63 | } 64 | // std::cout << "Distance: " << minDistance << ", threshold: " << m_acceptanceThreshold << std::endl; 65 | if(minDistance < m_acceptanceThreshold){ 66 | // std::cout << "\tAdding correspondence" << std::endl; 67 | // std::cout << "\t\t" << data[i]->getPosition() << " <-> " << reference[minIndex]->getPosition() << std::endl; 68 | // std::cout << "\t\t" << point1 << " <-> " << reference[minIndex]->getPosition() << std::endl; 69 | inlierSet.push_back(std::make_pair(data[i], reference[minIndex])); 70 | } else { 71 | minDistance = m_acceptanceThreshold; 72 | } 73 | score += minDistance; 74 | } 75 | return score / double(data.size()); 76 | } 77 | -------------------------------------------------------------------------------- /src/feature/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(feature_SRCS 2 | InterestPoint.cpp 3 | MultiScaleDetector.cpp 4 | RangeDetector.cpp 5 | NormalDetector.cpp 6 | NormalEdgeDetector.cpp 7 | NormalBlobDetector.cpp 8 | CurvatureDetector.cpp 9 | ShapeContext.cpp 10 | BetaGrid.cpp 11 | AbstractFeatureSetMatcher.cpp 12 | RansacFeatureSetMatcher.cpp 13 | RansacMultiFeatureSetMatcher.cpp 14 | ) 15 | 16 | SET(feature_HDRS 17 | Detector.h 18 | Descriptor.h 19 | InterestPoint.h 20 | MultiScaleDetector.h 21 | RangeDetector.h 22 | NormalDetector.h 23 | NormalEdgeDetector.h 24 | NormalBlobDetector.h 25 | CurvatureDetector.h 26 | ShapeContext.h 27 | BetaGrid.h 28 | AbstractFeatureSetMatcher.h 29 | RansacFeatureSetMatcher.h 30 | RansacMultiFeatureSetMatcher.h 31 | ) 32 | 33 | ADD_LIBRARY(flirtlib_feature SHARED ${feature_SRCS}) 34 | TARGET_LINK_LIBRARIES(flirtlib_feature ${Boost_SERIALIZATION_LIBRARY}) 35 | 36 | install(TARGETS flirtlib_feature 37 | RUNTIME DESTINATION bin 38 | LIBRARY DESTINATION lib 39 | ARCHIVE DESTINATION lib) 40 | 41 | install(FILES ${feature_HDRS} DESTINATION include/flirtlib/feature) 42 | -------------------------------------------------------------------------------- /src/feature/Descriptor.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DESCRIPTOR_H_ 22 | #define DESCRIPTOR_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class InterestPoint; 33 | class LaserReading; 34 | class OrientedPoint2D; 35 | 36 | /** 37 | * Representation of an abstract descriptor. 38 | * The class represents an abstract descriptor, defining the interface for comparing two descriptors. 39 | * 40 | * @author Gian Diego Tipaldi 41 | */ 42 | 43 | class Descriptor { 44 | public: 45 | /** Clone function for prototyping. It implements the Prototype pattern. */ 46 | virtual Descriptor* clone() const = 0; 47 | 48 | /** Default destructor. */ 49 | virtual ~Descriptor() { } 50 | 51 | /** 52 | * Abstract interface for computing the distance between two descriptors. 53 | * The implementation of the actual distance is left to the inherited classes. 54 | * 55 | */ 56 | virtual double distance(const Descriptor* descriptor) const = 0; 57 | 58 | /** 59 | * Returns the descriptor in the form of onedimensional histogram. The resulting vector represents the feature descriptor. 60 | * 61 | */ 62 | virtual void getFlatDescription(std::vector& description) const = 0; 63 | 64 | /** 65 | * Returns the descriptor in the form of a weighted onedimensional histogram. The resulting vectors represent the feature descriptor and the importance of each dimension. 66 | * @param description the descriptor vector 67 | * @param weight the descriptor variance 68 | * 69 | */ 70 | virtual void getWeightedFlatDescription(std::vector& description, std::vector& weight) const 71 | {getFlatDescription(description); weight.resize(description.size(),1.);} 72 | 73 | protected: 74 | friend class boost::serialization::access; 75 | 76 | /** Serializes the class using boost::serialization. */ 77 | template 78 | void serialize(Archive & ar, const unsigned int version); 79 | }; 80 | 81 | template 82 | void Descriptor::serialize(Archive& ar, const unsigned int version) 83 | { 84 | BOOST_SERIALIZATION_ASSUME_ABSTRACT(Descriptor); 85 | } 86 | 87 | #if BOOST_VERSION > 104000 88 | BOOST_CLASS_EXPORT_KEY(Descriptor); 89 | #endif 90 | 91 | /** 92 | * Representation of an abstract descriptor generator. 93 | * The class represents an abstract descriptor generator, defining the interface for generating the description of an interest point. 94 | * 95 | * @author Gian Diego Tipaldi 96 | */ 97 | 98 | class DescriptorGenerator{ 99 | public: 100 | 101 | /** Default destructor. */ 102 | virtual ~DescriptorGenerator() { } 103 | 104 | /** Abstract interface for generating a descriptors given an interest point and a laser reading. */ 105 | virtual Descriptor* describe(const InterestPoint& _point, const LaserReading& reading) = 0; 106 | 107 | /** Abstract interface for generating a descriptors given a general point in \f$ \mathcal{SO}(2) \f$ and a laser reading. */ 108 | virtual Descriptor* describe(const OrientedPoint2D& _point, const LaserReading& reading) = 0; 109 | }; 110 | 111 | #endif 112 | 113 | -------------------------------------------------------------------------------- /src/feature/Detector.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DETECTOR_H_ 22 | #define DETECTOR_H_ 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * Representation of an abstract detector. 29 | * This class represents an abstract detector, defining the interface for detecting interest points in laser readings. 30 | * 31 | * @author Gian Diego Tipaldi 32 | */ 33 | 34 | 35 | class Detector { 36 | public: 37 | /** Default destructor. */ 38 | virtual ~Detector() { } 39 | 40 | /** 41 | * Detects the interesting points given the laser reading. 42 | * 43 | * @return The number of interest points detected. 44 | * 45 | * @param reading The laser reading. 46 | * @param points The detected interest points. 47 | */ 48 | virtual unsigned int detect(const LaserReading& reading, std::vector& points) const = 0; 49 | 50 | /** 51 | * Detects the interesting points given the laser reading. It also returns the signals used for the computation. 52 | * 53 | * @return The number of interest points detected. 54 | * 55 | * @param reading The laser reading. 56 | * @param points The detected interest points. 57 | * @param signal The signal used for computing the interest points. 58 | * @param signalSmooth The smoothed signal at the different scales. 59 | * @param signalDiff The differential operator applied to the signal at the different scales. 60 | * @param indexes The indexes of the differential operator maxima at the different scales. 61 | */ 62 | virtual unsigned int detect(const LaserReading& reading, std::vector& points, 63 | std::vector< double >& signal, 64 | std::vector< std::vector >& signalSmooth, 65 | std::vector< std::vector >& signalDiff, 66 | std::vector< std::vector >& indexes) const = 0; 67 | 68 | }; 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/feature/InterestPoint.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "InterestPoint.h" 23 | 24 | InterestPoint::InterestPoint(const OrientedPoint2D& _position, double _scale, const Descriptor* _descriptor): 25 | m_position(_position), 26 | m_scale(_scale), 27 | m_scaleLevel(0), 28 | m_descriptor(NULL) 29 | { 30 | if(_descriptor) m_descriptor = _descriptor->clone(); 31 | } 32 | 33 | InterestPoint::InterestPoint(const InterestPoint& _point): 34 | m_position(_point.getPosition()), 35 | m_scale(_point.getScale()), 36 | m_scaleLevel(_point.getScaleLevel()) 37 | { 38 | if(_point.getDescriptor()) 39 | m_descriptor = _point.getDescriptor()->clone(); 40 | else 41 | m_descriptor = 0; 42 | } 43 | 44 | InterestPoint& InterestPoint::operator=(const InterestPoint& _point){ 45 | m_position = _point.getPosition(); 46 | m_scale = _point.getScale(); 47 | m_scaleLevel = _point.getScaleLevel(); 48 | delete m_descriptor; 49 | m_descriptor = _point.getDescriptor()->clone(); 50 | return *this; 51 | } 52 | 53 | InterestPoint::~InterestPoint(){ 54 | delete m_descriptor; 55 | } 56 | -------------------------------------------------------------------------------- /src/feature/MultiScaleDetector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "MultiScaleDetector.h" 23 | 24 | 25 | MultiScaleDetector::MultiScaleDetector(const PeakFinder* _peak, unsigned int _scales, double _sigma, double step, SmoothingFilterFamily _filterType): 26 | m_peakFinder(_peak), 27 | m_scaleNumber(_scales), 28 | m_baseSigma(_sigma), 29 | m_sigmaStep(step), 30 | m_useMaxRange(false), 31 | m_filterType(_filterType) 32 | { 33 | computeFilterBank(); 34 | } 35 | 36 | unsigned int MultiScaleDetector::detect(const LaserReading& reading, std::vector& point) const{ 37 | std::vector signal; 38 | std::vector< std::vector > signalSmooth; 39 | std::vector< std::vector > signalDiff; 40 | std::vector< std::vector > indexes; 41 | return detect(reading, point, signal, signalSmooth, signalDiff, indexes); 42 | } 43 | 44 | unsigned int MultiScaleDetector::detect(const LaserReading& reading, std::vector& point, 45 | std::vector< double >& signal, 46 | std::vector< std::vector >& signalSmooth, 47 | std::vector< std::vector >& signalDiff, 48 | std::vector< std::vector >& indexes) const 49 | { 50 | std::vector maxRangeMapping; 51 | computeSignal(reading, signal, maxRangeMapping); 52 | detect(signal, signalSmooth, signalDiff, indexes); 53 | return computeInterestPoints(reading, signal, point, indexes, maxRangeMapping); 54 | } 55 | 56 | void MultiScaleDetector::detect(const std::vector& signal, 57 | std::vector< std::vector >& signalSmooth, 58 | std::vector< std::vector >& signalDiff, 59 | std::vector< std::vector >& indexes) const 60 | { 61 | signalSmooth.resize(m_scaleNumber); 62 | signalDiff.resize(m_scaleNumber); 63 | indexes.resize(m_scaleNumber); 64 | for(unsigned int i = 0; i < m_filterBank.size(); i++){ 65 | int offsetRange = floor((int)m_filterBank[i].size()/2.0); 66 | if(offsetRange > signal.size()) continue; 67 | signalSmooth[i] = convolve1D(signal, m_filterBank[i], -offsetRange); 68 | signalDiff[i] = convolve1D(signalSmooth[i], m_differentialBank[i], -1); 69 | for(unsigned int j = offsetRange + 1; j < signal.size() - offsetRange - 1; j++){ 70 | if(m_peakFinder->isPeak(signalDiff[i], j)){ 71 | indexes[i].push_back(j); 72 | } 73 | } 74 | } 75 | } 76 | 77 | void MultiScaleDetector::computeFilterBank(){ 78 | m_filterBank.resize(m_scaleNumber); 79 | m_scales.resize(m_scaleNumber); 80 | for(unsigned int i = 0; i < m_filterBank.size(); i++){ 81 | m_scales[i] = m_baseSigma * pow(m_sigmaStep, i); 82 | unsigned int kernelSize = 2*ceil(m_scales[i])+1; 83 | if(kernelSize < MIN_KERNEL_SIZE) 84 | kernelSize = MIN_KERNEL_SIZE; 85 | else if(kernelSize > MAX_KERNEL_SIZE) 86 | kernelSize = MAX_KERNEL_SIZE; 87 | switch(m_filterType){ 88 | case GAUSSIAN: 89 | m_filterBank[i] = gaussianKernel1D(m_scales[i], kernelSize); break; 90 | case BESSEL: 91 | m_filterBank[i] = besselKernel1D(m_scales[i], kernelSize); break; 92 | default: 93 | m_filterBank[i] = besselKernel1D(m_scales[i], kernelSize); break; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/feature/NormalBlobDetector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "NormalBlobDetector.h" 23 | 24 | 25 | NormalBlobDetector::NormalBlobDetector(const PeakFinder* peak, unsigned int scales, double sigma, double step, unsigned int window, SmoothingFilterFamily filterType): 26 | NormalDetector(peak, scales, sigma, step, window, filterType) 27 | { 28 | computeDifferentialBank(); 29 | } 30 | 31 | void NormalBlobDetector::computeDifferentialBank(){ 32 | m_differentialBank.resize(m_scaleNumber, std::vector(3)); 33 | for(unsigned int i = 0; i < m_differentialBank.size(); i++){ 34 | m_differentialBank[i][0] = m_scales[i]*1; 35 | m_differentialBank[i][1] = -m_scales[i]*2; 36 | m_differentialBank[i][2] = m_scales[i]*1; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/feature/NormalBlobDetector.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef NORMALBLOBDETECTOR_H_ 22 | #define NORMALBLOBDETECTOR_H_ 23 | 24 | #include 25 | 26 | /** 27 | * Representation of the normal blob detector. 28 | * The class represents the normal blob detector defined in the paper. It extracts blobs (extrema of the second derivative) on the normal signal. 29 | * 30 | * @author Gian Diego Tipaldi 31 | */ 32 | 33 | class NormalBlobDetector: public NormalDetector { 34 | public: 35 | /** 36 | * Constructor. Constructs and initialize the normal blob detector. 37 | * 38 | * @param peak The peak finder used to detect maxima in the signal. 39 | * @param scales The number of different scales to consider. 40 | * @param sigma The standard deviation of the smoothing kernel for the initial scale (\f$ t_0 \f$ in the paper). 41 | * @param step The scale increment at every new scale (\f$ t_i \f$ in the paper). The standard deviation of the kernel at scale \f$ s \f$ is \f$ t_0 \cdot (t_i)^s \f$ 42 | * @param window The window size for the local line fitting. 43 | * @param filterType The smoothing kernel used in the detector. 44 | */ 45 | NormalBlobDetector(const PeakFinder* peak, unsigned int scales = 5, double sigma = 1.6, double step = 1.4, unsigned int window = 3, SmoothingFilterFamily filterType = BESSEL); 46 | 47 | /** Default destructor. */ 48 | virtual ~NormalBlobDetector() { } 49 | 50 | protected: 51 | /** Computes the bank for the second derivative at different scales. */ 52 | virtual void computeDifferentialBank(); 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/feature/NormalDetector.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef NORMALDETECTOR_H_ 22 | #define NORMALDETECTOR_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | /** 34 | * Representation of a general detector based on the normal signal. 35 | * The class represents a general detector based on the normal signal. It computes the normal signal and define the general interface for detection. 36 | * The concrete detectors provides the precise differential invariant. 37 | * 38 | * @author Gian Diego Tipaldi 39 | */ 40 | 41 | class NormalDetector: public MultiScaleDetector { 42 | public: 43 | /** 44 | * Constructor. Constructs and initialize a general detector based on a normal signal. 45 | * 46 | * @param peak The peak finder used to detect maxima in the signal. 47 | * @param scales The number of different scales to consider. 48 | * @param sigma The standard deviation of the smoothing kernel for the initial scale (\f$ t_0 \f$ in the paper). 49 | * @param step The scale increment at every new scale (\f$ t_i \f$ in the paper). The standard deviation of the kernel at scale \f$ s \f$ is \f$ t_0 \cdot (t_i)^s \f$ 50 | * @param window The window size for the local line fitting. 51 | * @param filterType The smoothing kernel used in the detector. 52 | */ 53 | NormalDetector(const PeakFinder* peak, unsigned int scales = 5, double sigma = 1.6, double step = 1.4, unsigned int window = 3, SmoothingFilterFamily filterType = BESSEL); 54 | 55 | /** Virtual Default destructor. */ 56 | virtual ~NormalDetector() { } 57 | 58 | /** Sets the window size for the local line fitting. */ 59 | inline void setWindowSize(unsigned int size) 60 | {m_windowSize = size;} 61 | 62 | /** Gets the window size for the local line fitting. */ 63 | inline unsigned int getWindowSize() const 64 | {return m_windowSize;} 65 | 66 | protected: 67 | virtual void computeDifferentialBank() = 0; 68 | virtual void computeSignal(const LaserReading& reading, std::vector& signal, std::vector& maxRangeMapping) const; 69 | virtual unsigned int computeInterestPoints(const LaserReading& reading, const std::vector& signal, std::vector& point, 70 | std::vector< std::vector >& indexes, std::vector& maxRangeMapping) const; 71 | 72 | unsigned int m_windowSize; /**< The window size for the local line fitting. */ 73 | }; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/feature/NormalEdgeDetector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "NormalEdgeDetector.h" 23 | 24 | 25 | NormalEdgeDetector::NormalEdgeDetector(const PeakFinder* peak, unsigned int scales, double sigma, double step, unsigned int window, SmoothingFilterFamily filterType): 26 | NormalDetector(peak, scales, sigma, step, window, filterType) 27 | { 28 | computeDifferentialBank(); 29 | } 30 | 31 | void NormalEdgeDetector::computeDifferentialBank(){ 32 | m_differentialBank.resize(m_scaleNumber, std::vector(3)); 33 | for(unsigned int i = 0; i < m_differentialBank.size(); i++){ 34 | m_differentialBank[i][0] = -sqrt(m_scales[i])*0.5; 35 | m_differentialBank[i][1] = 0; 36 | m_differentialBank[i][2] = sqrt(m_scales[i])*0.5; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/feature/NormalEdgeDetector.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef NORMALEDGEDETECTOR_H_ 22 | #define NORMALEDGEDETECTOR_H_ 23 | 24 | #include 25 | 26 | /** 27 | * Representation of the normal edge detector. 28 | * The class represents the normal edge detector defined in the paper. It extracts edges (extrema of the first derivative) on the normal signal. 29 | * 30 | * @author Gian Diego Tipaldi 31 | */ 32 | 33 | class NormalEdgeDetector: public NormalDetector { 34 | public: 35 | /** 36 | * Constructor. Constructs and initialize the normal edge detector. 37 | * 38 | * @param peak The peak finder used to detect maxima in the signal. 39 | * @param scales The number of different scales to consider. 40 | * @param sigma The standard deviation of the smoothing kernel for the initial scale (\f$ t_0 \f$ in the paper). 41 | * @param step The scale increment at every new scale (\f$ t_i \f$ in the paper). The standard deviation of the kernel at scale \f$ s \f$ is \f$ t_0 \cdot (t_i)^s \f$ 42 | * @param window The window size for the local line fitting. 43 | * @param filterType The smoothing kernel used in the detector. 44 | */ 45 | NormalEdgeDetector(const PeakFinder* peak, unsigned int scales = 5, double sigma = 1.6, double step = 1.4, unsigned int window = 3, SmoothingFilterFamily filterType = BESSEL); 46 | 47 | /** Virtual Default destructor. */ 48 | virtual ~NormalEdgeDetector() { } 49 | 50 | protected: 51 | /** Computes the bank for the first derivative at different scales. */ 52 | virtual void computeDifferentialBank(); 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/feature/RangeDetector.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef RANGEDETECTOR_H_ 22 | #define RANGEDETECTOR_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | /** 33 | * Representation of the range based detector. 34 | * The class represents the range based detector defined in the paper. It extracts blobs (extrema of the second derivative) on the range signal. 35 | * This is equivalent of applying the theory behind the SIFT detector on the monodimensional range image. 36 | * 37 | * @author Gian Diego Tipaldi 38 | */ 39 | 40 | class RangeDetector: public MultiScaleDetector { 41 | public: 42 | /** 43 | * Constructor. Constructs and initialize the range based detector. 44 | * 45 | * @param peak The peak finder used to detect maxima in the signal. 46 | * @param scales The number of different scales to consider. 47 | * @param sigma The standard deviation of the smoothing kernel for the initial scale (\f$ t_0 \f$ in the paper). 48 | * @param step The scale increment at every new scale (\f$ t_i \f$ in the paper). The standard deviation of the kernel at scale \f$ s \f$ is \f$ t_0 \cdot (t_i)^s \f$ 49 | * @param filterType The smoothing kernel used in the detector. 50 | */ 51 | RangeDetector(const PeakFinder* peak, unsigned int scales = 5, double sigma = 1.6, double step = 1.4, SmoothingFilterFamily filterType = BESSEL); 52 | 53 | /** Virtual Default destructor. */ 54 | virtual ~RangeDetector() { } 55 | 56 | protected: 57 | /** Computes the bank for the second derivative at different scales. */ 58 | virtual void computeDifferentialBank(); 59 | 60 | virtual void computeSignal(const LaserReading& reading, std::vector& signal, std::vector& maxRangeMapping) const; 61 | 62 | virtual unsigned int computeInterestPoints(const LaserReading& reading, const std::vector& signal, std::vector& point, 63 | std::vector< std::vector >& indexes, std::vector& maxRangeMapping) const; 64 | }; 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /src/feature/RansacMultiFeatureSetMatcher.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef RANSACMULTIFEATURESETMATCHER_H_ 22 | #define RANSACMULTIFEATURESETMATCHER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /** 30 | * Representation of the RANSAC algorithm for feature matching. 31 | * The class represents the RANSAC algorithm for matching two different feature sets. 32 | * The matching result is an Euclidean transformation (rotation + translation) encoded as a point in \f$ \mathcal{SO}(2) \f$. 33 | * The algorithm uses the Threshold strategy to obtain the possible correspondences from the features' descriptors. 34 | * The main difference with the Nearest Neighobour is the increased complexity (reduced inlier probability) and the increased accuracy 35 | * especially in environment with very repetitive structures. 36 | * 37 | * @author Gian Diego Tipaldi 38 | */ 39 | 40 | class RansacMultiFeatureSetMatcher: public RansacFeatureSetMatcher { 41 | public: 42 | /** 43 | * Constructor. Constructs and initializes the RANSAC algorithm. 44 | * 45 | * @param acceptanceThreshold The maximum distance (in meters) for a point to be considered in the inlier set. 46 | * @param successProbability The probability of finding a correct match if exists. 47 | * @param inlierProbability The probability of a generic correspondence to be an inlier. 48 | * @param distanceThreshold The maximum distance (dimensionless) for two descriptors to be considered as a valid match. This threshold depends on the actual distance employed. 49 | * @param rigidityThreshold The maximum value (in meters) of difference between the relative distance of two interest points. This implements a rigidity check in the RANSAC hypothesis generation. 50 | * @param adaptive The flag to set the adaptive strategy to compute the number of RANSAC iterations (EXPERIMENTAL!!!). 51 | */ 52 | RansacMultiFeatureSetMatcher(double acceptanceThreshold, double successProbability, double inlierProbability, double distanceThreshold, double rigidityThreshold, bool adaptive = false); 53 | 54 | virtual double matchSets(const std::vector &reference, const std::vector &data, OrientedPoint2D& transformation, 55 | std::vector< std::pair > &correspondences) const; 56 | 57 | /** Default destructor. */ 58 | virtual ~RansacMultiFeatureSetMatcher() { } 59 | }; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/feature/ShapeContext.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "ShapeContext.h" 23 | 24 | 25 | BOOST_CLASS_EXPORT(ShapeContext); 26 | 27 | Descriptor* ShapeContext::clone() const{ 28 | return new ShapeContext(*this); 29 | } 30 | 31 | void ShapeContext::getFlatDescription(std::vector& description) const { 32 | description.clear(); 33 | for(unsigned int i = 0; i < m_histogram.size(); i++){ 34 | for(unsigned int j = 0; j < m_histogram[i].size(); j++){ 35 | description.push_back(m_histogram[i][j]); 36 | } 37 | } 38 | } 39 | 40 | double ShapeContext::distance(const Descriptor* descriptor) const { 41 | const ShapeContext *shapeContext = dynamic_cast(descriptor); 42 | if(!m_distanceFunction || !shapeContext){ 43 | return 10e16; 44 | } 45 | return m_distanceFunction->distance(this->getHistogram(), shapeContext->getHistogram()); 46 | } 47 | 48 | ShapeContextGenerator::ShapeContextGenerator(double minRho, double maxRho, unsigned int binRho, unsigned int binPhi) 49 | { 50 | setEdges(minRho, maxRho, binRho, binPhi); 51 | } 52 | 53 | ShapeContextGenerator::ShapeContextGenerator(const std::vector& rhoEdges, const std::vector& phiEdges): 54 | m_rhoEdges(rhoEdges), 55 | m_phiEdges(phiEdges) 56 | { 57 | 58 | } 59 | 60 | void ShapeContextGenerator::setEdges(double minRho, double maxRho, unsigned int binRho, unsigned int binPhi){ 61 | m_rhoEdges.resize(binRho+1); 62 | m_phiEdges.resize(binPhi+1); 63 | double minPhi = -M_PI, maxPhi = M_PI; 64 | for(unsigned int i = 0; i <= binRho; i++){ 65 | m_rhoEdges[i] = minRho + double(i)*(maxRho - minRho)/double(binRho); 66 | } 67 | for(unsigned int i = 0; i <= binPhi; i++){ 68 | m_phiEdges[i] = minPhi + double(i)*(maxPhi - minPhi)/double(binPhi); 69 | } 70 | } 71 | 72 | 73 | Descriptor* ShapeContextGenerator::describe(const InterestPoint& point, const LaserReading& reading){ 74 | return describe(point.getPosition(), reading); 75 | } 76 | 77 | Descriptor* ShapeContextGenerator::describe(const OrientedPoint2D& point, const LaserReading& reading){ 78 | unsigned int accumulator = 0; 79 | ShapeContext * shape = new ShapeContext(); 80 | shape->getHistogram().resize(m_phiEdges.size() - 1, std::vector(m_rhoEdges.size() - 1, 0.)); 81 | for(unsigned int i = 0; i < reading.getWorldCartesian().size(); i++){ 82 | Point2D difference = reading.getWorldCartesian()[i] - point; 83 | double distance = hypot(difference.x, difference.y); 84 | if ((distance >= m_rhoEdges[0] && distance < m_rhoEdges[m_rhoEdges.size() - 1])){ 85 | for(unsigned int rho = 0; rho < m_rhoEdges.size() - 1; rho++){ 86 | if((distance < m_rhoEdges[rho + 1] && distance >= m_rhoEdges[rho])){ 87 | double angle = atan2(difference.y, difference.x); 88 | angle = normAngle(angle - point.theta, -M_PI); 89 | for(unsigned int phi = 0; phi < m_phiEdges.size() - 1; phi++){ 90 | if(angle < m_phiEdges[phi + 1] && angle >= m_phiEdges[phi]){ 91 | shape->getHistogram()[phi][rho] += 1.; 92 | accumulator += 1; 93 | } 94 | } 95 | } 96 | } 97 | } 98 | } 99 | int size = shape->getHistogram().size() * shape->getHistogram().front().size(); 100 | for(unsigned int i = 0; i < shape->getHistogram().size(); i++){ 101 | for(unsigned int j = 0; j < shape->getHistogram()[i].size(); j++){ 102 | shape->getHistogram()[i][j] = accumulator ? shape->getHistogram()[i][j]/double(accumulator) : 1./double(size); 103 | } 104 | } 105 | shape->setDistanceFunction(m_distanceFunction); 106 | return shape; 107 | } 108 | 109 | -------------------------------------------------------------------------------- /src/geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(geometry_SRCS 2 | point.cpp 3 | ) 4 | 5 | SET(geometry_HDRS 6 | point.h 7 | ) 8 | 9 | ADD_LIBRARY(flirtlib_geometry SHARED ${geometry_SRCS}) 10 | TARGET_LINK_LIBRARIES(flirtlib_geometry ${Boost_SERIALIZATION_LIBRARY}) 11 | 12 | install(TARGETS flirtlib_geometry 13 | RUNTIME DESTINATION bin 14 | LIBRARY DESTINATION lib 15 | ARCHIVE DESTINATION lib) 16 | 17 | install(FILES ${geometry_HDRS} DESTINATION include/flirtlib/geometry) 18 | 19 | -------------------------------------------------------------------------------- /src/geometry/point.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "point.h" 23 | 24 | Point2D::Point2D(): 25 | x(0.0), 26 | y(0.0) 27 | { 28 | 29 | } 30 | 31 | Point2D::Point2D(double _x, double _y): 32 | x(_x), 33 | y(_y) 34 | { 35 | 36 | } 37 | 38 | OrientedPoint2D::OrientedPoint2D(): 39 | Point2D(0.0,0.0), 40 | theta(0.0) 41 | { 42 | 43 | } 44 | 45 | OrientedPoint2D::OrientedPoint2D(double _x, double _y, double _theta): 46 | Point2D(_x,_y), 47 | theta(normAngle(_theta)) 48 | { 49 | 50 | } 51 | 52 | OrientedPoint2D OrientedPoint2D::ominus() const 53 | { 54 | double ctheta = cos(theta), stheta = sin(theta); 55 | return OrientedPoint2D(-x * ctheta - y * stheta, 56 | x * stheta - y * ctheta, 57 | normAngle(-theta)); 58 | } 59 | 60 | OrientedPoint2D OrientedPoint2D::ominus(const OrientedPoint2D& point) const 61 | { 62 | double ctheta = cos(theta), stheta = sin(theta); 63 | return OrientedPoint2D( (point.x - x) * ctheta + (point.y - y) * stheta, 64 | -(point.x - x) * stheta + (point.y - y) * ctheta, 65 | normAngle(point.theta - theta)); 66 | 67 | } 68 | 69 | Point2D OrientedPoint2D::ominus(const Point2D& point) const 70 | { 71 | double ctheta = cos(theta), stheta = sin(theta); 72 | return Point2D( (point.x - x) * ctheta + (point.y - y) * stheta, 73 | -(point.x - x) * stheta + (point.y - y) * ctheta); 74 | 75 | } 76 | 77 | OrientedPoint2D OrientedPoint2D::oplus(const OrientedPoint2D& point) const 78 | { 79 | double ctheta = cos(theta), stheta = sin(theta); 80 | return OrientedPoint2D(x + point.x * ctheta - point.y * stheta, 81 | y + point.x * stheta + point.y * ctheta, 82 | normAngle(theta + point.theta)); 83 | } 84 | 85 | Point2D OrientedPoint2D::oplus(const Point2D& point) const 86 | { 87 | double ctheta = cos(theta), stheta = sin(theta); 88 | return Point2D(x + point.x * ctheta - point.y * stheta, 89 | y + point.x * stheta + point.y * ctheta); 90 | } 91 | 92 | 93 | double normAngle(double angle, double base) { 94 | double pi2 = 2*M_PI; 95 | double min2pi = base + pi2; 96 | while(angle>=min2pi) angle -= pi2; 97 | while(angle. 19 | */ 20 | 21 | #ifndef ABSTRACTRENDERER_H_ 22 | #define ABSTRACTRENDERER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class AbstractRenderer { 29 | public: 30 | virtual ~AbstractRenderer() { } 31 | virtual void render() = 0; 32 | }; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /src/gui/BetaGridPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef BETGRIDPRESENTER_H_ 22 | #define BETGRIDPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class BetaGridPresenter: public DescriptorPresenter{ 31 | Q_OBJECT 32 | 33 | public: 34 | BetaGridPresenter(BetaGridGenerator* descriptor, ParameterWidget* peakParameter); 35 | 36 | virtual void setDescriptor(DescriptorGenerator* descriptor); 37 | 38 | virtual void setDescriptorParameter(ParameterWidget* peakParameter); 39 | 40 | void insertDistanceFunction(const QString& name, const HistogramDistance* distanceFunction); 41 | 42 | signals: 43 | void descriptorChanged(); 44 | 45 | public slots: 46 | void changeParameter(const QString& name); 47 | void changeMinRho(double value); 48 | void changeMaxRho(double value); 49 | void changeBinRho(int value); 50 | void changeBinPhi(int value); 51 | void changeDistanceFunction(int value); 52 | 53 | protected: 54 | void syncronize(); 55 | void reconnect(); 56 | 57 | const HistogramDistance* m_currentDistanceFunction; 58 | int m_currentDistanceFunctionIndex; 59 | QVector< const HistogramDistance* > m_distanceFunctions; 60 | QStringList m_distanceFunctionNames; 61 | }; 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/gui/BoxParameterWidget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "BoxParameterWidget.h" 23 | 24 | 25 | BoxParameterWidget::BoxParameterWidget(const QString &name, QWidget *parent): 26 | ParameterWidget(name, parent) 27 | { 28 | QGridLayout *layout = m_layout; 29 | m_groupBox = new QGroupBox(name, this); 30 | layout->addWidget(m_groupBox,0,0); 31 | m_layout = new QGridLayout(m_groupBox); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/gui/BoxParameterWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef BOXPARAMETERWIDGET_H_ 22 | #define BOXPARAMETERWIDGET_H_ 23 | 24 | #include 25 | #include 26 | 27 | class BoxParameterWidget: public ParameterWidget { 28 | public: 29 | BoxParameterWidget(const QString &name, QWidget *parent = 0); 30 | 31 | protected: 32 | QGroupBox *m_groupBox; 33 | }; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /src/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(gui_SRCS 2 | Color.cpp 3 | LaserReadingRenderer.cpp 4 | InterestPointRenderer.cpp 5 | PolarGridRenderer.cpp 6 | SensorStreamWidget.cpp 7 | RendererWidget.cpp 8 | MultiScaleDetectorPlotWidget.cpp 9 | SimplePeakFinderPresenter.cpp 10 | MultiScaleDetectorPresenter.cpp 11 | MultiScaleCurvatureDetectorPresenter.cpp 12 | MultiScaleNormalDetectorPresenter.cpp 13 | DetectorChooserPresenter.cpp 14 | DescriptorChooserPresenter.cpp 15 | ParameterWidget.cpp 16 | TabbedParameterWidget.cpp 17 | BoxParameterWidget.cpp 18 | ShapeContextPresenter.cpp 19 | BetaGridPresenter.cpp 20 | DescriptorWidget.cpp 21 | PolarGridGraphicsItem.cpp 22 | CorrespondenceRenderer.cpp 23 | FeatureSetMatcherPresenter.cpp 24 | RansacPresenter.cpp 25 | ) 26 | 27 | SET(gui_HDRS 28 | AbstractRenderer.h 29 | Color.h 30 | LaserReadingRenderer.h 31 | InterestPointRenderer.h 32 | PolarGridRenderer.h 33 | SensorStreamWidget.h 34 | RendererWidget.h 35 | MultiScaleDetectorPlotWidget.h 36 | PeakFinderPresenter.h 37 | SimplePeakFinderPresenter.h 38 | DetectorPresenter.h 39 | MultiScaleDetectorPresenter.h 40 | MultiScaleCurvatureDetectorPresenter.h 41 | MultiScaleNormalDetectorPresenter.h 42 | DetectorChooserPresenter.h 43 | DescriptorChooserPresenter.h 44 | ParameterWidget.h 45 | TabbedParameterWidget.h 46 | BoxParameterWidget.h 47 | DescriptorPresenter.h 48 | ShapeContextPresenter.h 49 | BetaGridPresenter.h 50 | DescriptorWidget.h 51 | PolarGridGraphicsItem.h 52 | CorrespondenceRenderer.h 53 | FeatureSetMatcherPresenter.h 54 | RansacPresenter.h 55 | ) 56 | 57 | SET(gui_LIBS 58 | flirtlib_sensors 59 | flirtlib_sensorstream 60 | flirtlib_feature 61 | flirtlib_geometry 62 | ${QT_LIBRARIES} 63 | ${OPENGL_LIBRARIES} 64 | ${QWT_LIBRARIES} 65 | flirtlib_utils 66 | ) 67 | 68 | QT4_AUTOMOC(${gui_SRCS}) 69 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 70 | 71 | ADD_LIBRARY(flirtlib_gui SHARED ${gui_SRCS}) 72 | TARGET_LINK_LIBRARIES(flirtlib_gui ${gui_LIBS}) 73 | 74 | install(TARGETS flirtlib_gui 75 | RUNTIME DESTINATION bin 76 | LIBRARY DESTINATION lib 77 | ARCHIVE DESTINATION lib) 78 | 79 | install(FILES ${gui_HDRS} DESTINATION include/flirtlib/gui) 80 | -------------------------------------------------------------------------------- /src/gui/Color.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "Color.h" 23 | 24 | Color::Color(float r, float g, float b, float a):m_red(r),m_green(g),m_blue(b),m_alpha(a) { } 25 | 26 | HSLColor::HSLColor(float h, float s, float l, float a):m_hue(h),m_saturation(s),m_lightness(l),m_alpha(a) { } 27 | 28 | Color HSLColor::toColor() const{ 29 | return HSL2RGB(*this); 30 | } 31 | 32 | void HSLColor::fromColor(const Color& color){ 33 | *this = RGB2HSL(color); 34 | } 35 | 36 | HSLColor RGB2HSL(const Color& color){ 37 | float min, max, hue, saturation, lightness, alpha; 38 | 39 | min = (color.red() < color.green()) ? color.red() : color.green(); 40 | min = (min < color.blue()) ? min : color.blue(); 41 | 42 | max = (color.red() > color.green()) ? color.red() : color.green(); 43 | max = (max > color.blue()) ? max : color.blue(); 44 | 45 | lightness = 0.5*(min + max); 46 | 47 | if(max == min){ 48 | hue = 0.f; 49 | saturation = 0.f; 50 | } else { 51 | saturation = lightness < 0.5 ? (max - min)/(max + min) : (max - min)/(2.f - max - min); 52 | 53 | if(max == color.red()) { 54 | hue = (color.green() - color.blue())/(max - min); 55 | } else if(max == color.green()){ 56 | hue = 2.f + (color.blue() - color.red())/(max - min); 57 | } else { 58 | hue = 4.f + (color.red() - color.green())/(max - min); 59 | } 60 | hue = hue < 0 ? hue + 6.f : hue; 61 | } 62 | 63 | alpha = color.alpha(); 64 | return HSLColor(hue, saturation, lightness, alpha); 65 | } 66 | 67 | Color HSL2RGB(const HSLColor& color) { 68 | float q, p, h, tc[3], col[3]; 69 | q = color.lightness() < 0.5 ? color.lightness() * (1.f + color.saturation()) : color.lightness() + color.saturation() - color.lightness() * color.saturation(); 70 | p = 2 * color.lightness() - q; 71 | h = color.hue() / 6.f; 72 | 73 | tc[0] = h + 1.f/3.f; 74 | tc[1] = h; 75 | tc[2] = h - 1.f/3.f; 76 | 77 | for(unsigned int i = 0; i < 3; i++){ 78 | tc[i] = tc[i] < 0 ? tc[i] + 1.f: tc[i]; 79 | tc[i] = tc[i] > 1 ? tc[i] - 1.f: tc[i]; 80 | if(6.f * tc[i] < 1.f){ 81 | col[i] = p + ((q - p) * 6.f * tc[i]); 82 | } else if(2.f * tc[i] < 1.f){ 83 | col[i] = q; 84 | } else if(3.f * tc[i] < 2.f){ 85 | col[i] = p + ((q - p) * 6.f * (2.f/3.f - tc[i])); 86 | } else { 87 | col[i] = p; 88 | } 89 | } 90 | 91 | return Color(col[0], col[1], col[2], color.alpha()); 92 | } 93 | 94 | std::ostream & operator<< (std::ostream& out, const Color& color){ 95 | out << "RGB(" << color.red() << ", " << color.green() << ", " << color.blue() << ")"; 96 | return out; 97 | } 98 | 99 | std::ostream & operator<< (std::ostream& out, const HSLColor& color){ 100 | out << "HSL(" << color.hue() << ", " << color.saturation() << ", " << color.lightness() << ")"; 101 | return out; 102 | } 103 | -------------------------------------------------------------------------------- /src/gui/Color.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef COLOR_H_ 22 | #define COLOR_H_ 23 | 24 | #include 25 | 26 | class Color{ 27 | public: 28 | Color(float r, float g, float b, float a = 1.f); 29 | 30 | inline float& red() {return m_red;} 31 | inline float& green() {return m_green;} 32 | inline float& blue() {return m_blue;} 33 | inline float& alpha() {return m_alpha;} 34 | 35 | inline float red() const{return m_red;} 36 | inline float green() const{return m_green;} 37 | inline float blue() const{return m_blue;} 38 | inline float alpha() const{return m_alpha;} 39 | protected: 40 | float m_red, m_green, m_blue, m_alpha; 41 | }; 42 | 43 | class HSLColor{ 44 | public: 45 | HSLColor(float h, float s, float l, float a = 1.f); 46 | 47 | inline float& hue() {return m_hue;} 48 | inline float& saturation() {return m_saturation;} 49 | inline float& lightness() {return m_lightness;} 50 | inline float& alpha() {return m_alpha;} 51 | 52 | inline float hue() const {return m_hue;} 53 | inline float saturation() const {return m_saturation;} 54 | inline float lightness() const {return m_lightness;} 55 | inline float alpha() const {return m_alpha;} 56 | 57 | void fromColor(const Color& color); 58 | Color toColor() const; 59 | 60 | protected: 61 | float m_hue, m_saturation, m_lightness, m_alpha; 62 | }; 63 | 64 | HSLColor RGB2HSL(const Color& color); 65 | 66 | Color HSL2RGB(const HSLColor& color); 67 | 68 | std::ostream& operator<< (std::ostream& out, const Color& color); 69 | std::ostream& operator<< (std::ostream& out, const HSLColor& color); 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/gui/CorrespondenceRenderer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "CorrespondenceRenderer.h" 23 | 24 | CorrespondenceRenderer::CorrespondenceRenderer(const std::vector< std::pair > *correspondences, const std::vector< double > *distances): 25 | m_correspondences(correspondences), 26 | m_distances(NULL), 27 | m_referenceDepth(0), 28 | m_dataDepth(0), 29 | m_maxDistance(0) 30 | { 31 | if(m_correspondences){ 32 | m_colors.resize(m_correspondences->size(),Color(1.f,0.f,0.f,1.f)); 33 | if(distances && m_correspondences->size() == distances->size()){ 34 | m_distances = distances; 35 | for(unsigned int i = 0; i < m_distances->size(); i++){ 36 | m_maxDistance = m_maxDistance > (*m_distances)[i] ? m_maxDistance : (*m_distances)[i]; 37 | } 38 | } 39 | } 40 | } 41 | 42 | void CorrespondenceRenderer::setCorrespondences(const std::vector< std::pair > *correspondences, const std::vector< double > *distances) 43 | { 44 | m_correspondences = correspondences; 45 | m_distances = distances; 46 | if(m_correspondences){ 47 | m_colors.resize(m_correspondences->size(),Color(1.f,0.f,0.f,1.f)); 48 | if(distances && m_correspondences->size() == distances->size()){ 49 | m_distances = distances; 50 | for(unsigned int i = 0; i < m_distances->size(); i++){ 51 | m_maxDistance = m_maxDistance > (*m_distances)[i] ? m_maxDistance : (*m_distances)[i]; 52 | } 53 | } 54 | } 55 | } 56 | 57 | void CorrespondenceRenderer::render() 58 | { 59 | if(!m_correspondences) return; 60 | glPushMatrix(); 61 | float width; 62 | glGetFloatv(GL_LINE_WIDTH, &width); 63 | glLineWidth(5.0); 64 | glBegin(GL_LINES); 65 | for(unsigned int i = 0; i < m_correspondences->size(); i++){ 66 | float alpha = m_distances ? 1.f - (*m_distances)[i]/m_maxDistance : 1.f; 67 | // glColor4f(m_colors[i].red(), m_colors[i].green(), m_colors[i].blue(), alpha); 68 | glColor4f(alpha, alpha, alpha, 1.f); 69 | glVertex3f((*m_correspondences)[i].first.x, (*m_correspondences)[i].first.y, m_referenceDepth); 70 | glVertex3f((*m_correspondences)[i].second.x, (*m_correspondences)[i].second.y, m_dataDepth); 71 | } 72 | glEnd(); 73 | glLineWidth(width); 74 | glPopMatrix(); 75 | } -------------------------------------------------------------------------------- /src/gui/CorrespondenceRenderer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef CORRESPONDENCERENDERER_H_ 22 | #define CORRESPONDENCERENDERER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class CorrespondenceRenderer: public AbstractRenderer { 34 | public: 35 | CorrespondenceRenderer(const std::vector< std::pair > *correspondences, const std::vector< double > *m_distances = 0); 36 | 37 | virtual ~CorrespondenceRenderer() { } 38 | 39 | /* CorrespondenceRenderer(const CorrespondenceRenderer& _renderer); 40 | 41 | CorrespondenceRenderer& operator=(const CorrespondenceRenderer& _renderer); 42 | 43 | virtual ~CorrespondenceRenderer(); 44 | */ 45 | inline void setReferenceDepth(float depth) 46 | {m_referenceDepth = depth;} 47 | 48 | inline void setDataDepth(float depth) 49 | {m_dataDepth = depth;} 50 | 51 | inline void setColors(const std::vector& _colors) 52 | {m_colors = _colors;} 53 | inline void setColor(unsigned int _index, float _red, float _green, float _blue, float _alpha = 1.0f) 54 | {if(_index < m_colors.size()) m_colors[_index] = Color(_red, _green, _blue, _alpha);} 55 | 56 | void setCorrespondences(const std::vector< std::pair > *correspondences, const std::vector< double > *m_distances = 0); 57 | 58 | inline const std::vector< std::pair > * getCorrespondences() const 59 | {return m_correspondences;} 60 | 61 | inline const std::vector< double > * getDistances() const 62 | {return m_distances;} 63 | 64 | virtual void render(); 65 | 66 | protected: 67 | const std::vector< std::pair > *m_correspondences; 68 | const std::vector< double > *m_distances; 69 | std::vector m_colors; 70 | float m_referenceDepth; 71 | float m_dataDepth; 72 | double m_maxDistance; 73 | }; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/gui/DescriptorChooserPresenter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "DescriptorChooserPresenter.h" 23 | #include "DescriptorChooserPresenter.moc" 24 | /* 25 | DescriptorChooserWidget::DescriptorChooserWidget(QWidget* parent): 26 | QWidget(parent), 27 | m_descriptor(this), 28 | m_descriptorLabel("Type of descriptor",this), 29 | m_layout(this) 30 | { 31 | buildGui(); 32 | } 33 | 34 | void DescriptorChooserWidget::changeDescriptor(int descriptor){ 35 | m_descriptor.setCurrentIndex(descriptor); 36 | } 37 | 38 | void DescriptorChooserWidget::buildGui(){ 39 | m_layout.setSpacing(3); 40 | m_layout.setMargin(3); 41 | m_layout.addWidget(&m_descriptorLabel,m_layout.rowCount(),0); 42 | m_layout.addWidget(&m_descriptor,m_layout.rowCount() - 1,1); 43 | 44 | m_descriptor.setInsertPolicy(QComboBox::NoInsert); 45 | m_descriptor.setEditable(false); 46 | 47 | connect(&m_descriptor, SIGNAL(activated(int)), this, SIGNAL(descriptorChanged(int))); 48 | } 49 | 50 | void DescriptorChooserWidget::resetDescriptor(){ 51 | while(m_descriptor.count()) m_descriptor.removeItem(0); 52 | } 53 | */ 54 | 55 | DescriptorChooserPresenter::DescriptorChooserPresenter(ParameterWidget* chooser): 56 | m_chooser(chooser), 57 | m_currentDescriptorPresenter(NULL) 58 | { 59 | m_chooser->addEnumParameter("descriptor", "Type of descriptor"); 60 | syncronize(); 61 | reconnect(); 62 | } 63 | 64 | 65 | void DescriptorChooserPresenter::insertDescriptor(const QString& name, DescriptorPresenter* descriptor){ 66 | m_descriptorPresenterNames.push_back(name); 67 | m_descriptorPresenters.push_back(descriptor); 68 | m_chooser->insertEnumValue("descriptor", name); 69 | if(m_descriptorPresenters.size() == 1){ 70 | m_currentDescriptorPresenter = descriptor; 71 | m_currentDescriptorPresenterIndex = 0; 72 | connect(m_currentDescriptorPresenter, SIGNAL(descriptorChanged()), this, SIGNAL(descriptorChanged())); 73 | m_currentDescriptorPresenter->activate(); 74 | } else{ 75 | descriptor->deactivate(); 76 | m_currentDescriptorPresenter->activate(); 77 | } 78 | } 79 | 80 | void DescriptorChooserPresenter::setChooser(ParameterWidget* chooser){ 81 | disconnect(m_chooser, 0, this, 0); 82 | m_chooser = chooser; 83 | m_chooser->clearParameterMap(); 84 | m_chooser->addEnumParameter("descriptor", "Type of descriptor"); 85 | syncronize(); 86 | reconnect(); 87 | } 88 | 89 | void DescriptorChooserPresenter::changeParameter(const QString& name){ 90 | if(!QString::compare(name, "descriptor")){ 91 | int guiValue; 92 | bool valid = m_chooser->getEnumValue("descriptor", guiValue); 93 | if(valid) {changeDescriptor(guiValue);} 94 | } 95 | } 96 | 97 | void DescriptorChooserPresenter::changeDescriptor(int descriptor){ 98 | if(m_currentDescriptorPresenterIndex != descriptor){ 99 | disconnect(m_currentDescriptorPresenter, SIGNAL(descriptorChanged()), this, SIGNAL(descriptorChanged())); 100 | m_currentDescriptorPresenter->deactivate(); 101 | m_currentDescriptorPresenterIndex = descriptor; 102 | m_currentDescriptorPresenter = m_descriptorPresenters[m_currentDescriptorPresenterIndex]; 103 | m_chooser->setEnumValue("descriptor", m_currentDescriptorPresenterIndex); 104 | m_currentDescriptorPresenter->activate(); 105 | connect(m_currentDescriptorPresenter, SIGNAL(descriptorChanged()), this, SIGNAL(descriptorChanged())); 106 | emit descriptorChanged(); 107 | } 108 | } 109 | 110 | 111 | void DescriptorChooserPresenter::syncronize(){ 112 | if(m_descriptorPresenters.size()){ 113 | m_chooser->clearEnumParameter("descriptor"); 114 | for(int i = 0; i < m_descriptorPresenterNames.size(); i++){ 115 | m_chooser->insertEnumValue("descriptor", m_descriptorPresenterNames[i]); 116 | } 117 | m_chooser->setEnumValue("descriptor", m_currentDescriptorPresenterIndex); 118 | m_currentDescriptorPresenter->activate(); 119 | } 120 | } 121 | 122 | void DescriptorChooserPresenter::reconnect(){ 123 | connect(m_chooser, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 124 | } 125 | -------------------------------------------------------------------------------- /src/gui/DescriptorChooserPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DESCRIPTORCHOOSERPRESENTER_H_ 22 | #define DESCRIPTORCHOOSERPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | // class DescriptorChooserWidget: public QWidget{ 34 | // Q_OBJECT 35 | // 36 | // public: 37 | // DescriptorChooserWidget(QWidget * parent = 0); 38 | // 39 | // inline int getDescriptor() const 40 | // {return m_descriptor.currentIndex();} 41 | // inline void insertDescriptor(const QString& name) 42 | // {m_descriptor.addItem(name);} 43 | // 44 | // void resetDescriptor(); 45 | // 46 | // signals: 47 | // void descriptorChanged(int descriptor); 48 | // 49 | // public slots: 50 | // void changeDescriptor(int descriptor); 51 | // 52 | // protected: 53 | // void buildGui(); 54 | // 55 | // QComboBox m_descriptor; 56 | // QLabel m_descriptorLabel; 57 | // QGridLayout m_layout; 58 | // 59 | // }; 60 | 61 | class DescriptorChooserPresenter: public QObject{ 62 | Q_OBJECT 63 | 64 | public: 65 | DescriptorChooserPresenter(ParameterWidget* chooser); 66 | 67 | void insertDescriptor(const QString& name, DescriptorPresenter* descriptor); 68 | 69 | void setChooser(ParameterWidget* chooser); 70 | 71 | inline const ParameterWidget* getChooserParameter() const 72 | {return m_chooser;} 73 | 74 | inline const DescriptorPresenter* getCurrentDescriptorPresenter() const 75 | {return m_currentDescriptorPresenter;} 76 | 77 | inline const DescriptorGenerator* getCurrentDescriptor() const 78 | {return m_currentDescriptorPresenter->getDescriptor();} 79 | 80 | inline ParameterWidget* getChooserParameter() 81 | {return m_chooser;} 82 | 83 | inline DescriptorPresenter* getCurrentDescriptorPresenter() 84 | {return m_currentDescriptorPresenter;} 85 | 86 | inline DescriptorGenerator* getCurrentDescriptor() 87 | {return m_currentDescriptorPresenter->getDescriptor();} 88 | 89 | signals: 90 | void descriptorChanged(); 91 | 92 | public slots: 93 | void changeDescriptor(int descriptor); 94 | void changeParameter(const QString& name); 95 | 96 | protected: 97 | void syncronize(); 98 | void reconnect(); 99 | ParameterWidget* m_chooser; 100 | DescriptorPresenter* m_currentDescriptorPresenter; 101 | int m_currentDescriptorPresenterIndex; 102 | QVector< DescriptorPresenter* > m_descriptorPresenters; 103 | QStringList m_descriptorPresenterNames; 104 | }; 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /src/gui/DescriptorPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DESCRIPTORPRESENTER_H_ 22 | #define DESCRIPTORPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class DescriptorPresenter: public QObject{ 30 | public: 31 | DescriptorPresenter(DescriptorGenerator* descriptor, ParameterWidget* peakParameter): 32 | m_descriptor(descriptor), 33 | m_descriptorParameter(peakParameter) 34 | { } 35 | 36 | inline void activate() 37 | {if(m_descriptorParameter) m_descriptorParameter->activate();} 38 | inline void deactivate() 39 | {if(m_descriptorParameter) m_descriptorParameter->deactivate();} 40 | 41 | virtual void setDescriptor(DescriptorGenerator* descriptor) = 0; 42 | 43 | virtual void setDescriptorParameter(ParameterWidget* peakParameter) = 0; 44 | 45 | inline const DescriptorGenerator* getDescriptor() const 46 | {return m_descriptor;} 47 | 48 | inline const ParameterWidget* getDescriptorParameter() const 49 | {return m_descriptorParameter;} 50 | 51 | inline DescriptorGenerator* getDescriptor() 52 | {return m_descriptor;} 53 | 54 | inline ParameterWidget* getDescriptorParameter() 55 | {return m_descriptorParameter;} 56 | 57 | protected: 58 | DescriptorGenerator* m_descriptor; 59 | ParameterWidget* m_descriptorParameter; 60 | }; 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/gui/DescriptorWidget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "DescriptorWidget.h" 23 | #include "DescriptorWidget.moc" 24 | 25 | #include 26 | 27 | DescriptorWidget::DescriptorWidget(QWidget *parent): 28 | QGraphicsView(parent), 29 | m_items(0) 30 | { 31 | m_scene = new QGraphicsScene(this); 32 | setScene(m_scene); 33 | setCacheMode(CacheBackground); 34 | setViewportUpdateMode(BoundingRectViewportUpdate); 35 | setRenderHint(QPainter::Antialiasing); 36 | } 37 | 38 | void DescriptorWidget::addDescriptor(QGraphicsItem * item){ 39 | if(!item) return; 40 | QRectF bounding = item->boundingRect(); 41 | float adjust = 10.; 42 | float width = adjust + bounding.width(); 43 | float height = adjust + bounding.height(); 44 | item->setPos(m_position.x(), m_position.y()); 45 | m_items.push_back(item); 46 | m_scene->addItem(item); 47 | m_position.rx() += width + adjust; 48 | update(); 49 | } 50 | 51 | void DescriptorWidget::addSeparator() { 52 | if(!m_items.size()) return; 53 | QRectF bounding = m_items.front()->boundingRect(); 54 | float adjust = 10.; 55 | float height = adjust + bounding.height(); 56 | QLineF line(m_position.x(), m_position.y(), m_position.x(), m_position.y() + height); 57 | QPen pen; 58 | pen.setWidth(3); 59 | m_scene->addLine(line, pen); 60 | m_position.rx() += adjust + pen.widthF(); 61 | } 62 | 63 | void DescriptorWidget::addNewLine() { 64 | QRectF bounding = m_items.front()->boundingRect(); 65 | float adjust = 10.; 66 | float width = adjust + bounding.width(); 67 | float height = adjust + bounding.height(); 68 | m_position.rx() = m_items.front()->x(); 69 | m_position.ry() += height; 70 | } 71 | 72 | void DescriptorWidget::clear(){ 73 | if(m_scene) delete m_scene; 74 | m_scene = new QGraphicsScene(this); 75 | setScene(m_scene); 76 | setCacheMode(CacheBackground); 77 | setViewportUpdateMode(BoundingRectViewportUpdate); 78 | setRenderHint(QPainter::Antialiasing); 79 | /* foreach(QGraphicsItem * item, m_items){ 80 | m_scene->removeItem(item); 81 | delete item; 82 | }*/ 83 | m_items.clear(); 84 | // scene->set 85 | } 86 | 87 | void DescriptorWidget::mousePressEvent(QMouseEvent *event){ 88 | const QGraphicsItem * selected = itemAt(event->pos()); 89 | int index = findDescriptor(selected); 90 | if(index > -1) emit descriptorSelected(index); 91 | } 92 | 93 | int DescriptorWidget::findDescriptor(const QGraphicsItem * item){ 94 | int index = -1; 95 | for(int i = 0; i < m_items.size(); i++){ 96 | if(m_items[i] == item){ 97 | index = i; 98 | break; 99 | } 100 | } 101 | return index; 102 | } 103 | -------------------------------------------------------------------------------- /src/gui/DescriptorWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DESCRIPTORWIDGET_H_ 22 | #define DESCRIPTORWIDGET_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | class DescriptorWidget: public QGraphicsView { 32 | Q_OBJECT 33 | 34 | public: 35 | DescriptorWidget(QWidget *parent = 0); 36 | 37 | void addDescriptor(QGraphicsItem * item); 38 | 39 | void addSeparator(); 40 | 41 | void addNewLine(); 42 | 43 | void clear(); 44 | 45 | signals: 46 | void descriptorSelected(int index); 47 | 48 | protected: 49 | virtual void mousePressEvent(QMouseEvent *event); 50 | 51 | int findDescriptor(const QGraphicsItem * item); 52 | 53 | QGraphicsScene * m_scene; 54 | QVector m_items; 55 | QPointF m_position; 56 | 57 | 58 | }; 59 | 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/gui/DetectorChooserPresenter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "DetectorChooserPresenter.h" 23 | #include "DetectorChooserPresenter.moc" 24 | /* 25 | DetectorChooserWidget::DetectorChooserWidget(QWidget* parent): 26 | QWidget(parent), 27 | m_detector(this), 28 | m_detectorLabel("Type of detector",this), 29 | m_layout(this) 30 | { 31 | buildGui(); 32 | } 33 | 34 | void DetectorChooserWidget::changeDetector(int detector){ 35 | m_detector.setCurrentIndex(detector); 36 | } 37 | 38 | void DetectorChooserWidget::buildGui(){ 39 | m_layout.setSpacing(3); 40 | m_layout.setMargin(3); 41 | m_layout.addWidget(&m_detectorLabel,m_layout.rowCount(),0); 42 | m_layout.addWidget(&m_detector,m_layout.rowCount() - 1,1); 43 | 44 | m_detector.setInsertPolicy(QComboBox::NoInsert); 45 | m_detector.setEditable(false); 46 | 47 | connect(&m_detector, SIGNAL(activated(int)), this, SIGNAL(detectorChanged(int))); 48 | } 49 | 50 | void DetectorChooserWidget::resetDetector(){ 51 | while(m_detector.count()) m_detector.removeItem(0); 52 | } 53 | */ 54 | 55 | DetectorChooserPresenter::DetectorChooserPresenter(ParameterWidget* chooser): 56 | m_chooser(chooser), 57 | m_currentDetectorPresenter(NULL) 58 | { 59 | m_chooser->addEnumParameter("detector", "Type of detector"); 60 | syncronize(); 61 | reconnect(); 62 | } 63 | 64 | 65 | void DetectorChooserPresenter::insertDetector(const QString& name, DetectorPresenter* detector){ 66 | m_detectorPresenterNames.push_back(name); 67 | m_detectorPresenters.push_back(detector); 68 | m_chooser->insertEnumValue("detector", name); 69 | if(m_detectorPresenters.size() == 1){ 70 | m_currentDetectorPresenter = detector; 71 | m_currentDetectorPresenterIndex = 0; 72 | connect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged())); 73 | m_currentDetectorPresenter->activate(); 74 | } else{ 75 | detector->deactivate(); 76 | m_currentDetectorPresenter->activate(); 77 | } 78 | } 79 | 80 | void DetectorChooserPresenter::setChooser(ParameterWidget* chooser){ 81 | disconnect(m_chooser, 0, this, 0); 82 | m_chooser = chooser; 83 | m_chooser->clearParameterMap(); 84 | m_chooser->addEnumParameter("detector", "Type of detector"); 85 | syncronize(); 86 | reconnect(); 87 | } 88 | 89 | void DetectorChooserPresenter::changeParameter(const QString& name){ 90 | if(!QString::compare(name, "detector")){ 91 | int guiValue; 92 | bool valid = m_chooser->getEnumValue("detector", guiValue); 93 | if(valid) {changeDetector(guiValue);} 94 | } 95 | } 96 | 97 | void DetectorChooserPresenter::changeDetector(int detector){ 98 | if(m_currentDetectorPresenterIndex != detector){ 99 | disconnect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged())); 100 | m_currentDetectorPresenter->deactivate(); 101 | m_currentDetectorPresenterIndex = detector; 102 | m_currentDetectorPresenter = m_detectorPresenters[m_currentDetectorPresenterIndex]; 103 | m_chooser->setEnumValue("detector", m_currentDetectorPresenterIndex); 104 | m_currentDetectorPresenter->activate(); 105 | connect(m_currentDetectorPresenter, SIGNAL(detectorChanged()), this, SIGNAL(detectorChanged())); 106 | emit detectorChanged(); 107 | } 108 | } 109 | 110 | 111 | void DetectorChooserPresenter::syncronize(){ 112 | if(m_detectorPresenters.size()){ 113 | m_chooser->clearEnumParameter("detector"); 114 | for(int i = 0; i < m_detectorPresenterNames.size(); i++){ 115 | m_chooser->insertEnumValue("detector", m_detectorPresenterNames[i]); 116 | } 117 | m_chooser->setEnumValue("detector", m_currentDetectorPresenterIndex); 118 | m_currentDetectorPresenter->activate(); 119 | } 120 | } 121 | 122 | void DetectorChooserPresenter::reconnect(){ 123 | connect(m_chooser, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 124 | } 125 | -------------------------------------------------------------------------------- /src/gui/DetectorChooserPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DETECTORCHOOSERPRESENTER_H_ 22 | #define DETECTORCHOOSERPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | // class DetectorChooserWidget: public QWidget{ 34 | // Q_OBJECT 35 | // 36 | // public: 37 | // DetectorChooserWidget(QWidget * parent = 0); 38 | // 39 | // inline int getDetector() const 40 | // {return m_detector.currentIndex();} 41 | // inline void insertDetector(const QString& name) 42 | // {m_detector.addItem(name);} 43 | // 44 | // void resetDetector(); 45 | // 46 | // signals: 47 | // void detectorChanged(int detector); 48 | // 49 | // public slots: 50 | // void changeDetector(int detector); 51 | // 52 | // protected: 53 | // void buildGui(); 54 | // 55 | // QComboBox m_detector; 56 | // QLabel m_detectorLabel; 57 | // QGridLayout m_layout; 58 | // 59 | // }; 60 | 61 | class DetectorChooserPresenter: public QObject{ 62 | Q_OBJECT 63 | 64 | public: 65 | DetectorChooserPresenter(ParameterWidget* chooser); 66 | 67 | void insertDetector(const QString& name, DetectorPresenter* detector); 68 | 69 | void setChooser(ParameterWidget* chooser); 70 | 71 | inline const ParameterWidget* getChooserParameter() const 72 | {return m_chooser;} 73 | 74 | inline const DetectorPresenter* getCurrentDetectorPresenter() const 75 | {return m_currentDetectorPresenter;} 76 | 77 | inline const Detector* getCurrentDetector() const 78 | {return m_currentDetectorPresenter->getDetector();} 79 | 80 | inline ParameterWidget* getChooserParameter() 81 | {return m_chooser;} 82 | 83 | inline DetectorPresenter* getCurrentDetectorPresenter() 84 | {return m_currentDetectorPresenter;} 85 | 86 | inline Detector* getCurrentDetector() 87 | {return m_currentDetectorPresenter->getDetector();} 88 | 89 | signals: 90 | void detectorChanged(); 91 | 92 | public slots: 93 | void changeDetector(int detector); 94 | void changeParameter(const QString& name); 95 | 96 | protected: 97 | void syncronize(); 98 | void reconnect(); 99 | ParameterWidget* m_chooser; 100 | DetectorPresenter* m_currentDetectorPresenter; 101 | int m_currentDetectorPresenterIndex; 102 | QVector< DetectorPresenter* > m_detectorPresenters; 103 | QStringList m_detectorPresenterNames; 104 | }; 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /src/gui/DetectorPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef DETECTORPRESENTER_H_ 22 | #define DETECTORPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class DetectorPresenter: public QObject{ 32 | public: 33 | DetectorPresenter(Detector* detector, ParameterWidget* detectorParameter): 34 | m_detector(detector), 35 | m_detectorParameter(detectorParameter) 36 | { } 37 | 38 | virtual inline void activate() 39 | {if(m_detectorParameter){m_detectorParameter->activate();}} 40 | virtual inline void deactivate() 41 | {if(m_detectorParameter) m_detectorParameter->deactivate();} 42 | 43 | virtual void setDetector(Detector* detector) = 0; 44 | 45 | virtual void setDetectorParameter(ParameterWidget* detectorParameter) = 0; 46 | 47 | inline const Detector* getDetector() const 48 | {return m_detector;} 49 | 50 | inline const ParameterWidget* getDetectorParameter() const 51 | {return m_detectorParameter;} 52 | 53 | inline Detector* getDetector() 54 | {return m_detector;} 55 | 56 | inline ParameterWidget* getDetectorParameter() 57 | {return m_detectorParameter;} 58 | 59 | 60 | protected: 61 | virtual void syncronize() = 0; 62 | virtual void reconnect() = 0; 63 | 64 | Detector* m_detector; 65 | ParameterWidget* m_detectorParameter; 66 | }; 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /src/gui/FeatureSetMatcherPresenter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "FeatureSetMatcherPresenter.h" 23 | #include "FeatureSetMatcherPresenter.moc" 24 | 25 | #include 26 | 27 | FeatureSetMatcherPresenter::FeatureSetMatcherPresenter(AbstractFeatureSetMatcher* featureSetMatcher, ParameterWidget* featureSetMatcherParameter): 28 | m_featureSetMatcher(featureSetMatcher), 29 | m_featureSetMatcherParameter(featureSetMatcherParameter) 30 | { 31 | m_featureSetMatcherParameter->addDoubleParameter("acceptanceThreshold", "Threshold on the inlier distance", 0.01, 0., 1e17, 3, 0.005); 32 | syncronize(); 33 | reconnect(); 34 | } 35 | 36 | void FeatureSetMatcherPresenter::setFeatureSetMatcher(AbstractFeatureSetMatcher* featureSetMatcher){ 37 | m_featureSetMatcher = featureSetMatcher; 38 | syncronize(); 39 | } 40 | 41 | void FeatureSetMatcherPresenter::setFeatureSetMatcherParameter(ParameterWidget* featureSetMatcherParameter){ 42 | disconnect(m_featureSetMatcherParameter, 0, this, 0); 43 | m_featureSetMatcherParameter = featureSetMatcherParameter; 44 | m_featureSetMatcherParameter->clearParameterMap(); 45 | m_featureSetMatcherParameter->addDoubleParameter("acceptanceThreshold", "Threshold on the inlier distance", 0.01, 0., 1e17, 3, 0.005); 46 | syncronize(); 47 | reconnect(); 48 | } 49 | 50 | void FeatureSetMatcherPresenter::changeParameter(const QString& name){ 51 | if(!QString::compare(name, "acceptanceThreshold")){ 52 | double guiValue; 53 | bool valid = m_featureSetMatcherParameter->getDoubleValue("acceptanceThreshold", guiValue); 54 | if(valid) {changeAcceptanceThreshold(guiValue);} 55 | } 56 | } 57 | 58 | 59 | void FeatureSetMatcherPresenter::changeAcceptanceThreshold(double value){ 60 | AbstractFeatureSetMatcher *featureSetMatcher = (AbstractFeatureSetMatcher *) m_featureSetMatcher; 61 | double guiValue; 62 | m_featureSetMatcherParameter->getDoubleValue(QString("acceptanceThreshold"), guiValue); 63 | // guiValue = guiValue * guiValue * 5.99; 64 | double modifiedValue = value * value * 5.99; 65 | if(featureSetMatcher->getAcceptanceThreshold() != modifiedValue || guiValue != value){ 66 | featureSetMatcher->setAcceptanceThreshold(modifiedValue); 67 | m_featureSetMatcherParameter->setDoubleValue("acceptanceThreshold", value); 68 | emit featureSetMatcherChanged(); 69 | } 70 | } 71 | 72 | void FeatureSetMatcherPresenter::syncronize(){ 73 | AbstractFeatureSetMatcher *featureSetMatcher = (AbstractFeatureSetMatcher *) m_featureSetMatcher; 74 | double realValue = sqrt(featureSetMatcher->getAcceptanceThreshold() / 5.99); 75 | m_featureSetMatcherParameter->setDoubleValue("acceptanceThreshold", realValue); 76 | } 77 | 78 | void FeatureSetMatcherPresenter::reconnect(){ 79 | connect(m_featureSetMatcherParameter, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 80 | } 81 | -------------------------------------------------------------------------------- /src/gui/FeatureSetMatcherPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef FEATURESETMATCHERPRESENTER_H_ 22 | #define FEATURESETMATCHERPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class FeatureSetMatcherPresenter: public QObject{ 30 | Q_OBJECT 31 | 32 | public: 33 | FeatureSetMatcherPresenter(AbstractFeatureSetMatcher* featureSetMatcher, ParameterWidget* featureSetMatcherParameter); 34 | 35 | inline virtual void activate() 36 | {if(m_featureSetMatcherParameter) m_featureSetMatcherParameter->activate();} 37 | inline virtual void deactivate() 38 | {if(m_featureSetMatcherParameter) m_featureSetMatcherParameter->deactivate();} 39 | 40 | virtual void setFeatureSetMatcher(AbstractFeatureSetMatcher* featureSetMatcher) = 0; 41 | 42 | virtual void setFeatureSetMatcherParameter(ParameterWidget* peakParameter) = 0; 43 | 44 | 45 | inline const AbstractFeatureSetMatcher* getFeatureSetMatcher() const 46 | {return m_featureSetMatcher;} 47 | inline const ParameterWidget* getFeatureSetMatcherParameter() const 48 | {return m_featureSetMatcherParameter;} 49 | 50 | inline AbstractFeatureSetMatcher* getFeatureSetMatcher() 51 | {return m_featureSetMatcher;} 52 | inline ParameterWidget* getFeatureSetMatcherParameter() 53 | {return m_featureSetMatcherParameter;} 54 | 55 | signals: 56 | void featureSetMatcherChanged(); 57 | 58 | public slots: 59 | void changeParameter(const QString& name); 60 | void changeAcceptanceThreshold(double value); 61 | 62 | protected: 63 | virtual void syncronize(); 64 | virtual void reconnect(); 65 | 66 | AbstractFeatureSetMatcher* m_featureSetMatcher; 67 | ParameterWidget* m_featureSetMatcherParameter; 68 | }; 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/gui/InterestPointRenderer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef INTERESTPOINTRENDERER_H_ 22 | #define INTERESTPOINTRENDERER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | class InterestPointRenderer: public AbstractRenderer { 34 | public: 35 | InterestPointRenderer(const std::vector *_points, 36 | const std::vector * _scales); 37 | 38 | InterestPointRenderer(const InterestPointRenderer& _renderer); 39 | 40 | InterestPointRenderer& operator=(const InterestPointRenderer& _renderer); 41 | 42 | virtual ~InterestPointRenderer(); 43 | 44 | inline void setDepth(float depth) 45 | {m_depth = depth;} 46 | 47 | inline void setColors(const std::vector& _colors) 48 | {m_colors = _colors;} 49 | inline void setColor(unsigned int _index, float _red, float _green, float _blue, float _alpha = 1.0f) 50 | {if(_index < m_colors.size()) m_colors[_index] = Color(_red, _green, _blue, _alpha);} 51 | inline void setScaleFactor(float _size) 52 | {m_scaleFactor = _size;} 53 | inline void setSubdivision(int _around, int _along) 54 | {m_subdivision[0] = _around, m_subdivision[1] = _along;} 55 | 56 | inline const std::vector& getColors() const 57 | {return m_colors;} 58 | inline float getScaleFactor() const 59 | {return m_scaleFactor;} 60 | inline void getSubdivision(int& _around, int& _along) const 61 | {_around = m_subdivision[0]; _along = m_subdivision[1];} 62 | 63 | void setInterestPoints(const std::vector *_points, 64 | const std::vector * _scales); 65 | 66 | inline const std::vector * getInterestPoints() const 67 | {return m_interestPoints;} 68 | inline const std::vector * getScales() const 69 | {return m_scales;} 70 | 71 | inline const OrientedPoint2D* getLaserPose() const 72 | {return m_laserPose;} 73 | 74 | inline void setLaserPose(const OrientedPoint2D* pose) 75 | {m_laserPose = pose;} 76 | virtual void render(); 77 | 78 | protected: 79 | const std::vector *m_interestPoints; 80 | const std::vector * m_scales; 81 | const OrientedPoint2D* m_laserPose; 82 | std::vector m_GLUPoints; 83 | std::vector m_colors; 84 | float m_depth; 85 | float m_scaleFactor; 86 | int m_subdivision[2]; 87 | }; 88 | 89 | #endif 90 | 91 | -------------------------------------------------------------------------------- /src/gui/LaserReadingRenderer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef LASERREADINGRENDERER_H_ 22 | #define LASERREADINGRENDERER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class LaserReadingRenderer: public AbstractRenderer { 33 | public: 34 | LaserReadingRenderer(const std::vector *_points, const std::vector& normals = std::vector(0)); 35 | 36 | LaserReadingRenderer(const LaserReadingRenderer& _renderer); 37 | 38 | LaserReadingRenderer& operator=(const LaserReadingRenderer& _renderer); 39 | 40 | inline void setDepth(float depth) 41 | {m_depth = depth;m_listValid=false;} 42 | 43 | virtual ~LaserReadingRenderer(); 44 | 45 | inline void setColor(float _red, float _green, float _blue, float _alpha = 1.0f) 46 | {m_color = Color(_red, _green, _blue, _alpha);m_listValid=false;} 47 | inline void setColor(const Color& _color) 48 | {m_color = _color;m_listValid=false;} 49 | inline void setSize(float _size) 50 | {m_pointSize = _size;m_listValid=false;} 51 | inline void setSubdivision(int _around, int _along) 52 | {m_subdivision[0] = _around, m_subdivision[1] = _along;m_listValid=false;} 53 | 54 | inline void getColor(float& _red, float& _green, float& _blue, float& _alpha) const 55 | {_red = m_color.red(); _green = m_color.green(); _blue = m_color.blue(); _alpha = m_color.alpha(); } 56 | inline const Color& getColor() const 57 | {return m_color; } 58 | inline float getSize() const 59 | {return m_pointSize;} 60 | inline void getSubdivision(int& _around, int& _along) const 61 | {_around = m_subdivision[0]; _along = m_subdivision[1];} 62 | 63 | void setLaserPoints(const std::vector *_points, const std::vector& normals = std::vector(0)); 64 | 65 | inline const std::vector * getLaserPoints() const 66 | {return m_laserPoints;} 67 | 68 | inline const std::vector & getLaserNormals() const 69 | {return m_laserNormals;} 70 | 71 | inline const OrientedPoint2D* getLaserPose() const 72 | {return m_laserPose;} 73 | 74 | inline void setLaserPose(const OrientedPoint2D* pose) 75 | {m_laserPose = pose;m_listValid=false;} 76 | 77 | virtual void render(); 78 | 79 | protected: 80 | void makeList(); 81 | GLuint m_list; 82 | bool m_listValid; 83 | const std::vector * m_laserPoints; 84 | std::vector m_laserNormals; 85 | std::vector m_GLUPoints; 86 | const OrientedPoint2D* m_laserPose; 87 | Color m_color; 88 | float m_pointSize; 89 | float m_depth; 90 | int m_subdivision[2]; 91 | }; 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /src/gui/MultiScaleCurvatureDetectorPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef MULTISCALECURVATUREDETECTORPRESENTER_H_ 22 | #define MULTISCALECURVATUREDETECTORPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class MultiScaleCurvatureDetectorPresenter: public DetectorPresenter{ 33 | Q_OBJECT 34 | 35 | public: 36 | MultiScaleCurvatureDetectorPresenter(CurvatureDetector* detector, ParameterWidget* detectorParameter); 37 | 38 | virtual void activate(); 39 | 40 | virtual void deactivate(); 41 | 42 | void insertPeakFinder(const QString& name, PeakFinderPresenter* peak); 43 | 44 | void setDetector(Detector* detector); 45 | 46 | void setDetectorParameter(ParameterWidget* detectorParameter); 47 | 48 | signals: 49 | void detectorChanged(); 50 | 51 | public slots: 52 | void changeParameter(const QString& name); 53 | 54 | void changeMaxRange(int check); 55 | void changeScale(int scale); 56 | void changeSigma(double sigma); 57 | void changeSigmaStep(double step); 58 | void changeDmst(int dmst); 59 | void changePeakFinder(int peakFinder); 60 | 61 | protected: 62 | virtual void syncronize(); 63 | virtual void reconnect(); 64 | 65 | PeakFinderPresenter* m_currentPeakPresenter; 66 | int m_currentPeakPresenterIndex; 67 | QVector< PeakFinderPresenter* > m_peakPresenters; 68 | QStringList m_peakPresenterNames; 69 | }; 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/gui/MultiScaleDetectorPlotWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef MULTISCALEDETECTORPLOTWIDGET_H_ 22 | #define MULTISCALEDETECTORPLOTWIDGET_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class MultiScaleDetectorPlotWidget: public QWidget { 35 | Q_OBJECT 36 | public: 37 | MultiScaleDetectorPlotWidget(QWidget* parent = 0, unsigned int _scales = 0); 38 | 39 | virtual ~MultiScaleDetectorPlotWidget(); 40 | 41 | inline void setScales(unsigned int _scales) 42 | {m_scales = _scales; initCurves();} 43 | 44 | inline unsigned int getScales() const 45 | {return m_scales;} 46 | 47 | inline void setColors(const std::vector& _colors) 48 | {if(_colors.size() == m_scales) m_colors = _colors;} 49 | 50 | inline const std::vector& getColors() const 51 | {return m_colors;} 52 | 53 | public slots: 54 | virtual void setSmoothData(QVector& _dataX, QVector& _dataY, unsigned int _scale); 55 | virtual void setSmoothData(QVector< QVector >& _dataX, QVector< QVector >& _dataY); 56 | 57 | virtual void setDifferentialData(QVector& _dataX, QVector& _dataY, unsigned int _scale); 58 | virtual void setDifferentialData(QVector< QVector >& _dataX, QVector< QVector >& _dataY); 59 | 60 | virtual void setSmoothMarker(QVector& _dataX, QVector& _dataY, unsigned int _scale); 61 | virtual void setSmoothMarker(QVector< QVector >& _dataX, QVector< QVector >& _dataY); 62 | 63 | virtual void setDifferentialMarker(QVector& _dataX, QVector& _dataY, unsigned int _scale); 64 | virtual void setDifferentialMarker(QVector< QVector >& _dataX, QVector< QVector >& _dataY); 65 | 66 | virtual void replot(); 67 | 68 | protected: 69 | void buildGui(); 70 | void initCurves(); 71 | 72 | void setData(QVector& _curve, QVector& _dataX, QVector& _dataY, unsigned int _scale); 73 | void setData(QVector& _curve, QVector< QVector >& _dataX, QVector< QVector >& _dataY); 74 | 75 | QGridLayout *m_plotLayout; 76 | QwtPlot *m_smooth; 77 | QwtPlot *m_derivative; 78 | QVector m_smoothCurve; 79 | QVector m_smoothMarker; 80 | QVector m_diffCurve; 81 | QVector m_diffMarker; 82 | QwtPlotZoomer* m_smoothZoomer; 83 | QwtPlotZoomer* m_diffZoomer; 84 | unsigned int m_scales; 85 | 86 | std::vector m_colors; 87 | }; 88 | 89 | #endif 90 | 91 | -------------------------------------------------------------------------------- /src/gui/MultiScaleDetectorPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef MULTISCALEDETECTORPRESENTER_H_ 22 | #define MULTISCALEDETECTORPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class MultiScaleDetectorPresenter: public DetectorPresenter{ 33 | Q_OBJECT 34 | 35 | public: 36 | MultiScaleDetectorPresenter(MultiScaleDetector* detector, ParameterWidget* detectorParameter); 37 | 38 | virtual void activate(); 39 | 40 | virtual void deactivate(); 41 | 42 | void insertPeakFinder(const QString& name, PeakFinderPresenter* peak); 43 | 44 | void setDetector(Detector* detector); 45 | 46 | void setDetectorParameter(ParameterWidget* detectorParameter); 47 | 48 | signals: 49 | void detectorChanged(); 50 | 51 | public slots: 52 | void changeParameter(const QString& name); 53 | 54 | void changeMaxRange(int check); 55 | void changeScale(int scale); 56 | void changeSigma(double sigma); 57 | void changeSigmaStep(double step); 58 | void changeFilter(int filter); 59 | void changePeakFinder(int peakFinder); 60 | 61 | protected: 62 | virtual void syncronize(); 63 | virtual void reconnect(); 64 | 65 | PeakFinderPresenter* m_currentPeakPresenter; 66 | int m_currentPeakPresenterIndex; 67 | QVector< PeakFinderPresenter* > m_peakPresenters; 68 | QStringList m_peakPresenterNames; 69 | }; 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/gui/MultiScaleNormalDetectorPresenter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "MultiScaleNormalDetectorPresenter.h" 23 | #include "MultiScaleNormalDetectorPresenter.moc" 24 | 25 | #include 26 | 27 | MultiScaleNormalDetectorPresenter::MultiScaleNormalDetectorPresenter(NormalDetector* detector, ParameterWidget* detectorParameter): 28 | MultiScaleDetectorPresenter(detector, detectorParameter) 29 | { 30 | m_detectorParameter->addIntParameter("windowSize", "Size of the normal window", 3, 3, 11, 2); 31 | 32 | syncronize(); 33 | reconnect(); 34 | } 35 | 36 | void MultiScaleNormalDetectorPresenter::setDetectorParameter(ParameterWidget* detectorParameter){ 37 | disconnect(m_detectorParameter, 0, this, 0); 38 | MultiScaleDetectorPresenter::setDetectorParameter(detectorParameter); 39 | m_detectorParameter->addIntParameter("windowSize", "Size of the normal window", 3, 3, 11, 2); 40 | m_detectorParameter = detectorParameter; 41 | syncronize(); 42 | reconnect(); 43 | } 44 | 45 | 46 | 47 | void MultiScaleNormalDetectorPresenter::changeParameter(const QString& name){ 48 | if(!QString::compare(name, "windowSize")){ 49 | int guiValue; 50 | bool valid = m_detectorParameter->getIntValue("windowSize", guiValue); 51 | if(valid) {changeWindowSize(guiValue);} 52 | } else { 53 | MultiScaleDetectorPresenter::changeParameter(name); 54 | } 55 | } 56 | 57 | void MultiScaleNormalDetectorPresenter::changeWindowSize(int size){ 58 | NormalDetector *detector = dynamic_cast(m_detector); 59 | if(!detector || !m_detectorParameter) return; 60 | if((int)detector->getWindowSize() != size || m_detectorParameter->getIntValue("windowSize") != size){ 61 | detector->setWindowSize(size); 62 | m_detectorParameter->setIntValue("windowSize", detector->getWindowSize()); 63 | emit detectorChanged(); 64 | } 65 | } 66 | 67 | void MultiScaleNormalDetectorPresenter::syncronize(){ 68 | NormalDetector *detector = dynamic_cast(m_detector); 69 | if(detector && m_detectorParameter){ 70 | m_detectorParameter->setIntValue("windowSize", detector->getWindowSize()); 71 | } 72 | MultiScaleDetectorPresenter::syncronize(); 73 | } 74 | 75 | void MultiScaleNormalDetectorPresenter::reconnect(){ 76 | disconnect(m_detectorParameter, 0, this, 0); 77 | connect(m_detectorParameter, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 78 | } 79 | -------------------------------------------------------------------------------- /src/gui/MultiScaleNormalDetectorPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef MULTISCALENORMALDETECTORPRESENTER_H_ 22 | #define MULTISCALENORMALDETECTORPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class MultiScaleNormalDetectorPresenter: public MultiScaleDetectorPresenter{ 33 | Q_OBJECT 34 | 35 | public: 36 | MultiScaleNormalDetectorPresenter(NormalDetector* detector, ParameterWidget* detectorParameter); 37 | 38 | void setDetectorParameter(ParameterWidget* detectorParameter); 39 | 40 | public slots: 41 | void changeParameter(const QString& name); 42 | 43 | void changeWindowSize(int size); 44 | 45 | protected: 46 | virtual void syncronize(); 47 | virtual void reconnect(); 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/gui/ParameterWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef PARAMETERWIDGET_H_ 22 | #define PARAMETERWIDGET_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | struct ParameterPair{ 37 | QLabel *description; 38 | QWidget *parameter; 39 | }; 40 | 41 | class ParameterWidget: public QWidget { 42 | Q_OBJECT 43 | 44 | public: 45 | ParameterWidget(const QString &name, QWidget *parent = 0); 46 | 47 | virtual inline void activate() 48 | {show();} 49 | 50 | virtual inline void deactivate() 51 | {hide();} 52 | 53 | void addDoubleParameter(const QString& name, const QString& description, double initialValue = 0., double minValue = -10e16, double maxValue = 10e16, int decimals = 2, double step = 0.1); 54 | void addIntParameter(const QString& name, const QString& description, int initialValue = 0, int minValue = -10e7, int maxValue = 10e7, int step = 1); 55 | void addBoolParameter(const QString& name, const QString& description, bool initialValue = false); 56 | void addEnumParameter(const QString& name, const QString& description, QStringList& values, int initialValue = 0); 57 | inline void addEnumParameter(const QString& name, const QString& description, int initialValue = 0) 58 | {QStringList values; addEnumParameter(name, description, values, initialValue);} 59 | 60 | void removeParameter(QString& name); 61 | void clearParameterMap(); 62 | 63 | bool getDoubleValue(const QString& name, double& result) const; 64 | bool getIntValue(const QString& name, int& result) const; 65 | bool getBoolValue(const QString& name, bool& result) const; 66 | bool getEnumValue(const QString& name, int& result) const; 67 | 68 | inline double getDoubleValue(const QString& name) const 69 | {double result; getDoubleValue(name, result); return result;} 70 | inline int getIntValue(const QString& name) const 71 | {int result; getIntValue(name, result); return result;} 72 | inline bool getBoolValue(const QString& name) const 73 | {bool result; getBoolValue(name, result); return result;} 74 | inline int getEnumValue(const QString& name) const 75 | {int result; getEnumValue(name, result); return result;} 76 | 77 | signals: 78 | void parameterChanged(const QString& name); 79 | 80 | public slots: 81 | void setDoubleValue(const QString& name, double result); 82 | void setIntValue(const QString& name, int result); 83 | void setBoolValue(const QString& name, bool result); 84 | void setEnumValue(const QString& name, int result); 85 | void insertEnumValue(const QString& name, const QString& value); 86 | void removeEnumValue(const QString& name, const QString& value); 87 | void clearEnumParameter(const QString& name); 88 | 89 | protected: 90 | QString m_name; 91 | QHash m_parameterMap; 92 | QGridLayout *m_layout; 93 | QSignalMapper m_mapper; 94 | 95 | 96 | }; 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /src/gui/PeakFinderPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef PEAKFINDERPRESENTER_H_ 22 | #define PEAKFINDERPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class PeakFinderPresenter: public QObject{ 30 | public: 31 | PeakFinderPresenter(PeakFinder* peakFinder, ParameterWidget* peakParameter): 32 | m_peakFinder(peakFinder), 33 | m_peakFinderParameter(peakParameter) 34 | { } 35 | 36 | inline void activate() 37 | {if(m_peakFinderParameter) m_peakFinderParameter->activate();} 38 | inline void deactivate() 39 | {if(m_peakFinderParameter) m_peakFinderParameter->deactivate();} 40 | 41 | virtual void setPeakFinder(PeakFinder* peakFinder) = 0; 42 | 43 | virtual void setPeakFinderParameter(ParameterWidget* peakParameter) = 0; 44 | 45 | 46 | inline const PeakFinder* getPeakFinder() const 47 | {return m_peakFinder;} 48 | inline const ParameterWidget* getPeakFinderParameter() const 49 | {return m_peakFinderParameter;} 50 | 51 | inline PeakFinder* getPeakFinder() 52 | {return m_peakFinder;} 53 | inline ParameterWidget* getPeakFinderParameter() 54 | {return m_peakFinderParameter;} 55 | 56 | protected: 57 | PeakFinder* m_peakFinder; 58 | ParameterWidget* m_peakFinderParameter; 59 | }; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/gui/PolarGridGraphicsItem.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef POLARGRIDGRAPHICSITEM_H_ 22 | #define POLARGRIDGRAPHICSITEM_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | class PolarGridGraphicsItem: public QGraphicsItem { 31 | public: 32 | PolarGridGraphicsItem(const std::vector< std::vector > *grid, const std::vector *phiEdges, const std::vector *rhoEdges, QGraphicsItem* parent = 0); 33 | 34 | PolarGridGraphicsItem(const std::vector< double > *grid, const std::vector *phiEdges, const std::vector *rhoEdges, QGraphicsItem* parent = 0); 35 | 36 | inline void setColor(float _red, float _green, float _blue, float _alpha = 1.0f) 37 | {m_color = QColor(_red, _green, _blue, _alpha);} 38 | inline void setColor(const QColor& color) 39 | {m_color = color;} 40 | 41 | inline const QColor& getColor() const 42 | {return m_color; } 43 | 44 | void setGrid(const std::vector< std::vector > *grid, const std::vector *phiEdges, const std::vector *rhoEdges); 45 | 46 | void setFlatGrid(const std::vector< double > *grid, const std::vector *phiEdges, const std::vector *rhoEdges); 47 | 48 | inline const std::vector< std::vector > * getGrid() const 49 | {return m_grid;} 50 | 51 | inline const std::vector< double > * getFlatGrid() const 52 | {return m_flatGrid;} 53 | 54 | inline const std::vector * getPhiEdges() const 55 | {return m_phiEdges;} 56 | 57 | inline const std::vector * getRhoEdges() const 58 | {return m_rhoEdges;} 59 | 60 | inline const QString& getText() const 61 | {return m_text;} 62 | 63 | inline void setText(const QString& text) 64 | {m_text = text;} 65 | 66 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); 67 | 68 | QRectF boundingRect() const; 69 | 70 | QPainterPath shape() const; 71 | 72 | protected: 73 | // void mousePressEvent(QGraphicsSceneMouseEvent *event); 74 | 75 | const std::vector< std::vector >* m_grid; 76 | const std::vector< double >* m_flatGrid; 77 | const std::vector * m_phiEdges; 78 | const std::vector * m_rhoEdges; 79 | double m_maxValue; 80 | QColor m_color; 81 | QString m_text; 82 | }; 83 | 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /src/gui/PolarGridRenderer.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef POLARGRIDRENDERER_H_ 22 | #define POLARGRIDRENDERER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class PolarGridRenderer: public AbstractRenderer { 33 | public: 34 | PolarGridRenderer(const std::vector< std::vector > *grid, const std::vector *phiEdges, const std::vector *rhoEdges); 35 | 36 | PolarGridRenderer(const PolarGridRenderer& _renderer); 37 | 38 | PolarGridRenderer& operator=(const PolarGridRenderer& _renderer); 39 | 40 | virtual ~PolarGridRenderer(); 41 | 42 | inline void setDepth(float depth) 43 | {m_depth = depth;} 44 | 45 | inline void setColor(float _red, float _green, float _blue, float _alpha = 1.0f) 46 | {m_color = RGB2HSL(Color(_red, _green, _blue, _alpha));} 47 | inline void setColor(const Color& color) 48 | {m_color = RGB2HSL(color);} 49 | inline void setSubdivision(int _around, int _along) 50 | {m_subdivision[0] = _around, m_subdivision[1] = _along;} 51 | 52 | /* inline void getColor(float& _red, float& _green, float& _blue, float& _alpha) const 53 | {_red = m_color.red(); _green = m_color.green(); _blue = m_color.blue(); _alpha = m_color.alpha(); }*/ 54 | inline const HSLColor& getHSLColor() const 55 | {return m_color; } 56 | inline const Color getColor() const 57 | {return HSL2RGB(m_color); } 58 | inline void getSubdivision(int& _around, int& _along) const 59 | {_around = m_subdivision[0]; _along = m_subdivision[1];} 60 | 61 | void setGrid(const std::vector< std::vector > *grid, const std::vector *phiEdges, const std::vector *rhoEdges); 62 | 63 | inline const std::vector< std::vector > * getGrid() const 64 | {return m_grid;} 65 | 66 | inline const std::vector * getPhiEdges() const 67 | {return m_phiEdges;} 68 | 69 | inline const std::vector * getRhoEdges() const 70 | {return m_rhoEdges;} 71 | 72 | inline const OrientedPoint2D* getPosition() const 73 | {return m_position;} 74 | 75 | inline void setPosition(const OrientedPoint2D* position) 76 | {m_position = position;} 77 | 78 | 79 | virtual void render(); 80 | 81 | protected: 82 | const std::vector< std::vector >* m_grid; 83 | const std::vector * m_phiEdges; 84 | const std::vector * m_rhoEdges; 85 | std::vector m_GLUGrids; 86 | std::vector m_GLUSectors; 87 | const OrientedPoint2D * m_position; 88 | double m_maxValue; 89 | HSLColor m_color; 90 | float m_depth; 91 | int m_subdivision[2]; 92 | }; 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/gui/RansacPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef RANSACPRESENTER_H_ 22 | #define RANSACPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class RansacPresenter: public FeatureSetMatcherPresenter{ 31 | Q_OBJECT 32 | 33 | public: 34 | RansacPresenter(RansacFeatureSetMatcher* featureSetMatcher, ParameterWidget* featureSetMatcherParameter); 35 | 36 | virtual void setFeatureSetMatcher(AbstractFeatureSetMatcher* featureSetMatcher); 37 | 38 | virtual void setFeatureSetMatcherParameter(ParameterWidget* peakParameter); 39 | 40 | /* signals: 41 | void featureSetMatcherChanged();*/ 42 | 43 | public slots: 44 | void changeParameter(const QString& name); 45 | void changeSuccessProbability(double value); 46 | void changeInlierProbability(double value); 47 | void changeDistanceThreshold(double value); 48 | void changeAdaptive(int value); 49 | 50 | protected: 51 | virtual void syncronize(); 52 | virtual void reconnect(); 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/gui/RendererWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef RENDERERWIDGET_H_ 22 | #define RENDERERWIDGET_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class RendererWidget: public QGLWidget{ 33 | Q_OBJECT 34 | public: 35 | RendererWidget(QWidget *_parent = 0); 36 | inline void addRenderer(AbstractRenderer* _renderer) 37 | {m_renderObject.push_back(_renderer);} 38 | inline void removeRenderer(AbstractRenderer* _renderer) 39 | {m_renderObject.erase(std::find(m_renderObject.begin(), m_renderObject.end(), _renderer));} 40 | 41 | void unprojectCoordinates(GLdouble viewX, GLdouble viewY, GLdouble viewZ, GLdouble* worldX, GLdouble* worldY, GLdouble* worldZ); 42 | void unprojectCoordinates(GLdouble viewX, GLdouble viewY, GLdouble* worldX, GLdouble* worldY, GLdouble* worldZ); 43 | 44 | signals: 45 | void mousePressedGL(int button, int x, int y); 46 | void mouseMovedGL(int button, int x1, int y1, int x2, int y2); 47 | 48 | public slots: 49 | void setLaserPose(float _x, float _y, float _theta = 0); 50 | void setRotation(float _x, float _y, float _z); 51 | void setOffset(float _x, float _y, float _z); 52 | void setScale(float _scale); 53 | void makeSnapshot(const char * _filename); 54 | 55 | protected: 56 | virtual void initializeGL(); 57 | virtual void resizeGL(int _width, int _height); 58 | virtual void paintGL(); 59 | 60 | virtual void mousePressEvent(QMouseEvent *_event); 61 | virtual void mouseReleaseEvent(QMouseEvent *_event); 62 | virtual void mouseMoveEvent(QMouseEvent *_event); 63 | virtual void wheelEvent(QWheelEvent *_event); 64 | 65 | std::vector m_renderObject; 66 | 67 | GLdouble m_GLdefaultDepth; 68 | 69 | float m_laserPoseX; 70 | float m_laserPoseY; 71 | float m_laserPoseTheta; 72 | 73 | float m_rotationX; 74 | float m_rotationY; 75 | float m_rotationZ; 76 | float m_offsetX; 77 | float m_offsetY; 78 | float m_offsetZ; 79 | float m_scale; 80 | 81 | QPoint m_lastMousePosition; 82 | QPoint m_lastMousePressPosition; 83 | }; 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /src/gui/SensorStreamWidget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "SensorStreamWidget.h" 23 | 24 | 25 | SensorStreamWidget::SensorStreamWidget(QWidget * _parent): 26 | QFrame(_parent), 27 | m_isSeekable(false), 28 | m_position(0) 29 | { 30 | m_layout = new QGridLayout(this); 31 | m_nextButton = new QPushButton("Next", this); 32 | m_sensorSlider = new QSlider(this); 33 | m_sensorBox = new QSpinBox(this); 34 | m_sensorBox->setMinimum(0); 35 | 36 | buildGui(); 37 | } 38 | 39 | SensorStreamWidget::~SensorStreamWidget(){ 40 | delete m_layout; 41 | delete m_nextButton; 42 | delete m_sensorSlider; 43 | delete m_sensorBox; 44 | } 45 | 46 | void SensorStreamWidget::seekPosition(int _position){ 47 | if(_position == m_position){ 48 | return; 49 | } 50 | m_position = _position; 51 | if(m_isSeekable){ 52 | m_sensorSlider->setValue(_position); 53 | m_sensorBox->setValue(_position); 54 | } 55 | emit newReading(_position); 56 | } 57 | 58 | void SensorStreamWidget::nextPosition(){ 59 | if(m_isSeekable){ 60 | seekPosition(m_sensorSlider->value() + m_sensorSlider->singleStep()); 61 | } else { 62 | emit newReading(); 63 | } 64 | } 65 | 66 | void SensorStreamWidget::seekable(bool _seek, unsigned int _size){ 67 | m_isSeekable = _seek; 68 | m_sensorSlider->setEnabled(_seek); 69 | m_sensorBox->setEnabled(_seek); 70 | if(_size) { 71 | m_sensorSlider->setMaximum(_size); 72 | m_sensorBox->setMaximum(_size); 73 | } 74 | } 75 | 76 | void SensorStreamWidget::streamReady(){ 77 | m_nextButton->setEnabled(true); 78 | } 79 | 80 | 81 | void SensorStreamWidget::buildGui(){ 82 | m_layout->setSpacing(3); 83 | m_layout->setMargin(3); 84 | m_layout->addWidget(m_sensorSlider, 0,0); 85 | m_layout->addWidget(m_nextButton, 0,1); 86 | m_layout->addWidget(m_sensorBox, 0,2); 87 | 88 | m_sensorSlider->setEnabled(false); 89 | m_sensorSlider->setOrientation(Qt::Horizontal); 90 | 91 | m_nextButton->setEnabled(false); 92 | 93 | connect(m_nextButton, SIGNAL(clicked()), this, SLOT(nextPosition())); 94 | connect(m_sensorSlider, SIGNAL(valueChanged(int)), this, SLOT(seekPosition(int))); 95 | connect(m_sensorBox, SIGNAL(valueChanged(int)), this, SLOT(seekPosition(int))); 96 | } 97 | 98 | #include "SensorStreamWidget.moc" -------------------------------------------------------------------------------- /src/gui/SensorStreamWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SENSORSTREAMWIDGET_H_ 22 | #define SENSORSTREAMWIDGET_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class SensorStreamWidget: public QFrame{ 33 | Q_OBJECT 34 | 35 | public: 36 | SensorStreamWidget(QWidget * _parent = 0); 37 | virtual ~SensorStreamWidget(); 38 | inline int getPosition() const {return m_position;} 39 | 40 | signals: 41 | void newReading(); 42 | void newReading(int _position); 43 | 44 | public slots: 45 | void seekPosition(int _position); 46 | void nextPosition(); 47 | void seekable(bool seek, unsigned int _size = 0); 48 | void streamReady(); 49 | 50 | protected: 51 | void buildGui(); 52 | 53 | bool m_isSeekable; 54 | unsigned int m_position; 55 | QGridLayout *m_layout; 56 | QPushButton *m_nextButton; 57 | QSlider *m_sensorSlider; 58 | QSpinBox *m_sensorBox; 59 | }; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/gui/ShapeContextPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SHAPECONTEXTPRESENTER_H_ 22 | #define SHAPECONTEXTPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class ShapeContextPresenter: public DescriptorPresenter{ 31 | Q_OBJECT 32 | 33 | public: 34 | ShapeContextPresenter(ShapeContextGenerator* descriptor, ParameterWidget* peakParameter); 35 | 36 | virtual void setDescriptor(DescriptorGenerator* descriptor); 37 | 38 | virtual void setDescriptorParameter(ParameterWidget* peakParameter); 39 | 40 | void insertDistanceFunction(const QString& name, const HistogramDistance* distanceFunction); 41 | 42 | signals: 43 | void descriptorChanged(); 44 | 45 | public slots: 46 | void changeParameter(const QString& name); 47 | void changeMinRho(double value); 48 | void changeMaxRho(double value); 49 | void changeBinRho(int value); 50 | void changeBinPhi(int value); 51 | void changeDistanceFunction(int value); 52 | 53 | protected: 54 | void syncronize(); 55 | void reconnect(); 56 | 57 | const HistogramDistance* m_currentDistanceFunction; 58 | int m_currentDistanceFunctionIndex; 59 | QVector< const HistogramDistance* > m_distanceFunctions; 60 | QStringList m_distanceFunctionNames; 61 | }; 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/gui/SimplePeakFinderPresenter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "SimplePeakFinderPresenter.h" 23 | #include "SimplePeakFinderPresenter.moc" 24 | 25 | #include 26 | 27 | SimplePeakFinderPresenter::SimplePeakFinderPresenter(SimplePeakFinder* peakFinder, ParameterWidget* peakParameter): 28 | PeakFinderPresenter(peakFinder, peakParameter) 29 | { 30 | m_peakFinderParameter->addDoubleParameter("minValue", "Minimum value", 0., 0.); 31 | m_peakFinderParameter->addDoubleParameter("minDifference", "Minimum difference", 0., 0., 10e16, 4, 0.01); 32 | syncronize(); 33 | reconnect(); 34 | } 35 | 36 | void SimplePeakFinderPresenter::setPeakFinder(PeakFinder* peakFinder){ 37 | m_peakFinder = peakFinder; 38 | syncronize(); 39 | } 40 | 41 | void SimplePeakFinderPresenter::setPeakFinderParameter(ParameterWidget* peakParameter){ 42 | disconnect(m_peakFinderParameter, 0, this, 0); 43 | m_peakFinderParameter = peakParameter; 44 | m_peakFinderParameter->clearParameterMap(); 45 | m_peakFinderParameter->addDoubleParameter("minValue", "Minimum value", 0., 0.); 46 | m_peakFinderParameter->addDoubleParameter("minDifference", "Minimum difference", 0., 0., 10e16, 4, 0.01); 47 | syncronize(); 48 | reconnect(); 49 | } 50 | 51 | void SimplePeakFinderPresenter::changeParameter(const QString& name){ 52 | if(!QString::compare(name, "minValue")){ 53 | double guiValue; 54 | bool valid = m_peakFinderParameter->getDoubleValue("minValue", guiValue); 55 | if(valid) {changeMinValue(guiValue);} 56 | } else if(!QString::compare(name, "minDifference")){ 57 | double guiValue; 58 | bool valid = m_peakFinderParameter->getDoubleValue("minDifference", guiValue); 59 | if(valid) {changeMinDifference(guiValue);} 60 | } 61 | } 62 | 63 | 64 | void SimplePeakFinderPresenter::changeMinValue(double value){ 65 | SimplePeakFinder *peakFinder = (SimplePeakFinder *) m_peakFinder; 66 | double guiValue; 67 | m_peakFinderParameter->getDoubleValue(QString("minValue"), guiValue); 68 | if(peakFinder->getMinValue() != value || guiValue != value){ 69 | peakFinder->setMinValue(value); 70 | m_peakFinderParameter->setDoubleValue("minValue", peakFinder->getMinValue()); 71 | emit peakFinderChanged(); 72 | } 73 | } 74 | 75 | void SimplePeakFinderPresenter::changeMinDifference(double value){ 76 | SimplePeakFinder *peakFinder = (SimplePeakFinder *) m_peakFinder; 77 | double guiValue; 78 | m_peakFinderParameter->getDoubleValue("minDifference", guiValue); 79 | if(peakFinder->getMinDifference() != value || guiValue != value){ 80 | peakFinder->setMinDifference(value); 81 | m_peakFinderParameter->setDoubleValue("minDifference", peakFinder->getMinDifference()); 82 | emit peakFinderChanged(); 83 | } 84 | } 85 | 86 | void SimplePeakFinderPresenter::syncronize(){ 87 | SimplePeakFinder *peakFinder = (SimplePeakFinder *) m_peakFinder; 88 | m_peakFinderParameter->setDoubleValue("minValue", peakFinder->getMinValue()); 89 | m_peakFinderParameter->setDoubleValue("minDifference", peakFinder->getMinDifference()); 90 | } 91 | 92 | void SimplePeakFinderPresenter::reconnect(){ 93 | connect(m_peakFinderParameter, SIGNAL(parameterChanged(const QString&)), this, SLOT(changeParameter(const QString&))); 94 | } 95 | -------------------------------------------------------------------------------- /src/gui/SimplePeakFinderPresenter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SIMPLEPEAKFINDERPRESENTER_H_ 22 | #define SIMPLEPEAKFINDERPRESENTER_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class SimplePeakFinderPresenter: public PeakFinderPresenter{ 31 | Q_OBJECT 32 | 33 | public: 34 | SimplePeakFinderPresenter(SimplePeakFinder* peakFinder, ParameterWidget* peakParameter); 35 | 36 | virtual void setPeakFinder(PeakFinder* peakFinder); 37 | 38 | virtual void setPeakFinderParameter(ParameterWidget* peakParameter); 39 | 40 | signals: 41 | void peakFinderChanged(); 42 | 43 | public slots: 44 | void changeParameter(const QString& name); 45 | void changeMinValue(double value); 46 | void changeMinDifference(double value); 47 | 48 | protected: 49 | virtual void syncronize(); 50 | virtual void reconnect(); 51 | }; 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /src/gui/TabbedParameterWidget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "gui/TabbedParameterWidget.h" 23 | 24 | TabbedParameterWidget::TabbedParameterWidget(const QString &name, QTabWidget *parent, int position): 25 | ParameterWidget(name, parent), 26 | m_tabWidget(parent), 27 | m_tabPosition(position) 28 | { 29 | if(m_tabWidget && position == -1) 30 | m_tabPosition = m_tabWidget->count(); 31 | } 32 | 33 | void TabbedParameterWidget::activate() 34 | { 35 | ParameterWidget::activate(); 36 | if(m_tabWidget){ 37 | int position = m_tabWidget->insertTab(m_tabPosition, this, m_name); 38 | // m_tabWidget->setCurrentIndex(position); 39 | } 40 | } 41 | 42 | void TabbedParameterWidget::deactivate() 43 | { 44 | ParameterWidget::deactivate(); 45 | if(m_tabWidget){ 46 | int position = m_tabWidget->indexOf(this); 47 | m_tabWidget->removeTab(position); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/gui/TabbedParameterWidget.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef TABBEDPARAMETERWIDGET_H_ 22 | #define TABBEDPARAMETERWIDGET_H_ 23 | 24 | #include 25 | #include 26 | 27 | class TabbedParameterWidget: public ParameterWidget { 28 | public: 29 | TabbedParameterWidget(const QString &name, QTabWidget *parent = 0, int position = -1); 30 | 31 | virtual void activate(); 32 | 33 | virtual void deactivate(); 34 | 35 | protected: 36 | QTabWidget* m_tabWidget; 37 | int m_tabPosition; 38 | 39 | 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/insertLicense: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CH='/usr/local/bin/copyright-header' 4 | 5 | SW='FLIRTLib' 6 | DESC="Fast Laser Interesting Region Transform Library" 7 | HOLDER="Gian Diego Tipaldi and Kai O. Arras" 8 | YEAR="2009-2010" 9 | 10 | $CH --copyright-software "$SW" --copyright-software-description "$DESC" --copyright-holder "$HOLDER" --copyright-year "$YEAR" $@ 11 | -------------------------------------------------------------------------------- /src/sensors/AbstractReading.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "AbstractReading.h" 23 | 24 | AbstractReading::AbstractReading(double _time, const std::string& _name, const std::string& _robot): 25 | m_time(_time), 26 | m_name(_name), 27 | m_robot(_robot) 28 | { 29 | 30 | } -------------------------------------------------------------------------------- /src/sensors/AbstractReading.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef ABSTRACTREADING_H_ 22 | #define ABSTRACTREADING_H_ 23 | 24 | #include 25 | 26 | /** 27 | * Representation of an abstract sensor measurement. 28 | * This class represent a general sensor reading in terms of timestamp, sensor name and robot name. Other sensor modality should inherit from this base class. 29 | * 30 | * @author Gian Diego Tipaldi 31 | */ 32 | 33 | class AbstractReading { 34 | public: 35 | /** 36 | * Constructor. This is an abstract class, so the constructor only creates the shared part of any specialized class. 37 | * @param _time The timestamp of the reading. 38 | * @param _name The name of the sensor. 39 | * @param _robot The name of the robot. 40 | */ 41 | AbstractReading(double _time, const std::string& _name, const std::string& _robot); 42 | /** Destructor. */ 43 | virtual ~AbstractReading() {}; 44 | 45 | /** Clone function for prototyping. It implements the Prototype pattern. */ 46 | virtual AbstractReading* clone() const = 0; 47 | 48 | /** Get the timestamp of the reading. */ 49 | inline double getTime() const {return m_time;} 50 | /** Get the sensor name. */ 51 | inline const std::string& getName() const {return m_name;} 52 | /** Get the robot name. */ 53 | inline const std::string& getRobot() const {return m_robot;} 54 | 55 | 56 | protected: 57 | /** The timestamp of the reading (in seconds). */ 58 | double m_time; // maybe using a better timing representation 59 | /** The name of the sensor */ 60 | std::string m_name; 61 | /** The name of the robot (hostname of the machine) */ 62 | std::string m_robot; 63 | }; 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/sensors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(sensors_SRCS 2 | AbstractReading.cpp 3 | LaserReading.cpp 4 | ) 5 | 6 | SET(sensors_HDRS 7 | AbstractReading.h 8 | LaserReading.h 9 | ) 10 | 11 | ADD_LIBRARY(flirtlib_sensors SHARED ${sensors_SRCS}) 12 | TARGET_LINK_LIBRARIES(flirtlib_sensors flirtlib_geometry) 13 | 14 | install(TARGETS flirtlib_sensors 15 | RUNTIME DESTINATION bin 16 | LIBRARY DESTINATION lib 17 | ARCHIVE DESTINATION lib) 18 | 19 | install(FILES ${sensors_HDRS} DESTINATION include/flirtlib/sensors) 20 | -------------------------------------------------------------------------------- /src/sensors/LaserReading.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "LaserReading.h" 23 | 24 | 25 | using namespace std; 26 | 27 | LaserReading::LaserReading(const vector& _phi, const vector& _rho, double _time, const string& _name, const string& _robot): 28 | AbstractReading(_time, _name, _robot), 29 | m_maxRange(80), 30 | m_phi(_phi), 31 | m_rho(_rho) 32 | { 33 | m_remission.reserve(m_rho.size()); 34 | m_laserPose.x = 0; 35 | m_laserPose.y = 0; 36 | m_laserPose.theta = 0; 37 | m_robotPose.x = 0; 38 | m_robotPose.y = 0; 39 | m_robotPose.theta = 0; 40 | computeLocalCartesian(); 41 | m_worldCartesian = m_cartesian; 42 | } 43 | 44 | LaserReading::~LaserReading(){ 45 | 46 | } 47 | 48 | void LaserReading::setRemission(const vector& _remi){ 49 | if(_remi.size() == m_phi.size()) 50 | m_remission = _remi; 51 | } 52 | 53 | void LaserReading::setLaserPose(const OrientedPoint2D& _pose){ 54 | m_laserPose = _pose; 55 | computeWorldCartesian(); 56 | } 57 | 58 | void LaserReading::setRobotPose(const OrientedPoint2D& _pose){ 59 | m_robotPose = _pose; 60 | } 61 | 62 | void LaserReading::computeWorldCartesian(){ 63 | m_worldCartesian.resize(m_phi.size()); 64 | m_worldCartesianNoMax.clear(); 65 | for(unsigned int i = 0; i < m_phi.size(); i++){ 66 | if(m_rho[i]. 19 | */ 20 | 21 | #ifndef CARMENLOG_H_ 22 | #define CARMENLOG_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /** 36 | * Representation of a CARMEN log reader. It implements the LogReader class for the CARMEN log file format. 37 | * 38 | * @author Gian Diego Tipaldi 39 | */ 40 | 41 | class CarmenLogReader: public LogReader{ 42 | public: 43 | /** Virtual Default destructor. */ 44 | virtual ~CarmenLogReader() { } 45 | /** Read a log from an inputstream. */ 46 | virtual void readLog(std::istream& _stream, std::vector& _log) const; 47 | /** Read a single line from the stream. */ 48 | virtual AbstractReading* readLine(std::istream& _stream) const; 49 | 50 | protected: 51 | /** Parse the old laser structure (FLASER). */ 52 | LaserReading* parseFLaser(std::istream& _stream) const; 53 | /** Parse the new laser structure (ROBOTLASERX). */ 54 | LaserReading* parseRobotLaser(std::istream& _stream) const; 55 | /** Parse the raw laser structure (RAWLASERX). */ 56 | LaserReading* parseRawLaser(std::istream& _stream) const; 57 | }; 58 | 59 | 60 | /** 61 | * Representation of a CARMEN log writer. It implements the LogWriter class for the CARMEN log file format. 62 | * 63 | * @author Gian Diego Tipaldi 64 | */ 65 | 66 | class CarmenLogWriter: public LogWriter{ 67 | public: 68 | /** Virtual Default destructor */ 69 | virtual ~CarmenLogWriter() { } 70 | /** Write a log to an outputstream */ 71 | virtual void writeLog(std::ostream& _stream, const std::vector& _log) const; 72 | /** Write a single line to the stream. */ 73 | virtual void writeLine(std::ostream& _stream, const AbstractReading* _reading) const; 74 | 75 | protected: 76 | /** Write the old laser structure (FLASER). */ 77 | void writeFLaser(std::ostream& _stream, const LaserReading* _reading) const; 78 | /** Write the new laser structure (ROBOTLASERX). */ 79 | void writeRobotLaser(std::ostream& _stream, const LaserReading* _reading) const; 80 | /** Write the raw laser structure (RAWLASERX). */ 81 | void writeRawLaser(std::ostream& _stream, const LaserReading* _reading) const; 82 | }; 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /src/sensorstream/LogReader.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef LOGREADER_H_ 22 | #define LOGREADER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | /** 30 | * Representation of an abstract log reader. It defines the interface for reading a log file from a stream. 31 | * 32 | * @author Gian Diego Tipaldi 33 | */ 34 | 35 | class LogReader{ 36 | public: 37 | /** Virtual Default destructor */ 38 | virtual ~LogReader() { } 39 | 40 | /** Read a log from an inputstream */ 41 | virtual void readLog(std::istream& _stream, std::vector& _log) const = 0; 42 | 43 | /** Read a single line from an inputstream. */ 44 | virtual AbstractReading* readLine(std::istream& _stream) const = 0; 45 | }; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /src/sensorstream/LogSensorStream.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "LogSensorStream.h" 23 | 24 | LogSensorStream::LogSensorStream(const LogReader* _reader, const LogWriter* _writer): 25 | m_index(0), 26 | m_logReader(_reader), 27 | m_logWriter(_writer) 28 | { 29 | m_log.reserve(AVG_SIZE_LOG); 30 | } 31 | 32 | LogSensorStream::LogSensorStream(const LogSensorStream& _stream): 33 | m_log(_stream.getLog().size()), 34 | m_index(0), 35 | m_logReader(_stream.getReader()), 36 | m_logWriter(_stream.getWriter()) 37 | { 38 | const std::vector log = _stream.getLog(); 39 | for(unsigned int i = 0; i < log.size(); i++){ 40 | m_log[i] = log[i]->clone(); 41 | } 42 | } 43 | 44 | LogSensorStream& LogSensorStream::operator=(const LogSensorStream& _stream){ 45 | m_index = 0; 46 | m_logReader = _stream.getReader(); 47 | m_logWriter = _stream.getWriter(); 48 | 49 | for(unsigned int i = 0; i < m_log.size(); i++){ 50 | delete m_log[i]; 51 | } 52 | 53 | const std::vector log = _stream.getLog(); 54 | m_log.resize(log.size()); 55 | for(unsigned int i = 0; i < log.size(); i++){ 56 | m_log[i] = log[i]->clone(); 57 | } 58 | return *this; 59 | } 60 | 61 | LogSensorStream::~LogSensorStream(){ 62 | for(unsigned int i=0; i < m_log.size(); i++){ 63 | delete m_log[i]; 64 | } 65 | } 66 | 67 | AbstractReading* LogSensorStream::next(){ 68 | return m_log[m_index++]; 69 | } 70 | 71 | 72 | AbstractReading* LogSensorStream::current(){ 73 | return m_log[m_index]; 74 | } 75 | 76 | const AbstractReading* LogSensorStream::next() const{ 77 | return m_log[m_index++]; 78 | } 79 | 80 | 81 | const AbstractReading* LogSensorStream::current() const{ 82 | return m_log[m_index]; 83 | } 84 | 85 | bool LogSensorStream::seek(const unsigned int _position, SensorStreamOffset _offset){ 86 | unsigned int position = (_offset == BEGIN)? _position : m_log.size() -_position - 1; 87 | bool result = position >= 0 && position < m_log.size(); 88 | m_index = result ? position : m_index; 89 | return result; 90 | } 91 | 92 | bool LogSensorStream::end() const{ 93 | return m_index >= m_log.size(); 94 | } 95 | 96 | 97 | void LogSensorStream::load(const std::string& _filename){ 98 | std::ifstream infile; 99 | infile.open(_filename.c_str()); 100 | load(infile); 101 | infile.close(); 102 | } 103 | 104 | void LogSensorStream::save(const std::string& _filename){ 105 | std::ofstream outfile; 106 | outfile.open(_filename.c_str()); 107 | save(outfile); 108 | outfile.close(); 109 | } 110 | 111 | void LogSensorStream::load(std::istream& _stream){ 112 | m_logReader->readLog(_stream, m_log); 113 | } 114 | 115 | void LogSensorStream::save(std::ostream& _stream){ 116 | m_logWriter->writeLog(_stream, m_log); 117 | } 118 | -------------------------------------------------------------------------------- /src/sensorstream/LogSensorStream.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef LOGSENSORSTREAM_H_ 22 | #define LOGSENSORSTREAM_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /** \def AVG_SIZE_LOG Reserved space for a log in the constructor */ 36 | #define AVG_SIZE_LOG 1000 37 | 38 | /** 39 | * Representation of log file as a stream of sensor readings. 40 | * It implements the SensorStream class to stream from log files. 41 | * 42 | * See CarmenLogTest.cpp for an example of its use. 43 | * 44 | * @author Gian Diego Tipaldi 45 | */ 46 | 47 | class LogSensorStream: public SensorStream { 48 | public: 49 | /** 50 | * Constructor. It creates the stream by giving the _reader and the _writer. 51 | * @param _reader The LogReader object for a particular log format. 52 | * @param _writer The LogWriter object for a particular log format. 53 | */ 54 | LogSensorStream(const LogReader* _reader, const LogWriter* _writer); 55 | 56 | /** Copy Constructor. It copies the object of the class by cloning the readings. */ 57 | LogSensorStream(const LogSensorStream& _stream); 58 | 59 | /** 60 | * Assignament operator. It assigns _stream to this object. 61 | * The previous reading are deleted and the _stream one cloned. 62 | */ 63 | LogSensorStream& operator=(const LogSensorStream& _stream); 64 | 65 | /** Destructor */ 66 | virtual ~LogSensorStream(); 67 | 68 | /** Get the next reading and advance the stream (const reading). */ 69 | virtual const AbstractReading* next() const; 70 | 71 | /** Get the current reading without advancing the stream (const reading). */ 72 | virtual const AbstractReading* current() const; 73 | 74 | /** Get the next reading and advance the stream (non const reading). */ 75 | virtual AbstractReading* next(); 76 | 77 | /** Get the current reading without advancing the stream (non const reading). */ 78 | virtual AbstractReading* current(); 79 | 80 | inline virtual const AbstractReading* operator[](unsigned int n) const 81 | {return m_log[n];} 82 | 83 | inline virtual AbstractReading* operator[](unsigned int n) 84 | {return m_log[n];} 85 | 86 | /** Seek the stream to a given sensor position. Return false if is not possible. */ 87 | virtual bool seek(const unsigned int _position = 0, SensorStreamOffset _offset = BEGIN); 88 | 89 | /** Get the current sensor position of the stream. Return 0 if it is not seekable */ 90 | virtual inline unsigned int tell() const {return m_index;} 91 | 92 | /** Check if the stream is seekable */ 93 | virtual inline bool isSeekable() const {return true;} 94 | 95 | /** Check if the stream is finished. */ 96 | virtual bool end() const; 97 | 98 | 99 | /** Get the full log vector. */ 100 | inline const std::vector& getLog() const 101 | {return m_log;} 102 | 103 | /** Get the log reader. */ 104 | inline const LogReader* getReader() const 105 | {return m_logReader;} 106 | 107 | /** Get the log writer. */ 108 | inline const LogWriter* getWriter() const 109 | {return m_logWriter;} 110 | 111 | /** Load a log from a file. */ 112 | void load(const std::string& _filename); 113 | 114 | /** Save a log to a file. */ 115 | void save(const std::string& _filename); 116 | 117 | /** Load a log from a stream. */ 118 | void load(std::istream& _stream); 119 | 120 | /** Save a log to a stream. */ 121 | void save(std::ostream& _stream); 122 | 123 | protected: 124 | std::vector m_log; /**< The log, represented as a vector of reading. */ 125 | mutable unsigned int m_index; /**< The index of the current reading. */ 126 | const LogReader * m_logReader; /**< The log reader. */ 127 | const LogWriter * m_logWriter; /**< The log writer. */ 128 | }; 129 | 130 | #endif 131 | 132 | -------------------------------------------------------------------------------- /src/sensorstream/LogWriter.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef LOGWRITER_H_ 22 | #define LOGWRITER_H_ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | /** 30 | * Representation of an abstract log writer. It defines the interface for writing a log file to a stream. 31 | * 32 | * 33 | * @author Gian Diego Tipaldi 34 | */ 35 | 36 | class LogWriter{ 37 | public: 38 | /** Virtual Default destructor */ 39 | virtual ~LogWriter() { } 40 | 41 | /** Write a log to an outputstream */ 42 | virtual void writeLog(std::ostream& _stream, const std::vector& _log) const = 0; 43 | 44 | /** Write a reading to an outputstream */ 45 | virtual void writeLine(std::ostream& _stream, const AbstractReading* _reading) const = 0; 46 | }; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/sensorstream/SensorStream.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SENSORSTREAM_H_ 22 | #define SENSORSTREAM_H_ 23 | 24 | #include 25 | 26 | /** 27 | * \enum SensorStreamOffset The offset from where to seek, values are END or BEGIN. 28 | * 29 | * @author Gian Diego Tipaldi 30 | */ 31 | 32 | enum SensorStreamOffset { 33 | END, 34 | BEGIN 35 | }; 36 | 37 | /** 38 | * Representation of an abstract stream of sensor readings. 39 | * The class represents an abstract sensor stream, providing the interface for obtaining sensor 40 | * readings, as well as seeking within the stream and checking if the stream is over. 41 | * 42 | * @author Gian Diego Tipaldi 43 | */ 44 | 45 | class SensorStream { 46 | public: 47 | /** Virtual Default destructor */ 48 | virtual ~SensorStream() { } 49 | 50 | /** Get the next reading and advance the stream (const reading) */ 51 | virtual const AbstractReading* next() const = 0; 52 | 53 | /** Get the current reading without advancing the stream (const reading) */ 54 | virtual const AbstractReading* current() const = 0; 55 | 56 | /** Get the next reading and advance the stream (non const reading) */ 57 | virtual AbstractReading* next() = 0; 58 | 59 | /** Get the current reading without advancing the stream (nonconst reading) */ 60 | virtual AbstractReading* current() = 0; 61 | 62 | /** Get the n-th reading if the stream is seekable without advancing the the stream (const reading) */ 63 | virtual const AbstractReading* operator[](unsigned int n) const = 0; 64 | 65 | /** Get the n-th reading if the stream is seekable without advancing the the stream (non const reading) */ 66 | virtual AbstractReading* operator[](unsigned int n) = 0; 67 | 68 | /** Seek the stream to a given sensor position. Return false if is not possible */ 69 | virtual bool seek(const unsigned int _position = 0, SensorStreamOffset _offset = BEGIN) = 0; 70 | 71 | /** Get the current sensor position of the stream. Return 0 if it is not seekable */ 72 | virtual unsigned int tell() const = 0; 73 | 74 | /** Check if the stream is seekable */ 75 | virtual inline bool isSeekable() const {return false;} 76 | 77 | /** Check if the stream is finished */ 78 | virtual bool end() const = 0 ; 79 | }; 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(utils_SRCS 2 | Regression.cpp 3 | SimplePeakFinder.cpp 4 | SimpleMinMaxPeakFinder.cpp 5 | PoseEstimation.cpp 6 | ) 7 | 8 | SET(utils_HDRS 9 | Convolution.h 10 | Convolution.hpp 11 | HistogramDistances.h 12 | HistogramDistances.hpp 13 | PeakFinder.h 14 | PoseEstimation.h 15 | Regression.h 16 | SimpleMinMaxPeakFinder.h 17 | SimplePeakFinder.h 18 | ) 19 | 20 | ADD_LIBRARY(flirtlib_utils SHARED ${utils_SRCS}) 21 | 22 | install(TARGETS flirtlib_utils 23 | RUNTIME DESTINATION bin 24 | LIBRARY DESTINATION lib 25 | ARCHIVE DESTINATION lib) 26 | 27 | install(FILES ${utils_HDRS} DESTINATION include/flirtlib/utils) 28 | -------------------------------------------------------------------------------- /src/utils/Convolution.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef CONVOLUTION_H_ 22 | #define CONVOLUTION_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /** 30 | * Simple functions for performing convolution on discrete signals. 31 | * 32 | * @author Gian Diego Tipaldi 33 | */ 34 | 35 | /** 36 | * The padding strategy for the convolution operation. 37 | * 38 | */ 39 | enum ConvolutionPadding{ 40 | ZERO, /**< The zero padding strategy. The original signal is augmented with zeros at the borders. */ 41 | SPECULAR, /**< The specular padding strategy. The original signal is replicated in a specular way at the borders. */ 42 | CIRCULAR /**< The circular padding strategy. It implements the circular convolution. */ 43 | }; 44 | 45 | /** 46 | * The size of the convolution result 47 | * 48 | */ 49 | enum ConvolutionResult{ 50 | SAME, /**< The convolution result has the same size of the original signal. */ 51 | FULL /**< The convolution result has the full size. */ 52 | }; 53 | 54 | 55 | /** 56 | * Convolve the kernel over the source, if the size of the source is bigger than the size of the kernel, the opposite otherwise. 57 | * The padding is defined according to padding and can be ZERO, SPECULAR or CIRCULAR. The size of the result is defined by resultType 58 | * and can be FULL or SAME. The parameter offset define the offset of the kernel with respect to the source. 59 | * 60 | * @param source The signal to convolve. 61 | * @param kernel The convolution kernel. If the kernel is bigger than the source kernel and source are inverted. 62 | * @param offset The offset of the convolution. It is useful to shifting the signal to the left or right. 63 | * @param padding The type of padding. See the #ConvolutionPadding enum. 64 | * @param resultType The size of the convolution result. See the #ConvolutionResult enum. 65 | */ 66 | 67 | template 68 | std::vector convolve1D(const std::vector& source, const std::vector& kernel, int offset = 0, ConvolutionPadding padding = SPECULAR, ConvolutionResult resultType = SAME); 69 | 70 | /** 71 | * Compute the Bessel kernel for smoothing 72 | * 73 | * @param sigma The standard deviation of the kernel. 74 | * @param kernelSize The size of the kernel. 75 | */ 76 | 77 | template 78 | std::vector besselKernel1D(Numeric sigma, unsigned int kernelSize); 79 | 80 | /** 81 | * Compute the Gaussian kernel for smoothing 82 | * 83 | * @param sigma The standard deviation of the kernel. 84 | * @param kernelSize The size of the kernel. 85 | */ 86 | 87 | template 88 | std::vector gaussianKernel1D(Numeric sigma, unsigned int kernelSize); 89 | 90 | /** Print the signal to a stream */ 91 | template 92 | std::ostream& operator<<(std::ostream& out, const std::vector& vector); 93 | 94 | // real implementation 95 | #include 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /src/utils/Convolution.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | 23 | template 24 | std::ostream& operator<<(std::ostream& out, const std::vector& vector){ 25 | for(uint i = 0; i < vector.size(); i++){ 26 | out << vector[i] << " "; 27 | } 28 | return out; 29 | } 30 | 31 | template 32 | std::vector convolve1D(const std::vector& _source, const std::vector& _kernel, int _offset, ConvolutionPadding _padding, ConvolutionResult _resultType){ 33 | _resultType = (_padding == CIRCULAR) ? SAME : _resultType; 34 | bool inverted = (_source.size() < _kernel.size()); 35 | const std::vector& source = (inverted) ? _kernel : _source; 36 | const std::vector& kernel = (inverted) ? _source : _kernel; 37 | unsigned int size = _source.size() + (_resultType == FULL) * (_kernel.size() - 1); 38 | std::vector result(size); 39 | 40 | unsigned int i = 0; 41 | for( ; i < result.size(); i++){ 42 | result[i] = 0; 43 | 44 | int j = (int)i - (int)kernel.size() + 1 ; 45 | for(; j <= (int)i && j < _offset; j++){ 46 | Numeric pad = 0; 47 | switch(_padding) { 48 | case ZERO: 49 | pad = 0; break; 50 | case SPECULAR: 51 | pad = source[_offset - j]; break; 52 | case CIRCULAR: 53 | pad = source[source.size() + j -_offset]; break; 54 | } 55 | result[i] += pad * kernel[i - j]; 56 | } 57 | 58 | for( ; j <= (int)i && j < (int)source.size() + _offset; j++){ 59 | result[i] += source[j - _offset] * kernel[i - j]; 60 | } 61 | 62 | for( ; j <= (int)i; j++){ 63 | Numeric pad = 0; 64 | switch (_padding){ 65 | case ZERO: 66 | pad = 0; break; 67 | case SPECULAR: 68 | pad = source[2*source.size() - 1 - j + _offset]; break; 69 | case CIRCULAR: 70 | pad = source[j - _offset -source.size()]; break; 71 | } 72 | result[i] += pad * kernel[i - j]; 73 | } 74 | } 75 | /* for( ; i < result.size(); i++){ 76 | result[i] = 0; 77 | 78 | int j = (int)i - (int)kernel.size() + 1; 79 | for(; j <= (int)i; j++){ 80 | Numeric pad = 0; 81 | switch (_padding){ 82 | case ZERO: 83 | pad = 0; break; 84 | case SPECULAR: 85 | pad = source[source.size() - j]; break; 86 | case CIRCULAR: 87 | pad = source[j]; break; 88 | } 89 | result[i] += pad * kernel[i - j]; 90 | } 91 | }*/ 92 | 93 | return result; 94 | } 95 | 96 | template 97 | std::vector besselKernel1D(Numeric _sigma, unsigned int _kernelSize){ 98 | unsigned int size = (_kernelSize % 2) ? _kernelSize : _kernelSize + 1; 99 | std::vector result(size); 100 | Numeric accumulator = 0; 101 | 102 | for(unsigned int i = 0; i < size; i++){ 103 | result[i] = exp(_sigma) * boost::math::cyl_bessel_i(i - 0.5*(size-1),_sigma); 104 | accumulator += result[i]; 105 | } 106 | 107 | for(unsigned int i = 0; i < size; i++){ 108 | result[i] = result[i] / accumulator; 109 | } 110 | 111 | return result; 112 | } 113 | 114 | template 115 | std::vector gaussianKernel1D(Numeric sigma, unsigned int _kernelSize){ 116 | unsigned int size = (_kernelSize % 2) ? _kernelSize : _kernelSize + 1; 117 | std::vector result(size); 118 | Numeric accumulator = 0; 119 | if(sigma < 1e-10) sigma = 1e-6; 120 | 121 | for(unsigned int i = 0; i < size; i++){ 122 | Numeric x = i - 0.5*(size-1); 123 | result[i] = exp(-x*x/(2*sigma * sigma)); 124 | accumulator += result[i]; 125 | } 126 | 127 | for(unsigned int i = 0; i < size; i++){ 128 | result[i] = result[i] / accumulator; 129 | } 130 | 131 | return result; 132 | } 133 | -------------------------------------------------------------------------------- /src/utils/PeakFinder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef PEAKFINDER_H_ 22 | #define PEAKFINDER_H_ 23 | 24 | #include 25 | 26 | /** 27 | * Representation of an abstract algorithm for peak finding. 28 | * The class represents an abstract algorithm for finding peaks in discrete signals. 29 | * 30 | * @author Gian Diego Tipaldi 31 | */ 32 | 33 | class PeakFinder{ 34 | public: 35 | /** Default destructor. */ 36 | virtual ~PeakFinder() { } 37 | 38 | /** Finds the indexes of the peaks in a onedimensional signal. */ 39 | virtual void findPeaks(const std::vector& signal, std::vector& indexes) const = 0; 40 | 41 | /** Finds the indexes of the peaks in a bidimensional signal. */ 42 | virtual void findPeaks(const std::vector< std::vector >& signal, std::vector< std::vector >& indexes) const = 0; 43 | 44 | /** Checks if the given index represents a peak in the monodimensional signal */ 45 | virtual bool isPeak(const std::vector& signal, unsigned int index) const = 0; 46 | 47 | /** Checks if the given indexes represent a peak in the bidimensional signal */ 48 | virtual bool isPeak(const std::vector< std::vector >& signal, unsigned int index1, unsigned int index2) const = 0; 49 | }; 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/utils/PoseEstimation.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "PoseEstimation.h" 23 | 24 | double compute2DPose(const std::vector< std::pair > &correspondences, OrientedPoint2D& transformation) 25 | { 26 | Point2D point1mean, point2mean; 27 | for(unsigned int i = 0; i < correspondences.size(); i++){ 28 | point1mean = point1mean + correspondences[i].first; 29 | point2mean = point2mean + correspondences[i].second; 30 | } 31 | point1mean = point1mean * (1./double(correspondences.size())); 32 | point2mean = point2mean * (1./double(correspondences.size())); 33 | 34 | double A = 0, B = 0; 35 | for(unsigned int i = 0; i < correspondences.size(); i++){ 36 | Point2D delta1 = correspondences[i].first - point1mean; 37 | Point2D delta2 = correspondences[i].second - point2mean; 38 | A += delta1 * delta2; 39 | B += delta1.ortho() * delta2; 40 | } 41 | 42 | A /= double(correspondences.size()); 43 | B /= double(correspondences.size()); 44 | 45 | double denom = sqrt(A*A + B*B); 46 | double sinalpha1 = B/denom; 47 | double cosalpha1 = -A/denom; 48 | double sinalpha2 = -sinalpha1; 49 | double cosalpha2 = -cosalpha1; 50 | 51 | Point2D point1rotated(cosalpha1 * point1mean.x - sinalpha1 * point1mean.y, 52 | sinalpha1 * point1mean.x + cosalpha1 * point1mean.y); 53 | Point2D point2rotated(cosalpha2 * point1mean.x - sinalpha2 * point1mean.y, 54 | sinalpha2 * point1mean.x + cosalpha2 * point1mean.y); 55 | 56 | Point2D translation1(point2mean - point1rotated); 57 | Point2D translation2(point2mean - point2rotated); 58 | 59 | double error1 = 0, error2 = 0; 60 | for(unsigned int i = 0; i < correspondences.size(); i++){ 61 | const Point2D& point1 = correspondences[i].first; 62 | const Point2D& point2 = correspondences[i].second; 63 | Point2D delta1 = point2 - Point2D(cosalpha1 * point1.x - sinalpha1 * point1.y, sinalpha1 * point1.x + cosalpha1 * point1.y) - translation1; 64 | Point2D delta2 = point2 - Point2D(cosalpha2 * point1.x - sinalpha2 * point1.y, sinalpha2 * point1.x + cosalpha2 * point1.y) - translation2; 65 | error1 = error1 + delta1 * delta1; 66 | error2 = error2 + delta2 * delta2; 67 | } 68 | if(error1 <= error2){ 69 | transformation.x = translation1.x; transformation.y = translation1.y; transformation.theta = atan2(sinalpha1, cosalpha1); 70 | return error1; 71 | } else { 72 | transformation.x = translation2.x; transformation.y = translation2.y; transformation.theta = atan2(sinalpha2, cosalpha2); 73 | return error2; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/utils/PoseEstimation.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef POSEESTIMATION_H_ 22 | #define POSEESTIMATION_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | /** Function to compute the Euclidean transformation between two set of points. The transformation is computed in closed form minimizing the squared residual reprojection error. */ 30 | double compute2DPose(const std::vector< std::pair > &correspondences, OrientedPoint2D& transformation); 31 | 32 | /** Function to compute the Euclidean transformation between two set of points. The transformation is computed in closed form minimizing the squared residual reprojection error. */ 33 | inline OrientedPoint2D compute2DPose(const std::vector< std::pair > &correspondences) 34 | {OrientedPoint2D result; compute2DPose(correspondences, result); return result;} 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/utils/Regression.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef REGRESSION_H_ 22 | #define REGRESSION_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | * Simple functions to perform line fitting 30 | * 31 | * @author Gian Diego Tipaldi 32 | */ 33 | 34 | 35 | /** 36 | * Struct defining the parameters of a line; 37 | * 38 | * @author Gian Diego Tipaldi 39 | */ 40 | 41 | struct LineParameters{ 42 | double rho; /**< The distance of the line from the origin of the axis. */ 43 | double alpha; /**< The angle of the normal vector of the line. */ 44 | double error; /**< The residual error of the fitted line. */ 45 | }; 46 | 47 | /** 48 | * Fits a line in the weighted least squares sense to the points, in cartesian coordinates, with the corresponding weights, 49 | * minimizing the weighted perpendicular errors from the points to the line. 50 | */ 51 | 52 | LineParameters computeNormals(const std::vector& points, const std::vector& weights); 53 | 54 | /** 55 | * Fits a line in the weighted least squares sense to the points, in cartesian coordinates, 56 | * minimizing the perpendicular errors from the points to the line. 57 | */ 58 | 59 | LineParameters computeNormals(const std::vector& points); 60 | 61 | /** 62 | * Fits a line in the weighted least squares sense at the center with the points, in cartesian coordinates, 63 | * minimizing the perpendicular errors from the points to the line. 64 | */ 65 | 66 | 67 | LineParameters computeNormals(const Point2D& center, const std::vector& _points); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/utils/SimpleMinMaxPeakFinder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "SimpleMinMaxPeakFinder.h" 23 | 24 | SimpleMinMaxPeakFinder::SimpleMinMaxPeakFinder(double minValue, double minDifference): 25 | SimplePeakFinder(minValue, minDifference) 26 | { 27 | 28 | } 29 | 30 | bool SimpleMinMaxPeakFinder::isPeak(const std::vector& signal, unsigned int index) const { 31 | bool minPeak = signal[index] < -m_minValue && 32 | signal[index] - signal[index - 1] < -m_minDifference && 33 | signal[index] - signal[index + 1] < -m_minDifference; 34 | return SimplePeakFinder::isPeak(signal,index) || minPeak; 35 | } 36 | -------------------------------------------------------------------------------- /src/utils/SimpleMinMaxPeakFinder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SIMPLEMINMAXPEAKFINDER_H_ 22 | #define SIMPLEMINMAXPEAKFINDER_H_ 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * Representation of a simple algorithm for peak finding. 29 | * The class represents a simple algorithm for finding peaks in discrete signals. 30 | * The algorithm finds both positive and negative peaks. 31 | * 32 | * @author Gian Diego Tipaldi 33 | */ 34 | 35 | class SimpleMinMaxPeakFinder: public SimplePeakFinder{ 36 | public: 37 | /** 38 | * Constructor. Creates and initializes the peak finder. 39 | * 40 | * @param minValue The minimum value for a peak to be considerated valid. The negative value is used for the negative peak. 41 | * @param minDifference The minimum difference a peak should have with respect to its immediate neighbours. The negative value is used for the negative peak. 42 | */ 43 | SimpleMinMaxPeakFinder(double minValue = 0.0, double minDifference = 0.0); 44 | 45 | /** Default destructor. */ 46 | virtual ~SimpleMinMaxPeakFinder() { } 47 | 48 | virtual bool isPeak(const std::vector& signal, unsigned int index) const; 49 | }; 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/utils/SimplePeakFinder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // FLIRTLib - Fast Laser Interesting Region Transform Library 4 | // Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 5 | // 6 | // This file is part of FLIRTLib. 7 | // 8 | // FLIRTLib is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Lesser General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // FLIRTLib is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public License 19 | // along with FLIRTLib. If not, see . 20 | // 21 | 22 | #include "SimplePeakFinder.h" 23 | 24 | SimplePeakFinder::SimplePeakFinder(double minValue, double minDifference): 25 | PeakFinder(), 26 | m_minValue(minValue), 27 | m_minDifference(minDifference) 28 | { 29 | 30 | } 31 | 32 | void SimplePeakFinder::findPeaks(const std::vector& signal, std::vector& indexes) const { 33 | indexes.clear(); 34 | for (unsigned int i = 1; i < signal.size() - 1; i++){ 35 | if(isPeak(signal, i)){ 36 | indexes.push_back(i); 37 | } 38 | } 39 | } 40 | 41 | bool SimplePeakFinder::isPeak(const std::vector& signal, unsigned int index) const { 42 | return signal[index] > m_minValue && 43 | signal[index] - signal[index - 1] > m_minDifference && 44 | signal[index] - signal[index + 1] > m_minDifference; 45 | } 46 | 47 | void SimplePeakFinder::findPeaks(const std::vector< std::vector >& signal, std::vector< std::vector >& indexes) const{ 48 | indexes.resize(signal.size()); 49 | for (unsigned int i = 0; i < signal.size(); i++){ 50 | findPeaks(signal[i], indexes[i]); 51 | } 52 | } 53 | 54 | bool SimplePeakFinder::isPeak(const std::vector< std::vector >& signal, unsigned int index1, unsigned int index2) const{ 55 | return isPeak(signal[index1],index2); 56 | } 57 | -------------------------------------------------------------------------------- /src/utils/SimplePeakFinder.h: -------------------------------------------------------------------------------- 1 | /* * 2 | * FLIRTLib - Fast Laser Interesting Region Transform Library 3 | * Copyright (C) 2009-2010 Gian Diego Tipaldi and Kai O. Arras 4 | * 5 | * This file is part of FLIRTLib. 6 | * 7 | * FLIRTLib is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * FLIRTLib is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with FLIRTLib. If not, see . 19 | */ 20 | 21 | #ifndef SIMPLEPEAKFINDER_H_ 22 | #define SIMPLEPEAKFINDER_H_ 23 | 24 | #include 25 | #include 26 | 27 | /** 28 | * Representation of a simple algorithm for peak finding. 29 | * The class represents a simple algorithm for finding peaks in discrete signals. 30 | * 31 | * @author Gian Diego Tipaldi 32 | */ 33 | 34 | class SimplePeakFinder: public PeakFinder{ 35 | public: 36 | /** 37 | * Constructor. Creates and initializes the peak finder. 38 | * 39 | * @param minValue The minimum value for a peak to be considerated valid. 40 | * @param minDifference The minimum difference a peak should have with respect to its immediate neighbours. 41 | */ 42 | SimplePeakFinder(double minValue = 0.0, double minDifference = 0.0); 43 | 44 | /** Default destructor. */ 45 | virtual ~SimplePeakFinder() { } 46 | 47 | virtual void findPeaks(const std::vector& signal, std::vector& indexes) const; 48 | 49 | virtual void findPeaks(const std::vector< std::vector >& signal, std::vector< std::vector >& indexes) const; 50 | 51 | virtual bool isPeak(const std::vector& signal, unsigned int index) const; 52 | 53 | virtual bool isPeak(const std::vector< std::vector >& signal, unsigned int index1, unsigned int index2) const; 54 | 55 | /** Gets the minimum value for a peak to be considerated valid. */ 56 | inline double getMinValue() const 57 | {return m_minValue;} 58 | 59 | /** Gets the minimum difference a peak should have with respect to its immediate neighbours. */ 60 | inline double getMinDifference() const 61 | {return m_minDifference;} 62 | 63 | /** Sets the minimum value for a peak to be considerated valid. */ 64 | inline void setMinValue(double value) 65 | {m_minValue = value;} 66 | 67 | /** Sets the minimum difference a peak should have with respect to its immediate neighbours. */ 68 | inline void setMinDifference(double value) 69 | {m_minDifference = value;} 70 | protected: 71 | double m_minValue; /**< The minimum value for a peak to be considerated valid. */ 72 | double m_minDifference; /**< The minimum difference a peak should have with respect to its immediate neighbours. */ 73 | }; 74 | 75 | #endif 76 | 77 | --------------------------------------------------------------------------------