Browse Source

Adds program options and also adds generate_database binary

master
Joshua Moerman 10 years ago
parent
commit
6ee3eb6cfb
  1. 39
      src/generate_database.cpp
  2. 18
      src/main.cpp

39
src/generate_database.cpp

@ -0,0 +1,39 @@
#include <fingerprints.hpp>
#include <read_database.hpp>
#include <utilities.hpp>
extern "C" {
#include <libavformat/avformat.h>
}
#include <iostream>
using namespace std;
template <typename Metric>
void generate(const string & database_directory) {
auto const db = read_database<Metric>(database_directory);
cout << colors::green("Read database: ") << db.size() << endl;
}
int main(int argc, char * argv[]) {
if (argc != 3) {
cerr << "usage: main <dir> <type>\n";
return 1;
}
av_register_all();
av_log_set_level(AV_LOG_QUIET);
string const database_directory = argv[1];
string const type = argv[2];
if (type == "rgb") {
generate<fingerprints::rgb>(database_directory);
} else if (type == "wvlt_rgb") {
generate<fingerprints::wvlt_rgb>(database_directory);
} else {
cerr << "No known type given\n";
return 1;
}
}

18
src/main.cpp

@ -10,7 +10,6 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
extern "C" { extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
} }
@ -74,16 +73,21 @@ static void save_mozaic(Mozaiq const & mozaic, string filename){
encode_as_jpg(frame, filename); encode_as_jpg(frame, filename);
} }
int main(){ int main(int argc, char *argv[]){
if(argc != 6){
cerr << "usage: main <dir> <photo> <output> <h tiles> <v tiles>\n";
return 1;
}
av_register_all(); av_register_all();
av_log_set_level(AV_LOG_QUIET); av_log_set_level(AV_LOG_QUIET);
// TODO: use boost::program_options // TODO: use boost::program_options
string const database_directory = "basbram"; string const database_directory = argv[1];
string const filename = "basbram.jpg"; string const filename = argv[2];
string const output = "output/basbram.jpg"; string const output = argv[3];
int const h_tiles = 4*4; int const h_tiles = stoi(argv[4]);
int const v_tiles = 3*4; int const v_tiles = stoi(argv[5]);
auto const db = read_database<Metric>(database_directory); auto const db = read_database<Metric>(database_directory);
cout << colors::green("Read database: ") << db.size() << endl; cout << colors::green("Read database: ") << db.size() << endl;

Loading…
Cancel
Save