-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRecognize.hs
67 lines (44 loc) · 1.52 KB
/
Recognize.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module Recognize where
import Data.List (unfoldr)
import Test.HUnit
import Test.QuickCheck
import Area
type RecogText = [[RecogChar]]
data RecogChar = RecogChar
| RecogSkip Int
deriving (Show)
data MatchLetter = MatchLetter {matchArea :: PixelArea
,matchChar :: RecogChar
} deriving (Show)
----
findLines :: PixelArea -> [PixelArea]
findLines = undefined
recognizeText :: PixelArea -> Maybe RecogText
recognizeText = return . map recognizeLine . findLines
recognizeLine :: PixelArea -> [RecogChar]
recognizeLine = unfoldr func
where func :: PixelArea -> Maybe (RecogChar, PixelArea)
func px | isEmpty px = Nothing
| otherwise =
case recognizeChar px of
Just (rc, len) -> return (rc, skipColumns px len)
Nothing -> return (RecogSkip 1, skipColumns px 1)
recognizeChar :: PixelArea -> Maybe (RecogChar, Int)
recognizeChar area = undefined
where matches = filter (letterEqual area) letters
letters :: [MatchLetter]
letters = undefined
letterEqual :: PixelArea -> MatchLetter -> Bool
letterEqual area ltr =
case areaEqual area (matchArea ltr) of
Just (Coord width h) -> width == areaWidth (matchArea ltr)
Nothing -> False
-- TESTS
testsRecog = TestList $ map TestCase
[assertEqual "" 1
1
]
prop_empty c1 = (c1::Int) == c1
runRecog = do
runTestTT testsRecog
quickCheck prop_coord