refactors and new dct binary
This commit is contained in:
+50
-8
@@ -1,17 +1,59 @@
|
||||
use image_similarity::store::DescriptorStore;
|
||||
use image_similarity::descriptors::DCT;
|
||||
use image_similarity::descriptors::{Descriptor, DCT};
|
||||
use log::info;
|
||||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
use clap::Parser;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Cfg {
|
||||
/// Path that contains the input images. Will not traverse directories.
|
||||
path: PathBuf
|
||||
}
|
||||
|
||||
fn make_store<T: Descriptor>(descriptor: T, input_path: PathBuf, save_path: PathBuf) -> () {
|
||||
let mut store =
|
||||
DescriptorStore::new()
|
||||
.with_file("store.messagepack");
|
||||
.with_file(save_path);
|
||||
info!("{}", store);
|
||||
let desc =
|
||||
DCT::new()
|
||||
.with_quality(30);
|
||||
store.insert_directory("data", desc);
|
||||
store.insert_directory(input_path, descriptor);
|
||||
info!("{}", store);
|
||||
store.save().expect("Error saving");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
let cfg = Cfg::parse();
|
||||
|
||||
let mut threads = vec![];
|
||||
|
||||
let dct_50 =
|
||||
DCT::new()
|
||||
.with_quality(50);
|
||||
let dct_30 =
|
||||
DCT::new()
|
||||
.with_quality(30);
|
||||
let dct_10 =
|
||||
DCT::new()
|
||||
.with_quality(10);
|
||||
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_50, "data".into(), "dct50.messagepack".into());
|
||||
})
|
||||
);
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_30, "data".into(), "dct30.messagepack".into());
|
||||
})
|
||||
);
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_10, "data".into(), "dct10.messagepack".into());
|
||||
})
|
||||
);
|
||||
for thread in threads {
|
||||
let _ = thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user