hash

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache stores an array of image hashes from corona10/goimagehash

func NewCache

func NewCache(cacheFileName, promNamespace string, numFiles int) (*Cache, error)

NewCache reads the given file to rebuild its map from the last time it was run. If the file does not exist, it will be created.

func (*Cache) GetHash

func (c *Cache) GetHash(fileName string) (*Image, error)

GetHash gets the hash from cache or if it does not exist it calcs it

func (*Cache) Persist

func (c *Cache) Persist() error

Persist writes the cache to disk

func (*Cache) Stats

func (c *Cache) Stats() (int, int)

Stats returns the number of images in the cache

type DiffResult

type DiffResult struct {
	One     string
	Two     string
	OneArea int
	TwoArea int
}

DiffResult are two images that are the "same", i.e. within the given distance

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ diffs images

func NewDiffer

func NewDiffer(numWorkers, distanceThreshold int, inputImages chan types.Pair, cache *Cache, promNamespace string) *Differ

NewDiffer is the constructor, Run() must be called to start diffing

func (*Differ) Run

func (d *Differ) Run(ctx context.Context) (chan DiffResult, chan error)

Run starts the diff workers

func (*Differ) Shutdown

func (d *Differ) Shutdown()

Shutdown unregisters prom stats

type Image

type Image struct {
	*goimagehash.ImageHash
	image.Config `json:"-"`
}

Image is the minimal data needed to compare images and is held in-memory by HashCache.Cache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL