Skip to content

Commit 1416604

Browse files
authored
Merge pull request #65 from alicevision/cmake/fixBoost1.70
[cmake] fix for Boost 1.70
2 parents d143285 + 3b5f80d commit 1416604

4 files changed

Lines changed: 77 additions & 71 deletions

File tree

src/application/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ else()
1212
find_package(PopSift CONFIG REQUIRED)
1313
endif()
1414

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

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

src/application/main.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <string>
1212
#include <cmath>
1313
#include <iomanip>
14-
#include <stdlib.h>
14+
#include <cstdlib>
1515
#include <stdexcept>
1616
#include <list>
1717
#include <string>
@@ -170,8 +170,6 @@ static void collectFilenames( list<string>& inputFiles, const boost::filesystem:
170170

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

@@ -195,8 +193,8 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
195193
cerr << "Failed converting image " << inputFile << " to unsigned greyscale image" << endl;
196194
exit( -1 );
197195
}
198-
w = img.Width();
199-
h = img.Height();
196+
const auto w = img.Width();
197+
const auto h = img.Height();
200198
cout << "Loading " << w << " x " << h << " image " << inputFile << endl;
201199

202200
image_data = img.GetData();
@@ -211,10 +209,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
211209
#endif
212210
{
213211
nvtxRangePushA( "load and convert image - pgmread" );
214-
212+
int w{};
213+
int h{};
215214
image_data = readPGMfile( inputFile, w, h );
216-
if( image_data == 0 ) {
217-
exit( -1 );
215+
if( image_data == nullptr ) {
216+
exit( EXIT_FAILURE );
218217
}
219218

220219
nvtxRangePop( ); // "load and convert image - pgmread"
@@ -228,7 +227,7 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
228227
}
229228
else
230229
{
231-
float* f_image_data = new float [w * h];
230+
auto f_image_data = new float [w * h];
232231
for( int i=0; i<w*h; i++ )
233232
{
234233
f_image_data[i] = float( image_data[i] ) / 256.0f;
@@ -269,16 +268,15 @@ int main(int argc, char **argv)
269268

270269
popsift::Config config;
271270
list<string> inputFiles;
272-
string inputFile = "";
273-
const char* appName = argv[0];
271+
string inputFile{};
274272

275273
try {
276274
parseargs( argc, argv, config, inputFile ); // Parse command line
277275
std::cout << inputFile << std::endl;
278276
}
279277
catch (std::exception& e) {
280278
std::cout << e.what() << std::endl;
281-
exit(1);
279+
return EXIT_FAILURE;
282280
}
283281

284282
if( boost::filesystem::exists( inputFile ) ) {
@@ -287,13 +285,13 @@ int main(int argc, char **argv)
287285
collectFilenames( inputFiles, inputFile );
288286
if( inputFiles.empty() ) {
289287
cerr << "No files in directory, nothing to do" << endl;
290-
exit( 0 );
288+
return EXIT_SUCCESS;
291289
}
292290
} else if( boost::filesystem::is_regular_file( inputFile ) ) {
293291
inputFiles.push_back( inputFile );
294292
} else {
295293
cout << "Input file is neither regular file nor directory, nothing to do" << endl;
296-
exit( -1 );
294+
return EXIT_FAILURE;
297295
}
298296
}
299297

@@ -306,10 +304,9 @@ int main(int argc, char **argv)
306304
float_mode ? PopSift::FloatImages : PopSift::ByteImages );
307305

308306
std::queue<SiftJob*> jobs;
309-
for( auto it = inputFiles.begin(); it!=inputFiles.end(); it++ ) {
310-
inputFile = it->c_str();
311-
312-
SiftJob* job = process_image( inputFile, PopSift );
307+
for(const auto& currFile : inputFiles)
308+
{
309+
SiftJob* job = process_image( currFile, PopSift );
313310
jobs.push( job );
314311
}
315312

@@ -324,5 +321,7 @@ int main(int argc, char **argv)
324321
}
325322

326323
PopSift.uninit( );
324+
325+
return EXIT_SUCCESS;
327326
}
328327

src/application/match.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <string>
1212
#include <cmath>
1313
#include <iomanip>
14-
#include <stdlib.h>
14+
#include <cstdlib>
1515
#include <stdexcept>
1616
#include <list>
1717
#include <string>
@@ -38,11 +38,11 @@
3838

3939
using namespace std;
4040

41-
static bool print_dev_info = false;
42-
static bool print_time_info = false;
43-
static bool write_as_uchar = false;
44-
static bool dont_write = false;
45-
static bool pgmread_loading = false;
41+
static bool print_dev_info {false};
42+
static bool print_time_info {false};
43+
static bool write_as_uchar {false};
44+
static bool dont_write {false};
45+
static bool pgmread_loading {false};
4646

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

168168
SiftJob* process_image( const string& inputFile, PopSift& PopSift )
169169
{
170-
int w;
171-
int h;
172170
unsigned char* image_data;
173171
SiftJob* job;
174172

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

@@ -200,9 +198,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
200198
else
201199
#endif
202200
{
201+
int h{};
202+
int w{};
203203
image_data = readPGMfile( inputFile, w, h );
204-
if( image_data == 0 ) {
205-
exit( -1 );
204+
if( image_data == nullptr ) {
205+
exit( EXIT_FAILURE );
206206
}
207207

208208
nvtxRangePop( );
@@ -221,30 +221,29 @@ int main(int argc, char **argv)
221221
cudaDeviceReset();
222222

223223
popsift::Config config;
224-
string lFile = "";
225-
string rFile = "";
226-
const char* appName = argv[0];
224+
string lFile{};
225+
string rFile{};
227226

228227
try {
229228
parseargs( argc, argv, config, lFile, rFile ); // Parse command line
230229
std::cout << lFile << " <-> " << rFile << std::endl;
231230
}
232231
catch (std::exception& e) {
233232
std::cout << e.what() << std::endl;
234-
exit(1);
233+
return EXIT_SUCCESS;
235234
}
236235

237236
if( boost::filesystem::exists( lFile ) ) {
238237
if( not boost::filesystem::is_regular_file( lFile ) ) {
239238
cout << "Input file " << lFile << " is not a regular file, nothing to do" << endl;
240-
exit( -1 );
239+
return EXIT_FAILURE;
241240
}
242241
}
243242

244243
if( boost::filesystem::exists( rFile ) ) {
245244
if( not boost::filesystem::is_regular_file( rFile ) ) {
246245
cout << "Input file " << rFile << " is not a regular file, nothing to do" << endl;
247-
exit( -1 );
246+
return EXIT_FAILURE;
248247
}
249248
}
250249

@@ -271,5 +270,7 @@ int main(int argc, char **argv)
271270
delete rFeatures;
272271

273272
PopSift.uninit( );
273+
274+
return EXIT_SUCCESS;
274275
}
275276

0 commit comments

Comments
 (0)