|
|
@ -17,8 +17,8 @@ use std::path::Path; |
|
|
|
|
|
|
|
use cache::Cache;
|
|
|
|
|
|
|
|
pub mod hash;
|
|
|
|
pub mod cache;
|
|
|
|
pub mod hash;
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct PIHash<'a> {
|
|
|
@ -49,40 +49,44 @@ impl<'a> PIHash<'a> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_perceptual_hash(&self,
|
|
|
|
path: &Path,
|
|
|
|
precision: &hash::Precision,
|
|
|
|
hash_type: &hash::HashType)
|
|
|
|
-> u64 {
|
|
|
|
pub fn get_perceptual_hash(
|
|
|
|
&self,
|
|
|
|
path: &Path,
|
|
|
|
precision: &hash::Precision,
|
|
|
|
hash_type: &hash::HashType,
|
|
|
|
) -> u64 {
|
|
|
|
hash::get_perceptual_hash(&path, &precision, &hash_type, &self.cache)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_phashes(&self, path: &'a Path) -> hash::PerceptualHashes {
|
|
|
|
hash::get_perceptual_hashes(&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&self.cache)
|
|
|
|
hash::get_perceptual_hashes(&path, &hash::Precision::Medium, &self.cache)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn get_ahash(&self, path: &Path) -> u64 {
|
|
|
|
hash::get_perceptual_hash(&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::AHash,
|
|
|
|
&self.cache)
|
|
|
|
hash::get_perceptual_hash(
|
|
|
|
&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::AHash,
|
|
|
|
&self.cache,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_dhash(&self, path: &Path) -> u64 {
|
|
|
|
hash::get_perceptual_hash(&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::DHash,
|
|
|
|
&self.cache)
|
|
|
|
hash::get_perceptual_hash(
|
|
|
|
&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::DHash,
|
|
|
|
&self.cache,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_phash(&self, path: &Path) -> u64 {
|
|
|
|
hash::get_perceptual_hash(&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash,
|
|
|
|
&self.cache)
|
|
|
|
hash::get_perceptual_hash(
|
|
|
|
&path,
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash,
|
|
|
|
&self.cache,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -125,9 +129,11 @@ pub extern "C" fn ext_get_ahash(lib: &PIHash, path_char: *const libc::c_char) -> |
|
|
|
let image_path = match path_str.to_str() {
|
|
|
|
Ok(result) => result,
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes()));
|
|
|
|
println!(
|
|
|
|
"Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes())
|
|
|
|
);
|
|
|
|
panic!("Unable to parse path")
|
|
|
|
}
|
|
|
|
};
|
|
|
@ -143,9 +149,11 @@ pub extern "C" fn ext_get_dhash(lib: &PIHash, path_char: *const libc::c_char) -> |
|
|
|
let image_path = match path_str.to_str() {
|
|
|
|
Ok(result) => result,
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes()));
|
|
|
|
println!(
|
|
|
|
"Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes())
|
|
|
|
);
|
|
|
|
panic!("Unable to parse path")
|
|
|
|
}
|
|
|
|
};
|
|
|
@ -161,9 +169,11 @@ pub extern "C" fn ext_get_phash(lib: &PIHash, path_char: *const libc::c_char) -> |
|
|
|
let image_path = match path_str.to_str() {
|
|
|
|
Ok(result) => result,
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes()));
|
|
|
|
println!(
|
|
|
|
"Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes())
|
|
|
|
);
|
|
|
|
panic!("Unable to parse path")
|
|
|
|
}
|
|
|
|
};
|
|
|
@ -186,9 +196,11 @@ pub extern "C" fn ext_get_phashes(lib: &PIHash, path_char: *const libc::c_char) |
|
|
|
let image_path = match path_str.to_str() {
|
|
|
|
Ok(result) => result,
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes()));
|
|
|
|
println!(
|
|
|
|
"Error: {}. Unable to parse '{}'",
|
|
|
|
e,
|
|
|
|
to_hex_string(path_str.to_bytes())
|
|
|
|
);
|
|
|
|
panic!("Unable to parse path")
|
|
|
|
}
|
|
|
|
};
|
|
|
@ -209,7 +221,6 @@ pub extern "C" fn ext_free_phashes(raw_phashes: *const libc::c_void) { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn to_hex_string(bytes: &[u8]) -> String {
|
|
|
|
println!("length: {}", bytes.len());
|
|
|
|
let mut strs: Vec<String> = Vec::new();
|
|
|
@ -230,9 +241,9 @@ mod tests { |
|
|
|
use cache;
|
|
|
|
use hash;
|
|
|
|
|
|
|
|
use super::PIHash;
|
|
|
|
#[cfg(feature = "bench")]
|
|
|
|
use super::test::Bencher;
|
|
|
|
use super::PIHash;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_can_get_test_images() {
|
|
|
@ -263,21 +274,25 @@ mod tests { |
|
|
|
* Updated test function. Assumes 3 images to a set and no hamming distances.
|
|
|
|
* We don't need to confirm that the hamming distance calculation works in these tests.
|
|
|
|
*/
|
|
|
|
fn test_imageset_hash(hash_type: hash::HashType,
|
|
|
|
hash_precision: hash::Precision,
|
|
|
|
max_hamming_distance: u64,
|
|
|
|
image_paths: [&Path; 3],
|
|
|
|
image_hashes: [u64; 3],
|
|
|
|
lib: &PIHash) {
|
|
|
|
fn test_imageset_hash(
|
|
|
|
hash_type: hash::HashType,
|
|
|
|
hash_precision: hash::Precision,
|
|
|
|
max_hamming_distance: u64,
|
|
|
|
image_paths: [&Path; 3],
|
|
|
|
image_hashes: [u64; 3],
|
|
|
|
lib: &PIHash,
|
|
|
|
) {
|
|
|
|
let mut hashes: [u64; 3] = [0; 3];
|
|
|
|
for index in 0..image_paths.len() {
|
|
|
|
let image_path = image_paths[index];
|
|
|
|
let calculated_hash = lib.get_perceptual_hash(&image_path, &hash_precision, &hash_type);
|
|
|
|
println!("[{}] Image hashes for [{}] expected: [{}] actual: [{}]",
|
|
|
|
hash_type,
|
|
|
|
image_path.to_str().unwrap(),
|
|
|
|
image_hashes[index],
|
|
|
|
calculated_hash);
|
|
|
|
println!(
|
|
|
|
"[{}] Image hashes for [{}] expected: [{}] actual: [{}]",
|
|
|
|
hash_type,
|
|
|
|
image_path.to_str().unwrap(),
|
|
|
|
image_hashes[index],
|
|
|
|
calculated_hash
|
|
|
|
);
|
|
|
|
assert_eq!(calculated_hash, image_hashes[index]);
|
|
|
|
hashes[index] = calculated_hash;
|
|
|
|
}
|
|
|
@ -308,65 +323,74 @@ mod tests { |
|
|
|
let sample_01_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg")];
|
|
|
|
let sample_01_hashes: [u64; 3] = [
|
|
|
|
857051991849750,
|
|
|
|
857051991849750,
|
|
|
|
857051991849750];
|
|
|
|
test_imageset_hash(hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib);
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_01_hashes: [u64; 3] = [857051991849750, 857051991849750, 857051991849750];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_02 tests
|
|
|
|
let sample_02_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_02_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_02_hashes: [u64; 3] = [
|
|
|
|
18446744073441116160,
|
|
|
|
18446744073441116160,
|
|
|
|
18446744073441116160];
|
|
|
|
test_imageset_hash(hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
3u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib);
|
|
|
|
18446744073441116160,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
3u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_03 tests
|
|
|
|
let sample_03_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_03_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg")];
|
|
|
|
let sample_03_hashes: [u64; 3] = [
|
|
|
|
135670932300497406,
|
|
|
|
135670932300497406,
|
|
|
|
135670932300497406];
|
|
|
|
test_imageset_hash(hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib);
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_03_hashes: [u64; 3] =
|
|
|
|
[135670932300497406, 135670932300497406, 135670932300497406];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_04 tests
|
|
|
|
let sample_04_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_04_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_04_hashes: [u64; 3] = [
|
|
|
|
18446460933225054208,
|
|
|
|
18446460933225054208,
|
|
|
|
18446460933225054208];
|
|
|
|
test_imageset_hash(hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib);
|
|
|
|
18446460933225054208,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::AHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Clean_Cache
|
|
|
|
// super::teardown();
|
|
|
@ -381,65 +405,78 @@ mod tests { |
|
|
|
let sample_01_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_01_hashes: [u64; 3] = [
|
|
|
|
3404580580803739582,
|
|
|
|
3404580580803739582,
|
|
|
|
3404580580803739582];
|
|
|
|
test_imageset_hash(hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib);
|
|
|
|
3404580580803739582,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_02 tests
|
|
|
|
let sample_02_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_02_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_02_hashes: [u64; 3] = [
|
|
|
|
14726771606135242753,
|
|
|
|
14726771606135242753,
|
|
|
|
14726771606135242753];
|
|
|
|
test_imageset_hash(hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib);
|
|
|
|
14726771606135242753,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_03 tests
|
|
|
|
let sample_03_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_03_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg")];
|
|
|
|
let sample_03_hashes: [u64; 3] = [
|
|
|
|
144115181601817086,
|
|
|
|
144115181601817086,
|
|
|
|
144115181601817086];
|
|
|
|
test_imageset_hash(hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib);
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_03_hashes: [u64; 3] =
|
|
|
|
[144115181601817086, 144115181601817086, 144115181601817086];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_04 tests
|
|
|
|
let sample_04_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_04_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_04_hashes: [u64; 3] = [
|
|
|
|
18374262188442386433,
|
|
|
|
18374262188442386433,
|
|
|
|
18374262188442386433];
|
|
|
|
test_imageset_hash(hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib);
|
|
|
|
18374262188442386433,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::DHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Clean_Cache
|
|
|
|
// super::teardown();
|
|
|
@ -454,65 +491,77 @@ mod tests { |
|
|
|
let sample_01_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg")];
|
|
|
|
let sample_01_hashes: [u64; 3] = [
|
|
|
|
72357778504597504,
|
|
|
|
72357778504597504,
|
|
|
|
72357778504597504];
|
|
|
|
test_imageset_hash(hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib);
|
|
|
|
&Path::new("./test_images/sample_01_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_01_hashes: [u64; 3] = [72357778504597504, 72357778504597504, 72357778504597504];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_01_images,
|
|
|
|
sample_01_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_02 tests
|
|
|
|
let sample_02_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_02_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_02_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_02_hashes: [u64; 3] = [
|
|
|
|
5332332327550844928,
|
|
|
|
5332332327550844928,
|
|
|
|
5332332327550844928];
|
|
|
|
test_imageset_hash(hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib);
|
|
|
|
5332332327550844928,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
1u64,
|
|
|
|
sample_02_images,
|
|
|
|
sample_02_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_03 tests
|
|
|
|
let sample_03_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_03_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_03_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_03_hashes: [u64; 3] = [
|
|
|
|
6917529027641081856,
|
|
|
|
6917529027641081856,
|
|
|
|
6917529027641081856];
|
|
|
|
test_imageset_hash(hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib);
|
|
|
|
6917529027641081856,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
0u64,
|
|
|
|
sample_03_images,
|
|
|
|
sample_03_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sample_04 tests
|
|
|
|
let sample_04_images: [&Path; 3] = [
|
|
|
|
&Path::new("./test_images/sample_04_large.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_medium.jpg"),
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg")];
|
|
|
|
&Path::new("./test_images/sample_04_small.jpg"),
|
|
|
|
];
|
|
|
|
let sample_04_hashes: [u64; 3] = [
|
|
|
|
10997931646002397184,
|
|
|
|
10997931646002397184,
|
|
|
|
10997931646002397184];
|
|
|
|
test_imageset_hash(hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
3u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib);
|
|
|
|
10997931646002397184,
|
|
|
|
];
|
|
|
|
test_imageset_hash(
|
|
|
|
hash::HashType::PHash,
|
|
|
|
hash::Precision::Medium,
|
|
|
|
3u64,
|
|
|
|
sample_04_images,
|
|
|
|
sample_04_hashes,
|
|
|
|
&lib,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Clean_Cache
|
|
|
|
// super::teardown();
|
|
|
@ -526,15 +575,19 @@ mod tests { |
|
|
|
|
|
|
|
// Setup the caches to make sure we're good to properly bench
|
|
|
|
// All phashes so that the matricies are pulled from cache as well
|
|
|
|
lib.get_perceptual_hash(&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash);
|
|
|
|
lib.get_perceptual_hash(
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash,
|
|
|
|
);
|
|
|
|
|
|
|
|
bench.iter(|| {
|
|
|
|
// Sample_01 Bench
|
|
|
|
lib.get_perceptual_hash(&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash);
|
|
|
|
lib.get_perceptual_hash(
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash,
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
@ -546,9 +599,11 @@ mod tests { |
|
|
|
|
|
|
|
bench.iter(|| {
|
|
|
|
// Sample_01 Bench
|
|
|
|
lib.get_perceptual_hash(&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash);
|
|
|
|
lib.get_perceptual_hash(
|
|
|
|
&Path::new("./test_images/sample_01_large.jpg"),
|
|
|
|
&hash::Precision::Medium,
|
|
|
|
&hash::HashType::PHash,
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|