1 Star 0 Fork 0

fengyun311/go-study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
王明 提交于 2020-09-01 22:41 . 添加从csv 图片下载工具
package main
import (
"fmt"
"github.com/corona10/goimagehash"
)
func main() {
img_hash := "a:00fffffff1e0c000"
hash, err := goimagehash.ImageHashFromString(img_hash)
if err != nil {
fmt.Println(err)
}
img2_hash :="a:00fefffff1e0c000"
hash2, err := goimagehash.ImageHashFromString(img2_hash)
if err != nil {
fmt.Println(err)
}
//fmt.Println(hash.Distance(hash2))
a, _ := hash.Distance(hash2)
v := 1 - float32(a)/float32(hash.Bits() * 1.0)
fmt.Println(v)
//a := 5/3
//file1, _ := os.Open("sample1.jpg")
//file2, _ := os.Open("sample2.jpg")
//defer file1.Close()
//defer file2.Close()
//
//img1, _ := jpeg.Decode(file1)
//img2, _ := jpeg.Decode(file2)
//hash1, _ := goimagehash.AverageHash(img1)
//hash2, _ := goimagehash.AverageHash(img2)
//distance, _ := hash1.Distance(hash2)
//fmt.Printf("Distance between images: %v\n", distance)
//
//hash1, _ = goimagehash.DifferenceHash(img1)
//hash2, _ = goimagehash.DifferenceHash(img2)
//distance, _ = hash1.Distance(hash2)
//fmt.Printf("Distance between images: %v\n", distance)
//width, height := 8, 8
//hash3, _ = goimagehash.ExtAverageHash(img1, width, height)
//hash4, _ = goimagehash.ExtAverageHash(img2, width, height)
//distance, _ = hash3.Distance(hash4)
//fmt.Printf("Distance between images: %v\n", distance)
//fmt.Printf("hash3 bit size: %v\n", hash3.Bits())
//fmt.Printf("hash4 bit size: %v\n", hash4.Bits())
//
//var b bytes.Buffer
//foo := bufio.NewWriter(&b)
//_ = hash4.Dump(foo)
//foo.Flush()
//bar := bufio.NewReader(&b)
//hash5, _ := goimagehash.LoadExtImageHash(bar)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fengyun311/go-study.git
git@gitee.com:fengyun311/go-study.git
fengyun311
go-study
go-study
master

搜索帮助