Skip to content

Commit

Permalink
Merge pull request #65 from alicevision/cmake/fixBoost1.70
Browse files Browse the repository at this point in the history
[cmake] fix for Boost 1.70
  • Loading branch information
fabiencastan committed Feb 5, 2020
2 parents d143285 + 3b5f80d commit 1416604
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 71 deletions.
5 changes: 4 additions & 1 deletion src/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ else()
find_package(PopSift CONFIG REQUIRED)
endif()

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

set(Boost_INCLUDE_DIRS "")
set(Boost_LIBRARIES "")
find_package(Boost 1.53.0 REQUIRED COMPONENTS filesystem program_options)

set(PD_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
set(PD_LINK_LIBS ${Boost_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY})

Expand Down
35 changes: 17 additions & 18 deletions src/application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <cmath>
#include <iomanip>
#include <stdlib.h>
#include <cstdlib>
#include <stdexcept>
#include <list>
#include <string>
Expand Down Expand Up @@ -170,8 +170,6 @@ static void collectFilenames( list<string>& inputFiles, const boost::filesystem:

SiftJob* process_image( const string& inputFile, PopSift& PopSift )
{
int w;
int h;
SiftJob* job;
unsigned char* image_data;

Expand All @@ -195,8 +193,8 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
cerr << "Failed converting image " << inputFile << " to unsigned greyscale image" << endl;
exit( -1 );
}
w = img.Width();
h = img.Height();
const auto w = img.Width();
const auto h = img.Height();
cout << "Loading " << w << " x " << h << " image " << inputFile << endl;

image_data = img.GetData();
Expand All @@ -211,10 +209,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
#endif
{
nvtxRangePushA( "load and convert image - pgmread" );

int w{};
int h{};
image_data = readPGMfile( inputFile, w, h );
if( image_data == 0 ) {
exit( -1 );
if( image_data == nullptr ) {
exit( EXIT_FAILURE );
}

nvtxRangePop( ); // "load and convert image - pgmread"
Expand All @@ -228,7 +227,7 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
}
else
{
float* f_image_data = new float [w * h];
auto f_image_data = new float [w * h];
for( int i=0; i<w*h; i++ )
{
f_image_data[i] = float( image_data[i] ) / 256.0f;
Expand Down Expand Up @@ -269,16 +268,15 @@ int main(int argc, char **argv)

popsift::Config config;
list<string> inputFiles;
string inputFile = "";
const char* appName = argv[0];
string inputFile{};

try {
parseargs( argc, argv, config, inputFile ); // Parse command line
std::cout << inputFile << std::endl;
}
catch (std::exception& e) {
std::cout << e.what() << std::endl;
exit(1);
return EXIT_FAILURE;
}

if( boost::filesystem::exists( inputFile ) ) {
Expand All @@ -287,13 +285,13 @@ int main(int argc, char **argv)
collectFilenames( inputFiles, inputFile );
if( inputFiles.empty() ) {
cerr << "No files in directory, nothing to do" << endl;
exit( 0 );
return EXIT_SUCCESS;
}
} else if( boost::filesystem::is_regular_file( inputFile ) ) {
inputFiles.push_back( inputFile );
} else {
cout << "Input file is neither regular file nor directory, nothing to do" << endl;
exit( -1 );
return EXIT_FAILURE;
}
}

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

std::queue<SiftJob*> jobs;
for( auto it = inputFiles.begin(); it!=inputFiles.end(); it++ ) {
inputFile = it->c_str();

SiftJob* job = process_image( inputFile, PopSift );
for(const auto& currFile : inputFiles)
{
SiftJob* job = process_image( currFile, PopSift );
jobs.push( job );
}

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

PopSift.uninit( );

return EXIT_SUCCESS;
}

37 changes: 19 additions & 18 deletions src/application/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <cmath>
#include <iomanip>
#include <stdlib.h>
#include <cstdlib>
#include <stdexcept>
#include <list>
#include <string>
Expand All @@ -38,11 +38,11 @@

using namespace std;

static bool print_dev_info = false;
static bool print_time_info = false;
static bool write_as_uchar = false;
static bool dont_write = false;
static bool pgmread_loading = false;
static bool print_dev_info {false};
static bool print_time_info {false};
static bool write_as_uchar {false};
static bool dont_write {false};
static bool pgmread_loading {false};

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

SiftJob* process_image( const string& inputFile, PopSift& PopSift )
{
int w;
int h;
unsigned char* image_data;
SiftJob* job;

Expand All @@ -185,8 +183,8 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
cerr << "Failed converting image " << inputFile << " to unsigned greyscale image" << endl;
exit( -1 );
}
w = img.Width();
h = img.Height();
const auto w = img.Width();
const auto h = img.Height();
cout << "Loading " << w << " x " << h << " image " << inputFile << endl;
image_data = img.GetData();

Expand All @@ -200,9 +198,11 @@ SiftJob* process_image( const string& inputFile, PopSift& PopSift )
else
#endif
{
int h{};
int w{};
image_data = readPGMfile( inputFile, w, h );
if( image_data == 0 ) {
exit( -1 );
if( image_data == nullptr ) {
exit( EXIT_FAILURE );
}

nvtxRangePop( );
Expand All @@ -221,30 +221,29 @@ int main(int argc, char **argv)
cudaDeviceReset();

popsift::Config config;
string lFile = "";
string rFile = "";
const char* appName = argv[0];
string lFile{};
string rFile{};

try {
parseargs( argc, argv, config, lFile, rFile ); // Parse command line
std::cout << lFile << " <-> " << rFile << std::endl;
}
catch (std::exception& e) {
std::cout << e.what() << std::endl;
exit(1);
return EXIT_SUCCESS;
}

if( boost::filesystem::exists( lFile ) ) {
if( not boost::filesystem::is_regular_file( lFile ) ) {
cout << "Input file " << lFile << " is not a regular file, nothing to do" << endl;
exit( -1 );
return EXIT_FAILURE;
}
}

if( boost::filesystem::exists( rFile ) ) {
if( not boost::filesystem::is_regular_file( rFile ) ) {
cout << "Input file " << rFile << " is not a regular file, nothing to do" << endl;
exit( -1 );
return EXIT_FAILURE;
}
}

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

PopSift.uninit( );

return EXIT_SUCCESS;
}

Loading

0 comments on commit 1416604

Please sign in to comment.