loadDctHash reads a DCT hash from a reader
(r io.Reader)
| 225 | |
| 226 | // loadDctHash reads a DCT hash from a reader |
| 227 | func (h *ImageHash) loadDctHash(r io.Reader) error { |
| 228 | var length uint16 |
| 229 | if err := binary.Read(r, binary.LittleEndian, &length); err != nil { |
| 230 | return fmt.Errorf("failed to read DCT hash length: %w", err) |
| 231 | } |
| 232 | |
| 233 | h.dctHash = make([]float32, length) |
| 234 | if err := binary.Read(r, binary.LittleEndian, h.dctHash); err != nil { |
| 235 | return fmt.Errorf("failed to read DCT hash values: %w", err) |
| 236 | } |
| 237 | |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | // dctHashDistance calculates the distance between two DCT hashes |
| 242 | func (h *ImageHash) dctHashDistance(other *ImageHash) float32 { |
no test coverage detected