Skip to content

Commit

Permalink
Merge pull request #13 from dorian3d/update/version
Browse files Browse the repository at this point in the history
Several updates
  • Loading branch information
dorian3d committed May 1, 2016
2 parents 4a6eed2 + 6544e10 commit 405f931
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 123 deletions.
51 changes: 49 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
cmake_minimum_required(VERSION 2.8)
project(DBoW2)
include(ExternalProject)

option(BUILD_DBoW2 "Build DBoW2" ON)
option(BUILD_Demo "Build demo application" ON)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
endif()

set(HDRS
include/DBoW2/BowVector.h include/DBoW2/FBrief.h include/DBoW2/FSurf64.h
include/DBoW2/QueryResults.h include/DBoW2/TemplatedDatabase.h include/DBoW2/FORB.h
Expand All @@ -13,12 +30,41 @@ set(SRCS
src/BowVector.cpp src/FBrief.cpp src/FSurf64.cpp src/FORB.cpp
src/FeatureVector.cpp src/QueryResults.cpp src/ScoringObject.cpp)

set(DEPENDENCY_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies)
set(DEPENDENCY_INSTALL_DIR ${DEPENDENCY_DIR}/install)

find_package(OpenCV REQUIRED)
find_package(DLib REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})

find_package(DLib QUIET
PATHS ${DEPENDENCY_INSTALL_DIR})
if(${DLib_FOUND})
message("DLib library found, using it from the system")
include_directories(${DLib_INCLUDE_DIRS})
add_custom_target(Dependencies)
else(${DLib_FOUND})
message("DLib library not found in the system, it will be downloaded on build")
option(DOWNLOAD_DLib_dependency "Download DLib dependency" ON)
if(${DOWNLOAD_DLib_dependency})
ExternalProject_Add(DLib
PREFIX ${DEPENDENCY_DIR}
GIT_REPOSITORY http://github.com/dorian3d/DLib
GIT_TAG v1.1-nonfree
INSTALL_DIR ${DEPENDENCY_INSTALL_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>)
add_custom_target(Dependencies ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} DEPENDS DLib)
else()
message(SEND_ERROR "Please, activate DOWNLOAD_DLib_dependency option or download manually")
endif(${DOWNLOAD_DLib_dependency})
endif(${DLib_FOUND})

if(BUILD_DBoW2)
include_directories(include/DBoW2/ ${OpenCV_INCLUDE_DIRS} ${DLib_INCLUDE_DIRS})
add_library(${PROJECT_NAME} SHARED ${SRCS})
include_directories(include/DBoW2/)
add_dependencies(${PROJECT_NAME} Dependencies)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${DLib_LIBS})
endif(BUILD_DBoW2)

Expand All @@ -39,3 +85,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DBoW2Config.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
install(FILES "${PROJECT_BINARY_DIR}/DBoW2Config.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/DBoW2/)
install(DIRECTORY ${DEPENDENCY_INSTALL_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX} OPTIONAL)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you use this software in an academic work, please cite:

## Installation notes

DBoW2 requires [DLib](https://github.com/dorian3d/DLib), which you can find in [my repository](https://github.com/dorian3d/DLib).
DBoW2 requires [DLib](https://github.com/dorian3d/DLib), which is automatically installed if it cannot be found in the system. You can also find it in [my repository](https://github.com/dorian3d/DLib).

DBoW2 requires OpenCV and the `Boost::dynamic_bitset` class in order to use the BRIEF version. You can install Boost by typing:

Expand Down
19 changes: 8 additions & 11 deletions demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
// DBoW2
#include "DBoW2.h" // defines Surf64Vocabulary and Surf64Database

#include "DUtils.h"
#include "DUtilsCV.h" // defines macros CVXX
#include "DVision.h"
#include <DUtils/DUtils.h>
#include <DVision/DVision.h>

// OpenCV
#include <opencv/cv.h>
#include <opencv/highgui.h>
#if CV24
#include <opencv2/nonfree/features2d.hpp>
#endif
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/xfeatures2d/nonfree.hpp>


using namespace DBoW2;
Expand Down Expand Up @@ -76,7 +73,7 @@ void loadFeatures(vector<vector<vector<float> > > &features)
features.clear();
features.reserve(NIMAGES);

cv::SURF surf(400, 4, 2, EXTENDED_SURF);
cv::Ptr<cv::xfeatures2d::SURF> surf = cv::xfeatures2d::SURF::create(400, 4, 2, EXTENDED_SURF);

cout << "Extracting SURF features..." << endl;
for(int i = 0; i < NIMAGES; ++i)
Expand All @@ -89,10 +86,10 @@ void loadFeatures(vector<vector<vector<float> > > &features)
vector<cv::KeyPoint> keypoints;
vector<float> descriptors;

surf(image, mask, keypoints, descriptors);
surf->detectAndCompute(image, mask, keypoints, descriptors);

features.push_back(vector<vector<float> >());
changeStructure(descriptors, features.back(), surf.descriptorSize());
changeStructure(descriptors, features.back(), surf->descriptorSize());
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/BowVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum ScoringType
CHI_SQUARE,
KL,
BHATTACHARYYA,
DOT_PRODUCT,
DOT_PRODUCT
};

/// Vector of words to represent images
Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/DBoW2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Written by Dorian Galvez-Lopez,
* University of Zaragoza
*
* Check my website to obtain updates: http://webdiis.unizar.es/~dorian
* Check my website to obtain updates: http://doriangalvez.com
*
* \section requirements Requirements
* This library requires the DUtils, DUtilsCV, DVision and OpenCV libraries,
Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/FBrief.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __D_T_F_BRIEF__
#define __D_T_F_BRIEF__

#include <opencv/cv.h>
#include <opencv2/core.hpp>
#include <vector>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/FClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __D_T_FCLASS__
#define __D_T_FCLASS__

#include <opencv/cv.h>
#include <opencv2/core.hpp>
#include <vector>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/FORB.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __D_T_F_ORB__
#define __D_T_F_ORB__

#include <opencv/cv.h>
#include <opencv2/core.hpp>
#include <vector>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion include/DBoW2/FSurf64.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __D_T_F_SURF_64__
#define __D_T_F_SURF_64__

#include <opencv/cv.h>
#include <opencv2/core.hpp>
#include <vector>
#include <string>

Expand Down
Loading

0 comments on commit 405f931

Please sign in to comment.