use image_similarity::store::DescriptorStore; use image_similarity::descriptors::{Descriptor, DCT}; use log::info; use std::path::PathBuf; use std::thread; use clap::Parser; #[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(descriptor: T, input_path: PathBuf, save_path: PathBuf) -> DescriptorStore { let mut store = DescriptorStore::new() .with_file(save_path); info!("{}", store); store.insert_directory(input_path, descriptor); info!("{}", store); store.save().expect("Error saving"); store } struct StoreParams { desc: DCT, input_path: PathBuf, save_path: PathBuf, } fn main() { env_logger::init(); let cfg = Cfg::parse(); let mut threads = vec![]; let params = vec![ StoreParams { desc: DCT::new().with_quality(50), input_path: cfg.path.clone(), save_path: "dct50.messagepack".into(), }, // StoreParams { // desc: DCT::new().with_quality(30), // input_path: cfg.path.clone(), // save_path: "dct30.messagepack".into(), // }, // StoreParams { // desc: DCT::new().with_quality(10), // input_path: cfg.path.clone(), // save_path: "dct10.messagepack".into(), // }, ]; // let dct_50 = // DCT::new() // .with_quality(50); // let dct_30 = // DCT::new() // .with_quality(30); // let dct_10 = // DCT::new() // .with_quality(10); //let (tx, rx) = mpsc::channel::(); for param in params { threads.push( thread::spawn(move || { let store = make_store(param.desc, param.input_path, param.save_path); store.print_most_dups(); //tx.send(store).unwrap(); }) ) } // let path_50 = cfg.path.clone(); // threads.push( // thread::spawn(move || { // let store = make_store(dct_50, path_50, "dct50.messagepack".into()); // tx.send(store).expect("Thread send result error"); // }) // ); // let path_30 = cfg.path.clone(); // threads.push( // thread::spawn(move || { // dct_30_store = make_store(dct_30, path_30, "dct30.messagepack".into()); // }) // ); // let path_10 = cfg.path.clone(); // threads.push( // thread::spawn(move || { // dct_50_store = make_store(dct_10, path_10, "dct10.messagepack".into()); // }) // ); for thread in threads { let _ = thread.join(); } }