Skip to content

Commit b0741bc

Browse files
authored
Merge pull request #61 from dorian3d/travis
Travis CI
2 parents 4d08e9f + 031691d commit b0741bc

File tree

7 files changed

+53
-54
lines changed

7 files changed

+53
-54
lines changed

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: cpp
2+
os:
3+
- linux
4+
- osx
5+
- windows
6+
dist:
7+
- bionic
8+
osx_image:
9+
- xcode11.3
10+
env:
11+
- OPENCV_BRANCH=master
12+
- OPENCV_BRANCH=3.4
13+
cache:
14+
directories:
15+
- ${TRAVIS_BUILD_DIR}/opencv
16+
before_script:
17+
- rmdir opencv || true
18+
- if [ ! -d opencv ]; then git clone --single-branch --branch ${OPENCV_BRANCH} https://github.com/opencv/opencv.git; fi
19+
- pushd opencv
20+
- mkdir -p build
21+
- cd build
22+
- cmake .. -DBUILD_LIST=core,imgproc,imgcodecs,calib3d,highgui -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=../install
23+
- cmake --build . --parallel 8 --target install --config Release
24+
- popd
25+
script:
26+
- mkdir -p build
27+
- cd build
28+
- export OPENCV_CONFIG=$(dirname $(find ${TRAVIS_BUILD_DIR}/opencv/install -name OpenCVConfig.cmake | head -n1))
29+
- cmake .. -DOpenCV_DIR=${OPENCV_CONFIG}
30+
- cmake --build . --config Release
31+
- export DEMO=$(find . -type f \( -name demo.exe -o -name demo \) | head -n1)
32+
- export PATH="$PATH:${TRAVIS_BUILD_DIR}/opencv/install/x86/vc15/bin"
33+
- echo | $DEMO

CMakeLists.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.0)
22
project(DBoW2)
33
include(ExternalProject)
44

@@ -12,13 +12,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1212
endif()
1313

1414
if(MSVC)
15-
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
16-
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
17-
else()
18-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
19-
endif()
20-
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
21-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
15+
add_compile_options(/W4)
16+
else()
17+
add_compile_options(-Wall -Wextra -Wpedantic)
2218
endif()
2319

2420
set(HDRS
@@ -42,13 +38,15 @@ if(BUILD_DBoW2)
4238
set(LIB_SHARED "STATIC")
4339
endif(WIN32)
4440
add_library(${PROJECT_NAME} ${LIB_SHARED} ${SRCS})
45-
include_directories(include/DBoW2/)
41+
target_include_directories(${PROJECT_NAME} PUBLIC include/DBoW2/)
4642
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
43+
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
4744
endif(BUILD_DBoW2)
4845

4946
if(BUILD_Demo)
5047
add_executable(demo demo/demo.cpp)
5148
target_link_libraries(demo ${PROJECT_NAME} ${OpenCV_LIBS})
49+
set_target_properties(demo PROPERTIES CXX_STANDARD 11)
5250
file(COPY demo/images DESTINATION ${CMAKE_BINARY_DIR}/)
5351
endif(BUILD_Demo)
5452

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

demo/demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ void testVocCreation(const vector<vector<cv::Mat > > &features)
105105
const int k = 9;
106106
const int L = 3;
107107
const WeightingType weight = TF_IDF;
108-
const ScoringType score = L1_NORM;
108+
const ScoringType scoring = L1_NORM;
109109

110-
OrbVocabulary voc(k, L, weight, score);
110+
OrbVocabulary voc(k, L, weight, scoring);
111111

112112
cout << "Creating a small " << k << "^" << L << " vocabulary..." << endl;
113113
voc.create(features);

include/DBoW2/TemplatedDatabase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ EntryId TemplatedDatabase<TDescriptor, F>::add(const BowVector &v,
436436
EntryId entry_id = m_nentries++;
437437

438438
BowVector::const_iterator vit;
439-
std::vector<unsigned int>::const_iterator iit;
440439

441440
if(m_use_di)
442441
{

src/BowVector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ void BowVector::normalize(LNorm norm_type)
8888
std::ostream& operator<< (std::ostream &out, const BowVector &v)
8989
{
9090
BowVector::const_iterator vit;
91-
std::vector<unsigned int>::const_iterator iit;
9291
unsigned int i = 0;
9392
const unsigned int N = v.size();
9493
for(vit = v.begin(); vit != v.end(); ++vit, ++i)

src/FBrief.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void FBrief::toMat32F(const std::vector<TDescriptor> &descriptors,
9191
float *p = mat.ptr<float>(i);
9292
for(int j = 0; j < FBrief::L; ++j, ++p)
9393
{
94-
*p = (desc[j] ? 1 : 0);
94+
*p = (desc[j] ? 1.f : 0.f);
9595
}
9696
}
9797
}

src/FORB.cpp

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ double FORB::distance(const FORB::TDescriptor &a,
9797
(sizeof(uint64_t) - 1) * CHAR_BIT;
9898
}
9999

100-
return ret;
100+
return static_cast<double>(ret);
101101

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

172172
for(int j = 0; j < C; ++j, p += 8)
173173
{
174-
p[0] = (desc[j] & (1 << 7) ? 1 : 0);
175-
p[1] = (desc[j] & (1 << 6) ? 1 : 0);
176-
p[2] = (desc[j] & (1 << 5) ? 1 : 0);
177-
p[3] = (desc[j] & (1 << 4) ? 1 : 0);
178-
p[4] = (desc[j] & (1 << 3) ? 1 : 0);
179-
p[5] = (desc[j] & (1 << 2) ? 1 : 0);
180-
p[6] = (desc[j] & (1 << 1) ? 1 : 0);
181-
p[7] = desc[j] & (1);
174+
p[0] = (desc[j] & (1 << 7) ? 1.f : 0.f);
175+
p[1] = (desc[j] & (1 << 6) ? 1.f : 0.f);
176+
p[2] = (desc[j] & (1 << 5) ? 1.f : 0.f);
177+
p[3] = (desc[j] & (1 << 4) ? 1.f : 0.f);
178+
p[4] = (desc[j] & (1 << 3) ? 1.f : 0.f);
179+
p[5] = (desc[j] & (1 << 2) ? 1.f : 0.f);
180+
p[6] = (desc[j] & (1 << 1) ? 1.f : 0.f);
181+
p[7] = (desc[j] & (1) ? 1.f : 0.f);
182182
}
183183
}
184184
}
@@ -187,38 +187,7 @@ void FORB::toMat32F(const std::vector<TDescriptor> &descriptors,
187187

188188
void FORB::toMat32F(const cv::Mat &descriptors, cv::Mat &mat)
189189
{
190-
191190
descriptors.convertTo(mat, CV_32F);
192-
return;
193-
194-
if(descriptors.empty())
195-
{
196-
mat.release();
197-
return;
198-
}
199-
200-
const int N = descriptors.rows;
201-
const int C = descriptors.cols;
202-
203-
mat.create(N, FORB::L*8, CV_32F);
204-
float *p = mat.ptr<float>(); // p[i] == 1 or 0
205-
206-
const unsigned char *desc = descriptors.ptr<unsigned char>();
207-
208-
for(int i = 0; i < N; ++i, desc += C)
209-
{
210-
for(int j = 0; j < C; ++j, p += 8)
211-
{
212-
p[0] = (desc[j] & (1 << 7) ? 1 : 0);
213-
p[1] = (desc[j] & (1 << 6) ? 1 : 0);
214-
p[2] = (desc[j] & (1 << 5) ? 1 : 0);
215-
p[3] = (desc[j] & (1 << 4) ? 1 : 0);
216-
p[4] = (desc[j] & (1 << 3) ? 1 : 0);
217-
p[5] = (desc[j] & (1 << 2) ? 1 : 0);
218-
p[6] = (desc[j] & (1 << 1) ? 1 : 0);
219-
p[7] = desc[j] & (1);
220-
}
221-
}
222191
}
223192

224193
// --------------------------------------------------------------------------

0 commit comments

Comments
 (0)