找回密码
 加入
搜索
楼主: passkalilo

[已成交] 200块找人帮忙写一个简单的数字识别程序

[复制链接]
 楼主| 发表于 2009-11-24 20:39:13 | 显示全部楼层
楼上的是高手
发表于 2009-11-24 21:28:38 | 显示全部楼层
有高手就一定要给你编写程序吗?
   200块钱算什么?
guland 发表于 2009-11-22 15:39



    专职程序员年薪N十万(更牛逼的我不敢乱说啦,想入非非中)....关键是兴致....
发表于 2009-11-24 23:47:16 | 显示全部楼层
sanmoking 牛人啊  
学习下
发表于 2009-11-25 15:14:28 | 显示全部楼层
本帖最后由 foboy 于 2009-12-4 00:07 编辑

由于本人接了此任务,并且已经完成了主要部分,特贴出源码,大家发现有什么错误或不足请提出来。
这些是识别图片数字和字母的主要函数,最下面的数组是本人采集到的数字和字母的点阵信息。
其中$top是全局变量,保存的是第一个格子的坐标。
本程序只对比10个数字和26个字母的颜色点信息,所以不用保存图片以供对比,节省系统资源,那个兄弟居然说对比几十个长度的字符串比对比几十张1K左右的图片费资源。
code]Func getheguan();获取荷官名字
        Dim $topheguan[2], $theheguanword, $heguan, $sigleASCII[20], $ASCIIID
        $ASCIIID = 0
        $theheguan = ""
        $heguan = ""
        $topheguan = findtezhengdian(6437126, 3, 2, 6437126, 2, 9, 6437126, $top[0] + 18 * 2, $top[1] + 19 * 5, $top[0] + 18 * 5, $top[1] + 19 * 5 + 6);根据特征点获取“荷官”两个字的坐标,以确定从哪开始读取荷官名字。(findtezhengdian()这个函数我就不贴出来了。)
        If $topheguan[0] == 0 Or $topheguan[1] == 0 Then
                $heguan = "error"
                MsgBox(0, "", "找不到荷官")
                Return $heguan
        EndIf
        $topheguan[0] = $topheguan[0] + 32
        $topheguan[1] = $topheguan[1] + 2
        $sigleASCII[$ASCIIID] = getsingleword($topheguan[0] + $ASCIIID * 6, $topheguan[1])
        While $sigleASCII[$ASCIIID] <> 0;依次读取单个字母,直到返回的ASCII码为0
                $ASCIIID += 1
                $sigleASCII[$ASCIIID] = getsingleword($topheguan[0] + $ASCIIID * 6, $topheguan[1])
        WEnd
        $heguan = StringStripWS(StringFromASCIIArray($sigleASCII, 0, $ASCIIID), 8)
        ClipPut($heguan)
        Return $heguan
EndFunc   ;==>getheguan
Func getsingleword($x, $y)
        Dim $thecolorcode, $colora, $colorb, $colorc
        $thecolorcode = ""
        For $j = 0 To 9
                For $k = 0 To 5
                        $bb = PixelGetColor($x + $k, $y + $j)
                        If $bb == 6437126 Then
                                $thecolorcode &= "1"
                        Else
                                $thecolorcode &= "0"
                        EndIf
                Next
        Next
        ;ConsoleWrite(@CRLF & "字母点阵:" & $thecolorcode & ";")
        For $i = 0 To 51;将获取的点阵信息进行对比
                If $thecolorcode == $wordcode[$i] Then
                        If $i < 26 Then;将对应的数字下标转换成ASCII码,以便更方便的转换成字母。
                                $i += 97
                        Else
                                $i += 39
                        EndIf
                        Return $i;返回的是ASCII码
                EndIf
        Next
        Return 0
EndFunc   ;==>getsingleword
Func getnum($x, $y);获取格子中的数字
        Dim $howmany, $thecolorinfo, $numindex, $numshiwei, $numgewei, $theresult, $thenum
        $thecolortop = PixelGetColor($top[0] + 18 * ($x - 1), $top[1] + 19 * ($y - 1))
        If $thecolortop == 16777215 Then
                Return 666
        EndIf
        $howmany = PixelSearch($top[0] + 18 * ($x - 1) + 1, $top[1] + 19 * ($y - 1) + 4, $top[0] + 18 * ($x - 1) + 3, $top[1] + 19 * ($y - 1) + 14, 16777215);左边寻找白色以判断是几位数
        If @error Then
                $thenum = readnumone($x, $y)
                If $thenum == 888 Then
                        MsgBox(0, "错误!", "读取第" & $y & "行第 " & $x & "列数字时发生错误:未能识别。请将当前轮盘截图发给作者补充!QQ:114026307(" & $numshiwei & "," & $numgewei & $theinfo & ")")
                        Return 888
                EndIf
                Return $thenum
        Else
                $numshiwei = readnumtwo(1, $x, $y)
                $numgewei = readnumtwo(2, $x, $y)
                If $numshiwei == 888 Or $numgewei == 888 Then
                        MsgBox(0, "错误!", "读取第" & $y & "行第 " & $x & "列数字时发生错误:未能识别。请将当前轮盘截图发给作者补充!QQ:114026307(" & $numshiwei & "," & $numgewei & ")")
                        Return 888
                EndIf
                $thenum = $numshiwei & $numgewei
                Return $thenum
        EndIf
EndFunc   ;==>getnum
Func readnumtwo($x, $xx, $yy);获取两位数
        $theresult = readnum(($x - 1) * 7 + 1, $xx, $yy, "识别为2位数,尝试偏移1像素读取")
        If $theresult == 888 Then
                $theresult = readnum(($x - 1) * 7 + 2, $xx, $yy, "识别为2位数,偏移1像素读取失败,尝试偏移2像素读取")
                If $theresult == 888 Then
                        $theresult = readnum(($x - 1) * 7 + 3, $xx, $yy, "识别为2位数,偏移2像素读取失败,尝试偏移3像素读取")
                        If $theresult == 888 Then
                                Return 888
                        EndIf
                EndIf
        EndIf
        Return $theresult
EndFunc   ;==>readnumtwo
Func readnumone($xx, $yy);获取1位数
        $theresult = readnum(4, $xx, $yy, "识别为1位数,尝试偏移4像素读取")
        If $theresult == 888 Then
                $theresult = readnum(5, $xx, $yy, "识别为1位数,尝试偏移5像素读取")
                If $theresult == 888 Then
                        $theresult = readnum(6, $xx, $yy, "识别为1位数,尝试偏移6像素读取")
                        If $theresult == 888 Then
                                Return 888
                        EndIf
                EndIf
        EndIf
        Return $theresult
EndFunc   ;==>readnumone
Func readnum($x, $xx, $yy, $tishi);识别单个数字
        ;ConsoleWrite(@CRLF & $tishi)
        $thecolorinfo = getcolorinfo($top[0] + 18 * ($xx - 1) + $x, $top[1] + 19 * ($yy - 1) + 4)
        ;ConsoleWrite(@CRLF & $thecolorinfo)
        For $numindexb = 0 To 9
                If $thecolorinfo == $numa[$numindexb] Or $thecolorinfo == $numb[$numindexb] Or $thecolorinfo == $numc[$numindexb] Or $thecolorinfo == $numd[$numindexb] Then
                        Return $numindexb
                EndIf
                If $numindexb == 9 Then
                        Return 888
                EndIf
        Next
EndFunc   ;==>readnum

Func getcolorinfo($posx = 0, $posy = 0);获取数字的点阵信息
        Dim $theinfo = ""
        If $posx == 0 Or $posy == 0 Then
                Return 0
        EndIf
        For $i = 0 To 9
                For $j = 0 To 4
                        $thecolor = PixelGetColor($posx + $j, $posy + $i)
                        If $thecolor <> 0 And $thecolor <> 14239799 And $thecolor <> 3781133 Then
                                $theinfo &= "1"
                        Else
                                $theinfo &= "0"
                        EndIf
                Next
        Next
        Return $theinfo
EndFunc   ;==>getcolorinfo
Func dingyidianzhen()
        $numa[0] = "01111111111101111001110011100111001110011111111111"
        $numa[1] = "00111111111111111111001110011100111001110011100111"
        $numa[2] = "11111111111100100001000110011101111111001111111111"
        $numa[3] = "11111111111100100001011110111100011110011111111111"
        $numa[4] = "00011001110111101111111111101111111111110001100011"
        $numa[5] = "11111111111100011111111111101100001110011111111111"
        $numa[6] = "01111111111100111111111111111111001110011111111111"
        $numa[7] = "11111111110001100011001110011100111011100111011100"
        $numa[8] = "11111111111100111001111111111111001110011111111111"
        $numa[9] = "11111111111100111001111111111101111110011111111111"
        $numb[0] = "01111111111110111101111011110111101111011111101111"
        $numb[1] = "01111111111111110111001110011100111001110011100111"
        $numb[2] = "01111111111110100001000110011101111111101111111111"
        $numb[3] = "01111111111110100001001110011100001110011111111111"
        $numb[4] = "00011001110011101111111111101111111111110001100011"
        $numb[5] = "11111111111100011111111111110100001110011111111111"
        $numb[6] = "01111111111110111111111111111111101111011111101111"
        $numb[7] = "11111111110000100011000110001100111001110111001110"
        $numb[8] = "01111111111100111101111111111111101110011111111111"
        $numb[9] = "01111111111100111001111111111100111110011111111111"
        $numc[0] = "01111111111110111101111011110111101111011111101111"
        $numc[1] = "01110111101111011110011100111001110011100111001110"
        $numc[2] = "11111111111100100011000110011111110111001111111111"
        $numc[3] = "11111111111101100011011110111100011110011111111111"
        $numc[4] = "0"
        $numc[5] = "0"
        $numc[6] = "0"
        $numc[7] = "0"
        $numc[8] = "0"
        $numc[9] = "0"
        $numd[0] = "0"
        $numd[1] = "00111111111111110111001110011100111001110011100111"
        $numd[2] = "0"
        $numd[3] = "11111111111101100011011110111100011110111111111111"
        $numd[4] = "0"
        $numd[5] = "0"
        $numd[6] = "0"
        $numd[7] = "0"
        $numd[8] = "0"
        $numd[9] = "0"
        $wordcode[0] = "000000000000000000001100010010001110010010001111000000000000";a
        $wordcode[1] = "110000010000010000011100010010010010010010011100000000000000";b
        $wordcode[2] = "000000000000000000001110010010010000010000001110000000000000";c
        $wordcode[3] = "000110000010000010001110010010010010010010001111000000000000";d
        $wordcode[4] = "000000000000000000001100010010011110010000001110000000000000";e
        $wordcode[5] = "000111001000001000011110001000001000001000011110000000000000";f
        $wordcode[6] = "000000000000000000001111010010001100010000011110010001001110";g
        $wordcode[7] = "110000010000010000011100010010010010010010111011000000000000";h
        $wordcode[8] = "001000000000000000011000001000001000001000011100000000000000";i
        $wordcode[9] = "000100000000000000001100000100000100000100000100000100111000";j
        $wordcode[10] = "110000010000010000010111010100011100010010111011000000000000";k
        $wordcode[11] = "111000001000001000001000001000001000001000111110000000000000";l
        $wordcode[12] = "000000000000000000111100101010101010101010101010000000000000";m
        $wordcode[13] = "000000000000000000111100010010010010010010111011000000000000";n
        $wordcode[14] = "000000000000000000001100010010010010010010001100000000000000";o
        $wordcode[15] = "000000000000000000111100010010010010010010011100010000111000";p
        $wordcode[16] = "000000000000000000001110010010010010010010001110000010000111";q
        $wordcode[17] = "000000000000000000110110011000010000010000111000000000000000";r
        $wordcode[18] = "000000000000000000011110010000001100000010011110000000000000";s
        $wordcode[19] = "000000001000001000011100001000001000001000000110000000000000";t
        $wordcode[20] = "000000000000000000110110010010010010010010001111000000000000";u
        $wordcode[21] = "000000000000000000111011010010010100001100001000000000000000";v
        $wordcode[22] = "000000000000000000101010101010011100010100010100000000000000";w
        $wordcode[23] = "000000000000000000110110010100001000010100110110000000000000";x
        $wordcode[24] = "000000000000000000111011010010010100001100001000001000110000";y
        $wordcode[25] = "000000000000000000011110000100001000001000011110000000000000";z
        $wordcode[26] = "001000001000001100010100010100011110010010110011000000000000";A
        $wordcode[27] = "111100010010010010011100010010010010010010111100000000000000";B
        $wordcode[28] = "011110100010100000100000100000100000100010011100000000000000";C
        $wordcode[29] = "111100010010010010010010010010010010010010111100000000000000";D
        $wordcode[30] = "111110010010010100011100010100010000010010111110000000000000";E
        $wordcode[31] = "111110010010010100011100010100010000010000111000000000000000";F
        $wordcode[32] = "001110010010100000100000100111100010010010001100000000000000";J
        $wordcode[33] = "110011010010010010011110010010010010010010110011000000000000";H
        $wordcode[34] = "111110001000001000001000001000001000001000111110000000000000";I
        $wordcode[35] = "011111000100000100000100000100000100000100100100111000000000";J
        $wordcode[36] = "111011010010010100011000010100010100010010111011000000000000";K
        $wordcode[37] = "111000010000010000010000010000010000010001111111000000000000";L
        $wordcode[38] = "110110110110110110110110101010101010101010101010000000000000";M
        $wordcode[39] = "110111010010011010011010010110010110010010111010000000000000";N
        $wordcode[40] = "011100100010100010100010100010100010100010011100000000000000";O
        $wordcode[41] = "111100010010010010011100010000010000010000111000000000000000";P
        $wordcode[42] = "011100100010100010100010100010111010100110011100000110000000";Q
        $wordcode[43] = "111100010010010010011100010100010010010010111011000000000000";R
        $wordcode[44] = "011110100010100000011000000100000010100010111100000000000000";S
        $wordcode[45] = "111110101010001000001000001000001000001000011100000000000000";T
        $wordcode[46] = "110011010010010010010010010010010010010010001100000000000000";U
        $wordcode[47] = "110011010010010010010100010100001100001000001000000000000000";V
        $wordcode[48] = "101010101010101010011100010100010100010100010100000000000000";W
        $wordcode[49] = "110110010100010100001000001000010100010100110110000000000000";X
        $wordcode[50] = "110110010100010100001000001000001000001000011100000000000000";Y
        $wordcode[51] = "111110100100000100001000001000010000010010111110000000000000";Z
EndFunc   ;==>dingyidianzhen[/code]

评分

参与人数 3金钱 +70 贡献 +16 收起 理由
lpxx + 40 + 5 赞一个!
passkalilo + 10 + 1 精品文章
afan + 20 + 10

查看全部评分

发表于 2009-11-25 23:47:58 | 显示全部楼层
由于本人................

    收藏收藏啊
发表于 2009-11-26 00:49:51 | 显示全部楼层
这个 应该  , 能 写,以前 写过。文字的,这里是数字 , 应该不会很复杂
发表于 2011-10-3 15:31:47 | 显示全部楼层
不错,学习
发表于 2011-10-11 15:38:37 | 显示全部楼层
呵呵,挺强大
发表于 2011-10-12 02:11:21 | 显示全部楼层
暂时没有学习过这些~!~了解下 确实很不错
发表于 2011-10-21 20:55:24 | 显示全部楼层
记号,以后好好学,太神奇了
发表于 2011-10-22 19:30:13 | 显示全部楼层
买来看看,这个组件识别率高吗?
发表于 2012-2-10 15:58:35 | 显示全部楼层
很厉害呀。
发表于 2012-3-5 14:45:55 | 显示全部楼层
很好 ,刚好拿来参考,谢谢
发表于 2012-3-19 21:44:02 | 显示全部楼层
高手 佩服了
发表于 2012-4-13 16:05:27 | 显示全部楼层
hjghhjghfhgfghdfghfgh
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 15:25 , Processed in 0.093136 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表