-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (43 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"os"
"github.com/pixolous/pixolousAnalyze"
"gocv.io/x/gocv"
)
func main() {
//groups := make([][]string, 0)
pathToHash := make(map[string]string)
for i := 2014; i <= 2040; i++ {
path := fmt.Sprintf("%s%d%s", "pics/IMG-", i, ".jpg")
image := gocv.IMRead(path, gocv.IMReadColor)
if image.Empty() {
fmt.Printf("Failed to read image: %s\n", path)
os.Exit(1)
}
defer image.Close()
hash := pixolousAnalyze.AHash(image)
pathToHash[path] = hash
fmt.Println(hash)
}
hashes := make([]string, 0, len(pathToHash))
for p := range pathToHash {
hashes = append(hashes, pathToHash[p])
}
// for i := range pathToHash {
// for j := range pathToHash {
// if i != j {
// fmt.Println("Similarity", i, j, pixolousAnalyze.hashSimilarity(pathToHash[i], pathToHash[j]))
// }
// }
// }
fmt.Println(pixolousAnalyze.GetSimilarGrouped(pathToHash))
}
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}