Skip to content

Commit f49263d

Browse files
authored
Merge branch 'develop' into dev/cleaning
2 parents 85946b3 + 3e624d2 commit f49263d

File tree

9 files changed

+159
-115
lines changed

9 files changed

+159
-115
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ install:
6161
- wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/$CUDA_REPO_PKG
6262
- sudo dpkg -i $CUDA_REPO_PKG
6363
- rm ${CUDA_REPO_PKG}
64-
- sudo apt-get -y update
65-
- sudo apt-get install -y --no-install-recommends cuda-core-$CUDA_PKG_VERSION cuda-cudart-dev-$CUDA_PKG_VERSION cuda-cublas-dev-$CUDA_PKG_VERSION cuda-curand-dev-$CUDA_PKG_VERSION
64+
- travis_retry sudo apt-get -y update
65+
- travis_retry sudo apt-get install -y --no-install-recommends cuda-core-$CUDA_PKG_VERSION cuda-cudart-dev-$CUDA_PKG_VERSION cuda-cublas-dev-$CUDA_PKG_VERSION cuda-curand-dev-$CUDA_PKG_VERSION
6666
- sudo ln -s /usr/local/cuda-${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} /usr/local/cuda
6767

6868
before_script:

src/application/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.12)
2-
project(PopsiftDemo)
2+
project(PopsiftDemo LANGUAGES CXX)
33

44
if(TARGET popsift)
55
# when compiled in the repository the target is already defined
@@ -13,9 +13,12 @@ else()
1313
message(STATUS "Found PopSift, version: ${PopSift_VERSION}")
1414
endif()
1515

16-
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options system filesystem)
1716
find_package(DevIL COMPONENTS IL ILU) # yields IL_FOUND, IL_LIBRARIES, IL_INCLUDE_DIR
1817

18+
set(Boost_INCLUDE_DIRS "")
19+
set(Boost_LIBRARIES "")
20+
find_package(Boost 1.53.0 REQUIRED COMPONENTS filesystem program_options)
21+
1922
set(PD_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
2023
set(PD_LINK_LIBS ${Boost_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY})
2124

src/application/main.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ static void collectFilenames( list<string>& inputFiles, const boost::filesystem:
172172

173173
SiftJob* process_image( const string& inputFile, PopSift& PopSift )
174174
{
175-
int w;
176-
int h;
177175
SiftJob* job;
178176
unsigned char* image_data;
179177

@@ -197,8 +195,8 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
197195
cerr << "Failed converting image " << inputFile << " to unsigned greyscale image" << endl;
198196
exit( -1 );
199197
}
200-
w = img.Width();
201-
h = img.Height();
198+
const auto w = img.Width();
199+
const auto h = img.Height();
202200
cout << "Loading " << w << " x " << h << " image " << inputFile << endl;
203201

204202
image_data = img.GetData();
@@ -213,10 +211,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
213211
#endif
214212
{
215213
nvtxRangePushA( "load and convert image - pgmread" );
216-
214+
int w{};
215+
int h{};
217216
image_data = readPGMfile( inputFile, w, h );
218-
if( image_data == 0 ) {
219-
exit( -1 );
217+
if( image_data == nullptr ) {
218+
exit( EXIT_FAILURE );
220219
}
221220

222221
nvtxRangePop( ); // "load and convert image - pgmread"
@@ -230,7 +229,7 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
230229
}
231230
else
232231
{
233-
float* f_image_data = new float [w * h];
232+
auto f_image_data = new float [w * h];
234233
for( int i=0; i<w*h; i++ )
235234
{
236235
f_image_data[i] = float( image_data[i] ) / 256.0f;
@@ -271,8 +270,7 @@ int main(int argc, char **argv)
271270

272271
popsift::Config config;
273272
list<string> inputFiles;
274-
string inputFile = "";
275-
const char* appName = argv[0];
273+
string inputFile{};
276274

277275
std::cout << "PopSift version: " << POPSIFT_VERSION_STRING << std::endl;
278276

@@ -282,7 +280,7 @@ int main(int argc, char **argv)
282280
}
283281
catch (std::exception& e) {
284282
std::cout << e.what() << std::endl;
285-
exit(1);
283+
return EXIT_FAILURE;
286284
}
287285

288286
if( boost::filesystem::exists( inputFile ) ) {
@@ -291,13 +289,13 @@ int main(int argc, char **argv)
291289
collectFilenames( inputFiles, inputFile );
292290
if( inputFiles.empty() ) {
293291
cerr << "No files in directory, nothing to do" << endl;
294-
exit( 0 );
292+
return EXIT_SUCCESS;
295293
}
296294
} else if( boost::filesystem::is_regular_file( inputFile ) ) {
297295
inputFiles.push_back( inputFile );
298296
} else {
299297
cout << "Input file is neither regular file nor directory, nothing to do" << endl;
300-
exit( -1 );
298+
return EXIT_FAILURE;
301299
}
302300
}
303301

@@ -310,10 +308,9 @@ int main(int argc, char **argv)
310308
float_mode ? PopSift::FloatImages : PopSift::ByteImages );
311309

312310
std::queue<SiftJob*> jobs;
313-
for( auto it = inputFiles.begin(); it!=inputFiles.end(); it++ ) {
314-
inputFile = it->c_str();
315-
316-
SiftJob* job = process_image( inputFile, PopSift );
311+
for(const auto& currFile : inputFiles)
312+
{
313+
SiftJob* job = process_image( currFile, PopSift );
317314
jobs.push( job );
318315
}
319316

@@ -328,5 +325,7 @@ int main(int argc, char **argv)
328325
}
329326

330327
PopSift.uninit( );
328+
329+
return EXIT_SUCCESS;
331330
}
332331

src/application/match.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040

4141
using namespace std;
4242

43-
static bool print_dev_info = false;
44-
static bool print_time_info = false;
45-
static bool write_as_uchar = false;
46-
static bool dont_write = false;
47-
static bool pgmread_loading = false;
43+
static bool print_dev_info {false};
44+
static bool print_time_info {false};
45+
static bool write_as_uchar {false};
46+
static bool dont_write {false};
47+
static bool pgmread_loading {false};
4848

4949
static void parseargs(int argc, char** argv, popsift::Config& config, string& lFile, string& rFile) {
5050
using namespace boost::program_options;
@@ -169,8 +169,6 @@ static void collectFilenames( list<string>& inputFiles, const boost::filesystem:
169169

170170
SiftJob* process_image( const string& inputFile, PopSift& PopSift )
171171
{
172-
int w;
173-
int h;
174172
unsigned char* image_data;
175173
SiftJob* job;
176174

@@ -187,8 +185,8 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
187185
cerr << "Failed converting image " << inputFile << " to unsigned greyscale image" << endl;
188186
exit( -1 );
189187
}
190-
w = img.Width();
191-
h = img.Height();
188+
const auto w = img.Width();
189+
const auto h = img.Height();
192190
cout << "Loading " << w << " x " << h << " image " << inputFile << endl;
193191
image_data = img.GetData();
194192

@@ -202,9 +200,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
202200
else
203201
#endif
204202
{
203+
int h{};
204+
int w{};
205205
image_data = readPGMfile( inputFile, w, h );
206-
if( image_data == 0 ) {
207-
exit( -1 );
206+
if( image_data == nullptr ) {
207+
exit( EXIT_FAILURE );
208208
}
209209

210210
nvtxRangePop( );
@@ -223,9 +223,8 @@ int main(int argc, char **argv)
223223
cudaDeviceReset();
224224

225225
popsift::Config config;
226-
string lFile = "";
227-
string rFile = "";
228-
const char* appName = argv[0];
226+
string lFile{};
227+
string rFile{};
229228

230229
std::cout << "PopSift version: " << POPSIFT_VERSION_STRING << std::endl;
231230

@@ -235,20 +234,20 @@ int main(int argc, char **argv)
235234
}
236235
catch (std::exception& e) {
237236
std::cout << e.what() << std::endl;
238-
exit(1);
237+
return EXIT_SUCCESS;
239238
}
240239

241240
if( boost::filesystem::exists( lFile ) ) {
242241
if( not boost::filesystem::is_regular_file( lFile ) ) {
243242
cout << "Input file " << lFile << " is not a regular file, nothing to do" << endl;
244-
exit( -1 );
243+
return EXIT_FAILURE;
245244
}
246245
}
247246

248247
if( boost::filesystem::exists( rFile ) ) {
249248
if( not boost::filesystem::is_regular_file( rFile ) ) {
250249
cout << "Input file " << rFile << " is not a regular file, nothing to do" << endl;
251-
exit( -1 );
250+
return EXIT_FAILURE;
252251
}
253252
}
254253

@@ -275,5 +274,7 @@ int main(int argc, char **argv)
275274
delete rFeatures;
276275

277276
PopSift.uninit( );
277+
278+
return EXIT_SUCCESS;
278279
}
279280

0 commit comments

Comments
 (0)