[心得] 分享 台鐵驗證碼辨識/轉文字 package
https://github.com/linsamtw/TaiwanTrainVerificationCode2text
分享我開發的 package,台鐵驗證碼( 辨識 )轉文字
可直接 pip3 install TaiwanTrainVerificationCode2text
提供各位開發程式訂票,其中驗證碼破解部分的方法,可直接使用此 package 辨識,不
須再回傳 image 用人工方式辨識。
test data 準確率約為 88%,使用 10 萬張圖進行 training
----------------------------------------------------------
demo :
input
https://imgur.com/aCmz45y.jpg
output
WNBA8S
---------------------------------------------------------
使用方法如下
import os
from TaiwanTrainVerificationCode2text import verification_code2text
from TaiwanTrainVerificationCode2text import work_vcode
from TaiwanTrainVerificationCode2text import download
import TaiwanTrainVerificationCode2text
PATH = TaiwanTrainVerificationCode2text.__path__[0]
import cv2
import matplotlib.pyplot as plt
import random
# 下載我 train 好的 weight,ttf 是驗證碼字形,用於以下生成模擬驗證碼
download.weight()
download.ttf()
# 生成模擬驗證碼
work_vcode.work_vcode_fun(10,'test_data',5)
work_vcode.work_vcode_fun(10,'test_data',6)
file_path = '{}/{}/'.format(PATH,'test_data')
train_image_path = [file_path + i for i in os.listdir(file_path+'/')]
# 隨機取一個當作 demo
image_name = train_image_path[random.sample(range(len(train_image_path)),1)[0]]
# 讀取圖片
image = cv2.imread(image_name)
# 畫圖
plt.imshow(image)
# 辨識,驗證碼轉文字
text = verification_code2text.main(image)
# 印出最後結果
print(text)
ps : 使用 keras 進行建模預測,並將 train 好的 weight 提供下載使用
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.233.85.190
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1550414128.A.575.html
推
02/17 23:46,
5年前
, 1F
02/17 23:46, 1F
推
02/18 00:35,
5年前
, 2F
02/18 00:35, 2F
→
02/18 00:36,
5年前
, 3F
02/18 00:36, 3F
→
02/18 00:38,
5年前
, 4F
02/18 00:38, 4F
→
02/18 00:38,
5年前
, 5F
02/18 00:38, 5F
→
02/18 00:41,
5年前
, 6F
02/18 00:41, 6F
程式訂票嗎? 用 requests or selenium 可以實現,selenium 會比較簡單
※ 編輯: f496328mm (118.233.85.190), 02/18/2019 00:52:53
推
02/18 00:59,
5年前
, 7F
02/18 00:59, 7F
推
02/18 11:50,
5年前
, 8F
02/18 11:50, 8F
→
02/18 11:52,
5年前
, 9F
02/18 11:52, 9F
→
02/18 11:52,
5年前
, 10F
02/18 11:52, 10F
→
02/18 11:53,
5年前
, 11F
02/18 11:53, 11F
→
02/18 11:53,
5年前
, 12F
02/18 11:53, 12F
我之前是用 fb chatbot 設計
fb 負責傳遞 訂票需求(keyowrd)、資訊、訂票成功截圖
後端交給 python 處理
基本上手機 app 應該也是,有興趣可以私信討論
※ 編輯: f496328mm (60.248.26.145), 02/18/2019 12:51:43
推
02/18 13:03,
5年前
, 13F
02/18 13:03, 13F
推
02/19 20:06,
5年前
, 14F
02/19 20:06, 14F
推
02/20 02:54,
5年前
, 15F
02/20 02:54, 15F
噓
02/20 11:22,
5年前
, 16F
02/20 11:22, 16F
推
02/20 12:39,
5年前
, 17F
02/20 12:39, 17F
→
02/20 12:39,
5年前
, 18F
02/20 12:39, 18F