ImageHash class

The base class for image hash.

Usage:

final hash = ImageHash.fromString('average:0000000000000000');
print(hash.bitsCount()); // 64
print(hash.hash); // 0
print(hash.bits()); // 64

Constructors

ImageHash(BigInt hash, HashFn fn, {int bits = 64})
ImageHash.fromBytes(Uint8List bytes, HashFn kind, {int? bits})
Create from Uint8List
factory
ImageHash.fromHex(String hexString, HashFn kind, {int? bits})
Create an image hash from a hex string.
factory
ImageHash.fromString(String hashString)
Create an image hash from a string.
factory

Properties

bitLength int
Bit length convenience getter.
no setter
bits int
Bit length of the hash.
final
fn HashFn
The hash function.
final
hash BigInt
The hash value (arbitrary precision).
getter/setter pair
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bitsCount() int
Returns the number of bits in the hash.
distance(ImageHash other) int
Calculate the hamming distance between two hashes.
getBit(int idx) bool
Get the bit at the specified index.
isSimilar(ImageHash other, {double threshold = 0.9}) bool
Check if two hashes are similar.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setBit(int idx) → void
Set the bit at the specified index.
similarity(ImageHash other) double
Calculate the similarity between two hashes.
toBytes() Uint8List
Convert to Uint8List
toString() String
eg.: 'average:0000000000000000'
override

Operators

operator ==(Object other) bool
The equality operator.
override