From b33b45a4ea837f442a5aae2344096512b0a0785f Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Tue, 1 Jan 2019 20:49:26 +0200 Subject: [PATCH] wip --- src/Main.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 033cefb..8012817 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -17,6 +17,7 @@ import Pipes import Pipes.Files import qualified Pipes.Prelude as P import Pipes.Safe (runSafeT) +import qualified Data.BKTree as BK data Cmd = Cmd { source :: FilePath @@ -24,6 +25,18 @@ data Cmd = Cmd { source :: FilePath , recursive :: Bool } deriving (Show, Generic, ParseRecord) +data Fingerprint = + Fingerprint { imagePath :: FilePath + , hash :: !Word64 + } deriving Show + +instance BK.Metric Fingerprint where + -- hamming distance + distance (Fingerprint _ a) (Fingerprint _ b) = + let xored = a `xor` b + in _ + + fingerprint :: DynamicImage -> Word64 fingerprint = hash . grey . scale . convertRGB8 where