pass image as reference
This commit is contained in:
@@ -31,7 +31,7 @@ fn main() {
|
||||
|
||||
let img = image::open(cfg.path)
|
||||
.expect("Unable to open file");
|
||||
let phash: u64 = desc.describe(img);
|
||||
let phash: u64 = desc.describe(&img);
|
||||
debug!("Phash integer:\n{phash}");
|
||||
debug!("Phash binary:\n{phash:b}");
|
||||
let output = URL_SAFE_NO_PAD.encode(phash.to_be_bytes());
|
||||
|
||||
@@ -101,7 +101,7 @@ impl DCT {
|
||||
}
|
||||
|
||||
impl Descriptor for DCT {
|
||||
fn describe(&self, img: image::DynamicImage) -> u64 {
|
||||
fn describe(&self, img: &image::DynamicImage) -> u64 {
|
||||
let resized = self.resize(img);
|
||||
let mut dct_values = self.dct(&resized);
|
||||
debug!("DCT-coefficients:\n {}", print_matrix(dct_values));
|
||||
|
||||
@@ -2,10 +2,10 @@ pub trait Descriptor {
|
||||
fn info(&self) -> String {
|
||||
"Descriptor".to_string()
|
||||
}
|
||||
fn resize(&self, img: image::DynamicImage) -> image::DynamicImage {
|
||||
fn resize(&self, img: &image::DynamicImage) -> image::DynamicImage {
|
||||
img.grayscale().thumbnail_exact(8, 8)
|
||||
}
|
||||
fn describe(&self, img: image::DynamicImage) -> u64;
|
||||
fn describe(&self, img: &image::DynamicImage) -> u64;
|
||||
fn distance(&self, a: u64, b: u64) -> u64 {
|
||||
(a^b).count_ones().into()
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ impl DescriptorStore {
|
||||
continue
|
||||
}
|
||||
};
|
||||
let phash = desc.describe(img);
|
||||
let phash = desc.describe(&img);
|
||||
self.map.insert(name, phash);
|
||||
} else {
|
||||
debug!("{} already known, skipping.", name);
|
||||
|
||||
Reference in New Issue
Block a user