Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output parser for dssim algo. #33

Merged
merged 3 commits into from
Nov 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/clj/kamera/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
(update :actual #(.getAbsolutePath %))))
normalisation-chain))

(def ^:private default-compare-parser #(last (re-find #"all: .* \((.*)\)" %1)))
(def ^:private compare-parsers
{"mae" default-compare-parser
"dssim" #(last (re-find #"all: (.*)" %1))})

(defn compare-images [^File expected
^File actual
{:keys [metric screenshot-directory normalisations]}
Expand Down Expand Up @@ -147,7 +152,7 @@
(.getAbsolutePath actual)
(.getAbsolutePath difference)]
opts)
mean-absolute-error (when-let [e (last (re-find #"all: .* \((.*)\)" stderr))]
metric (when-let [e ((get compare-parsers metric default-compare-parser) stderr)]
(read-string e))]

(merge-with concat
Expand All @@ -160,8 +165,8 @@
{:errors [(format "Error comparing images - ImageMagick exited with code %s \n stdout: %s \n stderr: %s"
exit-code stdout stderr)]})

(if mean-absolute-error
{:metric mean-absolute-error}
(if metric
{:metric metric}
{:errors [(format "Could not parse ImageMagick output\n stdout: %s \n stderr: %s"
stdout stderr)]}))))))

Expand Down