inverted hashmap, added bktree

This commit is contained in:
2024-05-14 14:37:33 +02:00
parent 335f7e7d8c
commit 4327fe8c7c
5 changed files with 140 additions and 20 deletions
+42
View File
@@ -0,0 +1,42 @@
//use image_similarity::descriptors::dct::DCT;
use image_similarity::descriptors::{DCT, Descriptor};
use image_similarity::store::DescriptorStore;
use std::env;
use log::{info, debug, error};
struct Cfg {
path: String
}
impl Cfg{
fn load(args: &[String]) -> Result<Cfg, &'static str> {
if args.len() < 2 {
return Err("Filename argument required");
}
let path = args[1].clone();
Ok(Cfg { path })
}
}
fn main() {
env_logger::init();
//Init all descriptors:
let desc = DCT::new().with_quality(50);
let args: Vec<String> = env::args().collect();
let cfg = Cfg::load(&args)
.expect("Error loading config");
let img = image::open(cfg.path)
.expect("Unable to open file");
let store =
DescriptorStore::new()
.with_file("store.messagepack");
//info!("{}", store);
let phash: u64 = desc.describe(&img);
info!("Phash integer:\n{phash}");
info!("Phash binary:\n{phash:064b}");
store.knn(phash, 4);
}