黄色网站入口国产美女,精品国产欧美另类一区,国产一区二区美女自慰,日日摸夜夜添无码国产

選擇你喜歡的標(biāo)簽
我們會(huì)為你匹配適合你的網(wǎng)址導(dǎo)航

    確認(rèn) 跳過(guò)

    跳過(guò)將刪除所有初始化信息

    您的位置:0XUCN > 資訊 > 技術(shù)
    新聞分類

    DdddOcr自動(dòng)打碼通用驗(yàn)證碼自動(dòng)識(shí)別庫(kù)

    技術(shù) PRO 作者:嗜寵而嬌 2022-08-16 17:30

    在Python爬蟲(chóng)中,或者使用POST提交的過(guò)程中,往往需要提交驗(yàn)證碼來(lái)驗(yàn)證,除了人工打碼,付費(fèi)的api接口(打碼接口),深度學(xué)習(xí)識(shí)別驗(yàn)證碼,當(dāng)然還有適合新人使用的OCR驗(yàn)證碼識(shí)別庫(kù),簡(jiǎn)單的驗(yàn)證碼是可以完全實(shí)現(xiàn)自動(dòng)打碼的,比如下面本渣渣分享的通用驗(yàn)證碼自動(dòng)識(shí)別庫(kù):ddddocr(帶帶弟弟OCR)!

    DdddOcr庫(kù)安裝

    pip install ddddocr

    想要更快,使用國(guó)內(nèi)鏡像安裝:

    pip install ddddocr -i https://pypi.tuna.tsinghua.edu.cn/simple

    DdddOcr庫(kù)用法

    參數(shù)說(shuō)明 DdddOcr 接受兩個(gè)參數(shù)

    參數(shù)名默認(rèn)值說(shuō)明 use_gpu FalseBool 是否使用gpu進(jìn)行推理,如果該值為False則device_id不生效 device_id 0 int cuda設(shè)備號(hào),目前僅支持單張顯卡

    classification 參數(shù)名默認(rèn)值 說(shuō)明 img 0 bytes 圖片的bytes格式

    參考源碼:

    import ddddocrocr = ddddocr.DdddOcr()with open('code.png', 'rb') as f: ? ?img_bytes = f.read()res = ocr.classification(img_bytes)print(res)

    DdddOcr實(shí)戰(zhàn)

    網(wǎng)站評(píng)論提交

    url:https://www.feifeidm.com/Play/10919-0-0.html

    驗(yàn)證碼地址:https://www.feifeidm.com/include/vdimgck.php?r=0.7145461007261535

    參考源碼:

    import ddddocrimport requestsheaders = { ? ?"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}code_url="https://www.feifeidm.com/include/vdimgck.php?r=0.7145461007261535"r=requests.get(url=code_url,headers=headers,timeout=5)with open('code.png','wb')as f: ? ?f.write(r.content) ? ?print("下載驗(yàn)證碼成功!")ocr = ddddocr.DdddOcr()#with open(r'C:\Users\Administrator\Desktop\驗(yàn)證碼識(shí)別\code.png', 'rb') as f: ? ?#img_bytes = f.read()img_bytes=r.contentres = ocr.classification(img_bytes)print(res)

    搜狗快照刪除/提交

    url:http://fankui.help.sogou.com/index.php/web/web/index?type=2

    擴(kuò)展:其他適合新人的ocr識(shí)別庫(kù)

    pytesseract ytesseract需要配合安裝在本地的tesseract-ocr.exe文件一起使用,Tesseract Ocr文字識(shí)別,需要注意的是安裝時(shí)一定要選中中文包,默認(rèn)是只支持英文識(shí)別。

    庫(kù)安裝:

    pip install pytesseract

    庫(kù)用法:

    import pytesseractfrom PIL import Imagetext = pytesseract.image_to_string(Image.open(code.png"))print(text)

    PaddleOCR addleOCR是百度開(kāi)源的一款基于深度學(xué)習(xí)的ocr識(shí)別庫(kù),對(duì)中文的識(shí)別精度相當(dāng)不錯(cuò),可以應(yīng)付絕大多數(shù)的文字提取需求。

    庫(kù)安裝:需要依次安裝三個(gè)依賴庫(kù),安裝命令如下,其中shapely庫(kù)可能會(huì)受系統(tǒng)影響安裝報(bào)錯(cuò)。

    pip install paddlepaddlepip install shapelypip install paddleocr

    庫(kù)用法:

    ocr = PaddleOCR(use_angle_cls=True, lang="ch")# 輸入待識(shí)別圖片路徑img_path = r"code.png"# 輸出結(jié)果保存路徑result = ocr.ocr(img_path, cls=True)for line in result: ? ?print(line)from PIL import Imageimage = Image.open(img_path).convert('RGB')boxes = [line[0] for line in result]txts = [line[1][0] for line in result]scores = [line[1][1] for line in result]im_show = draw_ocr(image, boxes, txts, scores)im_show = Image.fromarray(im_show)im_show.show()

    easyocr github上一萬(wàn)多個(gè)star的開(kāi)源ocr項(xiàng)目,支持80多種語(yǔ)言的識(shí)別,識(shí)別精度超高。

    庫(kù)安裝:

    pip install easyocr

    庫(kù)用法:

    import easyocr#設(shè)置識(shí)別中英文兩種語(yǔ)言reader = easyocr.Reader(['ch_sim','en'], gpu = False) # need to run only once to load model into memoryresult = reader.readtext(r"code.png", detail = 0)print(result)

    muggle_ocr muggle_ocr是一款輕量級(jí)的ocr識(shí)別庫(kù),從名字也可以看出來(lái),專為麻瓜設(shè)計(jì)!使用也非常簡(jiǎn)單,但其強(qiáng)項(xiàng)主要是用于識(shí)別各類驗(yàn)證碼,一般文字提取效果就稍差了。

    庫(kù)安裝:

    pip install muggle_ocr

    庫(kù)用法:

    import muggle_ocr# 初始化sdk;model_type 包含了 ModelType.OCR/ModelType.Captcha 兩種模式,分別對(duì)應(yīng)常規(guī)圖片與驗(yàn)證碼sdk = muggle_ocr.SDK(model_type=muggle_ocr.ModelType.Captcha)with open(r"code.png", "rb") as f: ? ?img = f.read()text = sdk.predict(image_bytes=img)print(text)


    0XU.CN

    [超站]友情鏈接:

    四季很好,只要有你,文娛排行榜:https://www.yaopaiming.com/
    關(guān)注數(shù)據(jù)與安全,洞悉企業(yè)級(jí)服務(wù)市場(chǎng):https://www.ijiandao.com/

    圖庫(kù)
    公眾號(hào) 關(guān)注網(wǎng)絡(luò)尖刀微信公眾號(hào)
    隨時(shí)掌握互聯(lián)網(wǎng)精彩
    贊助鏈接