有没有朋友有现成的OCR代码能读取这个验证码,能给出一段吗?
附件是这个验证码的训练图片,各位能提供全套 ...
manlty 发表于 2010-12-11 16:54 #include <GDIPlus.au3>
_GDIPlus_Startup ()
$sBmpFile = @ScriptDir & "\031.bmp";要识别的文件
$hBitmap = _GDIPlus_BitmapCreateFromFile($sBmpFile)
$sOcr = ""
For $i=1 To 4
$hClone = _GDIPlus_BitmapCloneArea($hBitmap, 8+($i-1)*7, 4, 6, 11, $GDIP_PXF24RGB)
;_GDIPlus_ImageSaveToFile($hCLone,@ScriptDir&""&$i&".bmp")
$aBmpData = _myReadBitmapMsg($hClone)
;ConsoleWrite($aBmpData[0]&@crlf)
Switch $aBmpData[0]
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0C86400C86400C86400F5F3F0F5F3F0"
$sOcr &= "9"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0"
$sOcr &= "5"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0"
$sOcr &= "6"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0C86400C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0"
$sOcr &= "3"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0"
$sOcr &= "1"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0"
$sOcr &= "8"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400F5F3F0"
$sOcr &= "0"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0C86400F5F3F0C86400F5F3F0F5F3F0C86400F5F3F0F5F3F0C86400F5F3F0F5F3F0C86400F5F3F0F5F3F0C86400F5F3F0C86400C86400C86400C86400C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0"
$sOcr &= "4"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400C86400C86400"
$sOcr &= "2"
Case "F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400C86400C86400C86400C86400C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0F5F3F0C86400F5F3F0F5F3F0F5F3F0F5F3F0"
$sOcr &= "7"
EndSwitch
Next
ConsoleWrite("识别结果:" & $sOcr & @crlf)
_GDIPlus_ImageDispose ($hClone)
_WinAPI_DeleteObject ($hClone)
_GDIPlus_ImageDispose ($hBitmap)
_WinAPI_DeleteObject ($hBitmap)
_GDIPlus_ShutDown ()
Func _myReadBitmapMsg($hBitmap);
Local $aBmpData[4]
$aBmpData[1] = _GDIPlus_ImageGetWidth ($hBitmap)
$aBmpData[2] = _GDIPlus_ImageGetHeight ($hBitmap)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aBmpData[1], $aBmpData[2], $GDIP_ILMREAD, $GDIP_PXF24RGB);$aGdip[0]);
$aBmpData[3] = Abs(DllStructGetData($BitmapData, "Stride"))
Local $Scan0 = DllStructGetData($BitmapData, "Scan0");
Local $pixelData = DllStructCreate("ubyte lData[" & ($aBmpData[3] * $aBmpData[2]) & "]", $Scan0)
$aBmpData[0] = DllStructGetData($pixelData, "lData")
_GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
$aBmpData[0] = StringRegExpReplace($aBmpData[0], "(?:0x)?([0-9A-F]{"&$aBmpData[1]*6&"}).{"&$aBmpData[3]*2-$aBmpData[1]*6&"}", "$1")
Return $aBmpData
EndFunc
|