passkalilo
发表于 2009-11-24 20:39:13
楼上的是高手
sanmoking
发表于 2009-11-24 21:28:38
有高手就一定要给你编写程序吗?
200块钱算什么?
guland 发表于 2009-11-22 15:39 http://www.autoitx.com/images/common/back.gif
专职程序员年薪N十万(更牛逼的我不敢乱说啦,想入非非中)....关键是兴致....
lmx860512
发表于 2009-11-24 23:47:16
sanmoking 牛人啊
学习下
foboy
发表于 2009-11-25 15:14:28
本帖最后由 foboy 于 2009-12-4 00:07 编辑
由于本人接了此任务,并且已经完成了主要部分,特贴出源码,大家发现有什么错误或不足请提出来。
这些是识别图片数字和字母的主要函数,最下面的数组是本人采集到的数字和字母的点阵信息。
其中$top是全局变量,保存的是第一个格子的坐标。
本程序只对比10个数字和26个字母的颜色点信息,所以不用保存图片以供对比,节省系统资源,那个兄弟居然说对比几十个长度的字符串比对比几十张1K左右的图片费资源。
code]Func getheguan();获取荷官名字
Dim $topheguan, $theheguanword, $heguan, $sigleASCII, $ASCIIID
$ASCIIID = 0
$theheguan = ""
$heguan = ""
$topheguan = findtezhengdian(6437126, 3, 2, 6437126, 2, 9, 6437126, $top + 18 * 2, $top + 19 * 5, $top + 18 * 5, $top + 19 * 5 + 6);根据特征点获取“荷官”两个字的坐标,以确定从哪开始读取荷官名字。(findtezhengdian()这个函数我就不贴出来了。)
If $topheguan == 0 Or $topheguan == 0 Then
$heguan = "error"
MsgBox(0, "", "找不到荷官")
Return $heguan
EndIf
$topheguan = $topheguan + 32
$topheguan = $topheguan + 2
$sigleASCII[$ASCIIID] = getsingleword($topheguan + $ASCIIID * 6, $topheguan)
While $sigleASCII[$ASCIIID] <> 0;依次读取单个字母,直到返回的ASCII码为0
$ASCIIID += 1
$sigleASCII[$ASCIIID] = getsingleword($topheguan + $ASCIIID * 6, $topheguan)
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 + 18 * ($x - 1), $top + 19 * ($y - 1))
If $thecolortop == 16777215 Then
Return 666
EndIf
$howmany = PixelSearch($top + 18 * ($x - 1) + 1, $top + 19 * ($y - 1) + 4, $top + 18 * ($x - 1) + 3, $top + 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 + 18 * ($xx - 1) + $x, $top + 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 = "01111111111101111001110011100111001110011111111111"
$numa = "00111111111111111111001110011100111001110011100111"
$numa = "11111111111100100001000110011101111111001111111111"
$numa = "11111111111100100001011110111100011110011111111111"
$numa = "00011001110111101111111111101111111111110001100011"
$numa = "11111111111100011111111111101100001110011111111111"
$numa = "01111111111100111111111111111111001110011111111111"
$numa = "11111111110001100011001110011100111011100111011100"
$numa = "11111111111100111001111111111111001110011111111111"
$numa = "11111111111100111001111111111101111110011111111111"
$numb = "01111111111110111101111011110111101111011111101111"
$numb = "01111111111111110111001110011100111001110011100111"
$numb = "01111111111110100001000110011101111111101111111111"
$numb = "01111111111110100001001110011100001110011111111111"
$numb = "00011001110011101111111111101111111111110001100011"
$numb = "11111111111100011111111111110100001110011111111111"
$numb = "01111111111110111111111111111111101111011111101111"
$numb = "11111111110000100011000110001100111001110111001110"
$numb = "01111111111100111101111111111111101110011111111111"
$numb = "01111111111100111001111111111100111110011111111111"
$numc = "01111111111110111101111011110111101111011111101111"
$numc = "01110111101111011110011100111001110011100111001110"
$numc = "11111111111100100011000110011111110111001111111111"
$numc = "11111111111101100011011110111100011110011111111111"
$numc = "0"
$numc = "0"
$numc = "0"
$numc = "0"
$numc = "0"
$numc = "0"
$numd = "0"
$numd = "00111111111111110111001110011100111001110011100111"
$numd = "0"
$numd = "11111111111101100011011110111100011110111111111111"
$numd = "0"
$numd = "0"
$numd = "0"
$numd = "0"
$numd = "0"
$numd = "0"
$wordcode = "000000000000000000001100010010001110010010001111000000000000";a
$wordcode = "110000010000010000011100010010010010010010011100000000000000";b
$wordcode = "000000000000000000001110010010010000010000001110000000000000";c
$wordcode = "000110000010000010001110010010010010010010001111000000000000";d
$wordcode = "000000000000000000001100010010011110010000001110000000000000";e
$wordcode = "000111001000001000011110001000001000001000011110000000000000";f
$wordcode = "000000000000000000001111010010001100010000011110010001001110";g
$wordcode = "110000010000010000011100010010010010010010111011000000000000";h
$wordcode = "001000000000000000011000001000001000001000011100000000000000";i
$wordcode = "000100000000000000001100000100000100000100000100000100111000";j
$wordcode = "110000010000010000010111010100011100010010111011000000000000";k
$wordcode = "111000001000001000001000001000001000001000111110000000000000";l
$wordcode = "000000000000000000111100101010101010101010101010000000000000";m
$wordcode = "000000000000000000111100010010010010010010111011000000000000";n
$wordcode = "000000000000000000001100010010010010010010001100000000000000";o
$wordcode = "000000000000000000111100010010010010010010011100010000111000";p
$wordcode = "000000000000000000001110010010010010010010001110000010000111";q
$wordcode = "000000000000000000110110011000010000010000111000000000000000";r
$wordcode = "000000000000000000011110010000001100000010011110000000000000";s
$wordcode = "000000001000001000011100001000001000001000000110000000000000";t
$wordcode = "000000000000000000110110010010010010010010001111000000000000";u
$wordcode = "000000000000000000111011010010010100001100001000000000000000";v
$wordcode = "000000000000000000101010101010011100010100010100000000000000";w
$wordcode = "000000000000000000110110010100001000010100110110000000000000";x
$wordcode = "000000000000000000111011010010010100001100001000001000110000";y
$wordcode = "000000000000000000011110000100001000001000011110000000000000";z
$wordcode = "001000001000001100010100010100011110010010110011000000000000";A
$wordcode = "111100010010010010011100010010010010010010111100000000000000";B
$wordcode = "011110100010100000100000100000100000100010011100000000000000";C
$wordcode = "111100010010010010010010010010010010010010111100000000000000";D
$wordcode = "111110010010010100011100010100010000010010111110000000000000";E
$wordcode = "111110010010010100011100010100010000010000111000000000000000";F
$wordcode = "001110010010100000100000100111100010010010001100000000000000";J
$wordcode = "110011010010010010011110010010010010010010110011000000000000";H
$wordcode = "111110001000001000001000001000001000001000111110000000000000";I
$wordcode = "011111000100000100000100000100000100000100100100111000000000";J
$wordcode = "111011010010010100011000010100010100010010111011000000000000";K
$wordcode = "111000010000010000010000010000010000010001111111000000000000";L
$wordcode = "110110110110110110110110101010101010101010101010000000000000";M
$wordcode = "110111010010011010011010010110010110010010111010000000000000";N
$wordcode = "011100100010100010100010100010100010100010011100000000000000";O
$wordcode = "111100010010010010011100010000010000010000111000000000000000";P
$wordcode = "011100100010100010100010100010111010100110011100000110000000";Q
$wordcode = "111100010010010010011100010100010010010010111011000000000000";R
$wordcode = "011110100010100000011000000100000010100010111100000000000000";S
$wordcode = "111110101010001000001000001000001000001000011100000000000000";T
$wordcode = "110011010010010010010010010010010010010010001100000000000000";U
$wordcode = "110011010010010010010100010100001100001000001000000000000000";V
$wordcode = "101010101010101010011100010100010100010100010100000000000000";W
$wordcode = "110110010100010100001000001000010100010100110110000000000000";X
$wordcode = "110110010100010100001000001000001000001000011100000000000000";Y
$wordcode = "111110100100000100001000001000010000010010111110000000000000";Z
EndFunc ;==>dingyidianzhen
zhongzijie
发表于 2009-11-25 23:47:58
由于本人................
收藏收藏啊
king777sa
发表于 2009-11-26 00:49:51
这个 应该, 能 写,以前 写过。文字的,这里是数字 , 应该不会很复杂
fisher
发表于 2011-10-3 15:31:47
不错,学习
wpig
发表于 2011-10-11 15:38:37
呵呵,挺强大
zcool321
发表于 2011-10-12 02:11:21
暂时没有学习过这些~!~了解下 确实很不错
runanchor
发表于 2011-10-21 20:55:24
记号,以后好好学,太神奇了
auto
发表于 2011-10-22 19:30:13
买来看看,这个组件识别率高吗?
auhj887
发表于 2012-2-10 15:58:35
很厉害呀。
qiu491996004
发表于 2012-3-5 14:45:55
很好 ,刚好拿来参考,谢谢
raeast
发表于 2012-3-19 21:44:02
高手 佩服了
zhangdkpz
发表于 2012-4-13 16:05:27
hjghhjghfhgfghdfghfgh