国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Perl > 正文

Perl使用Tesseract-OCR實現驗證碼識別教程

2020-10-31 15:06:00
字體:
來源:轉載
供稿:網友

一、Tesseract-OCR 是什么

An OCR Engine that was developed at HP Labs between 1985 and 1995… and now at Google
基于Leptonica(http://leptonica.com/)圖形處理庫開的開源圖形識別引擎。
支持Linux、Windows、Mac平臺,
支持.NET、C++、Python、Java等開發語言:https://code.google.com/p/tesseract-ocr/wiki/AddOns
項目地址:https://code.google.com/p/tesseract-ocr/

二、使用方法

下載安裝:https://tesseract-ocr.googlecode.com/files/tesseract-ocr-setup-3.02.02.exe
注意安裝時的Path目錄、數學符號、語言選項,按需選擇。
執行:”tesseract yourpic.png res”
圖片 yourpic.png 里面的內容會被識別后保存在 res.txt
為了更精確的識別可以去到項目地址上下載相應的各種語言的 language tessdata
例如:
簡體中文 https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.chi_sim.tar.gz
繁體中文
下載解壓后 chi_sim.traineddata 復制到 Tesseract-OCR/tessdata 即可
執行:
“tesseract yourpic.png eng” 使用 默認eng語言包
“tesseract yourpic.png sim -l chi_sim” 使用 chi_sim語言包
“tesseract yourpic.png tra -l chi_tra” 使用 chi_sim語言包
選擇最接近真實數據的,方便以后修正

三、進階使用 Training

為數不多的training tesseract-ocr中文文檔
http://yy-programer.blogspot.tw/2012/08/training-tesseract-ocr-301.html
對于高精度需求的需要研究一下了,日常民用級別,默認識別加后期修正即可。

四、應用實例之吸附代理

針對 http://www.proxyfire.net/ 幾個代理列表頁的代理吸附

話不多說直接上代碼,
pf.bat

復制代碼 代碼如下:

pf.pl http://www.proxyfire.net/index.php?pageid=eliteproxylist       elite.txt
pf.pl http://www.proxyfire.net/index.php?pageid=anonymousproxylist   anony.txt
pf.pl http://www.proxyfire.net/index.php?pageid=transparentproxylist trans.txt
pf.pl http://www.proxyfire.net/index.php?pageid=socks4proxylist      s4.txt
pf.pl http://www.proxyfire.net/index.php?pageid=socks5proxylist      s5.txt
type *.txt > all.tmp
del *.txt /s/q
ren all.tmp all.txt
@pause

pf.pl
復制代碼 代碼如下:

use strict;
 
our $url    = $ARGV[0];
our $file   = $ARGV[1];
 
my $res = undef;
my @tmp = undef;
my @pxy = undef;
 
    `wget $url -q -O ___html`;
    open FH, "<___html";
    @tmp = ;
    close FH;
    $res = join('',@tmp);
    undef(@tmp);
    `del ___html /s /q`;
 
@tmp = ( $res =~ /<img alt="" src="([^" border="0">]+)><//td>(/d+)'http://www.proxyfire.net'.$tmp[$i], 'port'=>$tmp[$i+1]};
    $i = $i + 1;
}
 
for (my $i=0; $i < @pxy; $i++) {     if( length(${$pxy[$i]}{ip})>0 )
    {
        `echo off & wget ${$pxy[$i]}{ip} -q -O ___png`;
        `tesseract ___png ___ -l chi_tra`;
 
        my $txt = undef;  
        open FH,"<___.txt";
        $txt = ;
        close FH;
        if ( length($txt)>11 )
        {
            $txt =~ s//s+//g;
            $txt =~ s/日/8/g;
            $txt =~ s/ 主站蜘蛛池模板: 潮安县| 宁乡县| 汕尾市| 抚州市| 连山| 如东县| 宁陵县| 讷河市| 阿瓦提县| 怀远县| 安塞县| 察雅县| 防城港市| 前郭尔| 大厂| 达州市| 习水县| 二手房| 桐梓县| 永寿县| 达拉特旗| 金秀| 太和县| 工布江达县| 繁昌县| 黎城县| 郧西县| 丘北县| 岱山县| 佛冈县| 建始县| 淅川县| 南部县| 鹤壁市| 广昌县| 仁布县| 耒阳市| 团风县| 中方县| 榆林市| 闻喜县|