You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
#include <image_io.hpp>
|
|
#include <wavelet.hpp>
|
|
#include <image_database.hpp>
|
|
#include <fingerprints.hpp>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
extern "C" {
|
|
#include <libavformat/avformat.h>
|
|
}
|
|
|
|
#include <iostream>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
namespace fs = boost::filesystem;
|
|
|
|
int main(){
|
|
av_register_all();
|
|
|
|
string const database_directory = "database";
|
|
string const filename = "needle.jpg";
|
|
|
|
image_database<rgb_wavelet_coefficients> db;
|
|
|
|
fs::path const directory(database_directory);
|
|
fs::directory_iterator eod;
|
|
for(fs::directory_iterator it(directory); it != eod; ++it){
|
|
auto const path = it->path();
|
|
auto const ext = path.extension();
|
|
if(ext != ".png" && ext != ".jpg") continue;
|
|
|
|
cout << colors::green("adding: ") << path.string() << endl;
|
|
db.add(path.string());
|
|
}
|
|
|
|
while(true){
|
|
cout << "****************" << endl;
|
|
cout << colors::green("database: ") << db.size() << endl;
|
|
cout << colors::green("press enter to search match for: ") << filename << endl;
|
|
cin.ignore();
|
|
auto const index = db.nearest_image(open_image(filename));
|
|
cout << colors::green("match: ") << db.filename(index) << endl;
|
|
}
|
|
}
|
|
|
|
|