Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: cpp
os:
- linux
- osx
- windows
dist:
- bionic
osx_image:
- xcode11.3
env:
- OPENCV_BRANCH=master
- OPENCV_BRANCH=3.4
cache:
directories:
- ${TRAVIS_BUILD_DIR}/opencv
before_script:
- rmdir opencv || true
- if [ ! -d opencv ]; then git clone --single-branch --branch ${OPENCV_BRANCH} https://github.com/opencv/opencv.git; fi
- pushd opencv
- mkdir -p build
- cd build
- cmake .. -DBUILD_LIST=core,imgproc,imgcodecs,calib3d,highgui -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=../install
- cmake --build . --parallel 8 --target install --config Release
- popd
script:
- mkdir -p build
- cd build
- export OPENCV_CONFIG=$(dirname $(find ${TRAVIS_BUILD_DIR}/opencv/install -name OpenCVConfig.cmake | head -n1))
- cmake .. -DOpenCV_DIR=${OPENCV_CONFIG}
- cmake --build . --config Release
- export DEMO=$(find . -type f \( -name demo.exe -o -name demo \) | head -n1)
- export PATH="$PATH:${TRAVIS_BUILD_DIR}/opencv/install/x86/vc15/bin"
- echo | $DEMO
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
project(DBoW2)
include(ExternalProject)

Expand All @@ -12,13 +12,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
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")
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(HDRS
Expand All @@ -42,13 +38,15 @@ if(BUILD_DBoW2)
set(LIB_SHARED "STATIC")
endif(WIN32)
add_library(${PROJECT_NAME} ${LIB_SHARED} ${SRCS})
include_directories(include/DBoW2/)
target_include_directories(${PROJECT_NAME} PUBLIC include/DBoW2/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this by chance fix the issue with expected location of the exported headers in downstream projects? MIT-SPARK/Kimera-VIO#32 (comment)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will. I'm close to have this branch merged, so you will be able to test it.

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
endif(BUILD_DBoW2)

if(BUILD_Demo)
add_executable(demo demo/demo.cpp)
target_link_libraries(demo ${PROJECT_NAME} ${OpenCV_LIBS})
set_target_properties(demo PROPERTIES CXX_STANDARD 11)
file(COPY demo/images DESTINATION ${CMAKE_BINARY_DIR}/)
endif(BUILD_Demo)

Expand All @@ -64,3 +62,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DBoW2Config.cmake"
install(FILES "${PROJECT_BINARY_DIR}/DBoW2Config.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/DBoW2/)
install(DIRECTORY ${DEPENDENCY_INSTALL_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX} OPTIONAL)

4 changes: 2 additions & 2 deletions demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ void testVocCreation(const vector<vector<cv::Mat > > &features)
const int k = 9;
const int L = 3;
const WeightingType weight = TF_IDF;
const ScoringType score = L1_NORM;
const ScoringType scoring = L1_NORM;

OrbVocabulary voc(k, L, weight, score);
OrbVocabulary voc(k, L, weight, scoring);

cout << "Creating a small " << k << "^" << L << " vocabulary..." << endl;
voc.create(features);
Expand Down
1 change: 0 additions & 1 deletion include/DBoW2/TemplatedDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ EntryId TemplatedDatabase<TDescriptor, F>::add(const BowVector &v,
EntryId entry_id = m_nentries++;

BowVector::const_iterator vit;
std::vector<unsigned int>::const_iterator iit;

if(m_use_di)
{
Expand Down
1 change: 0 additions & 1 deletion src/BowVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ void BowVector::normalize(LNorm norm_type)
std::ostream& operator<< (std::ostream &out, const BowVector &v)
{
BowVector::const_iterator vit;
std::vector<unsigned int>::const_iterator iit;
unsigned int i = 0;
const unsigned int N = v.size();
for(vit = v.begin(); vit != v.end(); ++vit, ++i)
Expand Down
2 changes: 1 addition & 1 deletion src/FBrief.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void FBrief::toMat32F(const std::vector<TDescriptor> &descriptors,
float *p = mat.ptr<float>(i);
for(int j = 0; j < FBrief::L; ++j, ++p)
{
*p = (desc[j] ? 1 : 0);
*p = (desc[j] ? 1.f : 0.f);
}
}
}
Expand Down
49 changes: 9 additions & 40 deletions src/FORB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ double FORB::distance(const FORB::TDescriptor &a,
(sizeof(uint64_t) - 1) * CHAR_BIT;
}

return ret;
return static_cast<double>(ret);

// // If uint64_t is not defined in your system, you can try this
// // portable approach (requires DUtils from DLib)
Expand Down Expand Up @@ -171,14 +171,14 @@ void FORB::toMat32F(const std::vector<TDescriptor> &descriptors,

for(int j = 0; j < C; ++j, p += 8)
{
p[0] = (desc[j] & (1 << 7) ? 1 : 0);
p[1] = (desc[j] & (1 << 6) ? 1 : 0);
p[2] = (desc[j] & (1 << 5) ? 1 : 0);
p[3] = (desc[j] & (1 << 4) ? 1 : 0);
p[4] = (desc[j] & (1 << 3) ? 1 : 0);
p[5] = (desc[j] & (1 << 2) ? 1 : 0);
p[6] = (desc[j] & (1 << 1) ? 1 : 0);
p[7] = desc[j] & (1);
p[0] = (desc[j] & (1 << 7) ? 1.f : 0.f);
p[1] = (desc[j] & (1 << 6) ? 1.f : 0.f);
p[2] = (desc[j] & (1 << 5) ? 1.f : 0.f);
p[3] = (desc[j] & (1 << 4) ? 1.f : 0.f);
p[4] = (desc[j] & (1 << 3) ? 1.f : 0.f);
p[5] = (desc[j] & (1 << 2) ? 1.f : 0.f);
p[6] = (desc[j] & (1 << 1) ? 1.f : 0.f);
p[7] = (desc[j] & (1) ? 1.f : 0.f);
}
}
}
Expand All @@ -187,38 +187,7 @@ void FORB::toMat32F(const std::vector<TDescriptor> &descriptors,

void FORB::toMat32F(const cv::Mat &descriptors, cv::Mat &mat)
{

descriptors.convertTo(mat, CV_32F);
return;

if(descriptors.empty())
{
mat.release();
return;
}

const int N = descriptors.rows;
const int C = descriptors.cols;

mat.create(N, FORB::L*8, CV_32F);
float *p = mat.ptr<float>(); // p[i] == 1 or 0

const unsigned char *desc = descriptors.ptr<unsigned char>();

for(int i = 0; i < N; ++i, desc += C)
{
for(int j = 0; j < C; ++j, p += 8)
{
p[0] = (desc[j] & (1 << 7) ? 1 : 0);
p[1] = (desc[j] & (1 << 6) ? 1 : 0);
p[2] = (desc[j] & (1 << 5) ? 1 : 0);
p[3] = (desc[j] & (1 << 4) ? 1 : 0);
p[4] = (desc[j] & (1 << 3) ? 1 : 0);
p[5] = (desc[j] & (1 << 2) ? 1 : 0);
p[6] = (desc[j] & (1 << 1) ? 1 : 0);
p[7] = desc[j] & (1);
}
}
}

// --------------------------------------------------------------------------
Expand Down