#include #include #include #include #include extern "C" { #include } #include #include #include using namespace std; namespace fs = boost::filesystem; int main(){ av_register_all(); string database_directory = "database"; string filename = "needle.jpg"; image_database db; fs::path directory(database_directory); fs::directory_iterator eod; for(fs::directory_iterator it(directory); it != eod; ++it){ auto && path = it->path(); auto 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 index = db.nearest_image(open_as_rgb(filename)); cout << colors::green("match: ") << db.filename(index) << endl; } }