Created
August 29, 2012 04:14
-
-
Save thearthur/3506760 to your computer and use it in GitHub Desktop.
clojure Dojo team 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bankocr.core) | |
(def parse {\space :., \_ :_, \| :|}) | |
(defn parse-input [input] (map parse input )) | |
(def digits { [[:. :_ :.] | |
[:| :. :|] | |
[:| :_ :|]] 0 | |
[[:. :. :.] | |
[:. :. :|] | |
[:. :. :|]] 1 | |
[[:. :_ :.] | |
[:. :_ :|] | |
[:| :_ :.]] 2 | |
[[:. :_ :.] | |
[:. :_ :|] | |
[:. :_ :|]] 3 | |
[[:. :. :.] | |
[:| :_ :|] | |
[:. :. :|]] 4 | |
[[:. :_ :.] | |
[:| :_ :.] | |
[:. :_ :|]] 5 | |
[[:. :_ :.] | |
[:| :_ :.] | |
[:| :_ :|]] 6 | |
[[:. :_ :.] | |
[:. :. :|] | |
[:. :. :|]] 7 | |
[[:. :_ :.] | |
[:| :_ :|] | |
[:| :_ :|]] 8 | |
[[:. :_ :.] | |
[:| :_ :|] | |
[:. :_ :|]] 9}) | |
(def lines [" _ _ _ _ _ _ _ _ " | |
"| | | _| _||_||_ |_ ||_||_|" | |
"|_| ||_ _| | _||_| ||_| _|"] ) | |
(defn partitioin-digits [lines] | |
(map #(partition 3 %) (map parse-input lines))) | |
(defn split-digits [digits] | |
(map vector (first digits) (second digits) (nth digits 2))) | |
(defn ocr [lines] | |
(map digits (split-digits (partitioin-digits lines)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment