updated logging
This commit is contained in:
@@ -18,6 +18,7 @@ impl Cfg{
|
||||
}
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
//Init all descriptors:
|
||||
let desc = DCT::new().with_quality(50);
|
||||
|
||||
+4
-2
@@ -1,9 +1,11 @@
|
||||
use image_similarity::store::DescriptorStore;
|
||||
use image_similarity::descriptors::{DCT, Descriptor};
|
||||
use image_similarity::descriptors::DCT;
|
||||
use log::info;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
let mut store = DescriptorStore::new();
|
||||
let desc = DCT::new().with_quality(30);
|
||||
store.insert_directory("img", desc);
|
||||
print!("{}", store);
|
||||
info!("{}", store);
|
||||
}
|
||||
|
||||
+4
-2
@@ -3,6 +3,7 @@ use crate::descriptors::Descriptor;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::fmt;
|
||||
use log::info;
|
||||
|
||||
pub struct DescriptorStore {
|
||||
map: HashMap<String, u64>
|
||||
@@ -39,6 +40,7 @@ impl DescriptorStore {
|
||||
let file = node.expect("Error walking directory");
|
||||
let name = file.file_name().into_string().expect("Issue with filename");
|
||||
if !self.contains(name.to_string()) {
|
||||
info!("Processing {}", name);
|
||||
let img = image::open(file.path()).expect("Unable to open file");
|
||||
let phash = desc.describe(img);
|
||||
self.map.insert(name, phash);
|
||||
@@ -51,9 +53,9 @@ impl fmt::Display for DescriptorStore {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut output = String::new();
|
||||
for (key, val) in self.map.iter() {
|
||||
let entry = format!("{key: >15}: {val}\t {val:b}\n");
|
||||
let entry = format!("{key: >15}: {val}\t {val:064b}\n");
|
||||
output.push_str(&entry);
|
||||
}
|
||||
write!(f, "{}", output)
|
||||
write!(f, "DescriptorStore:\n{}", output)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user