inverted hashmap, added bktree
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user