10 个稳定版本 (3 个主要版本)
使用旧的 Rust 2015
3.2.0 | 2021年5月4日 |
---|---|
3.1.1 | 2021年3月13日 |
3.1.0 | 2020年2月19日 |
3.0.0 | 2019年10月28日 |
0.0.2 |
|
#299 在 图像
每月下载量 434
在 7 个 crate 中使用(6 个直接使用)
56KB
696 行
img_hash

现在可以在稳定 Rust 上构建!(但需要夜间构建以进行基准测试。)
一个用于获取图像感知哈希值的库。
感谢 Dr. Neal Krawetz 提供了均值(aHash)、梯度(dHash)和 DCT(pHash)感知哈希算法的概要。
http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html(访问时间:2014年8月)
还提供了 Blockhash.io 算法 的实现。
此 crate 可以直接在 PistonDevelopers/image crate 的缓冲区上操作。
使用方法
将 img_hash
添加到您的 Cargo.toml
[dependencies.img_hash]
version = "3.0"
示例程序
extern crate image;
extern crate img_hash;
use img_hash::{HasherConfig, HashAlg};
fn main() {
let image1 = image::open("image1.png").unwrap();
let image2 = image::open("image2.png").unwrap();
let hasher = HasherConfig::new().to_hasher();
let hash1 = hasher.hash_image(&image1);
let hash2 = hasher.hash_image(&image2);
println!("Image1 hash: {}", hash1.to_base64());
println!("Image2 hash: {}", hash2.to_base64());
println!("Hamming Distance: {}", hash1.dist(&hash2));
}
基准测试
为了在 Rust 稳定版上构建和测试,必须将基准测试放在功能门后面。如果您已安装 Rust 夜间版并想运行基准测试,请使用以下命令
cargo bench --features bench
许可证
许可方式任选其一
- Apache License,版本 2.0(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可证(LICENSE-MIT 或 http://opensource.org/licenses/MIT)
由您选择。
贡献
除非您明确声明,否则您提交给本工作的任何有意贡献,根据 Apache-2.0 许可证的定义,应按上述方式双重许可,不附加任何额外条款或条件。
依赖关系
~14MB
~114K SLoC