可用APP:冲顶大会、芝士超人、西瓜视频。 注:不同的APP需更改 common/ocr.py 中的分辨率。
非常感谢关注,欢迎大家PR新的想法和优化。
- 谷歌 Tesseract
-
获取手机截屏
-
OCR 识别题目与选项文字
两个方法:
- 搜索判断
以下为两个示例结果
参考了 I Hacked HQ Trivia But Here’s How They Can Stop Me
使用步骤 (谷歌 Tesseract)
教程:https://github.com/wowliao/TopSup/wiki/WebDriveAgent%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B
pip install pytesseract
pip install pillow
pip install requests
pip install colorama
安装 python-wda
https://github.com/tesseract-ocr/tesseract/wiki
# mac 环境 记得自己安装训练文件
# tesseract 路径
#pytesseract.pytesseract.tesseract_cmd = '/usr/local/Cellar/tesseract/3.05.01/bin/tesseract'
# 语言包目录和参数
#tessdata_dir_config = '--tessdata-dir "/usr/local/Cellar/tesseract/3.05.01/share/tessdata/" --psm 6'
python GetQuestionTessIos.py
注:若Mac中有Python2和Python3:python3 GetQuestionTessIos.py
会自动识别文字并打开浏览器
注: 可以用 GetImgTool.py
调整题目截取位置
若屏幕分辨率不同,请在 ocr.py
中自行修改代码即可
# 切割题目和选项位置,左上角坐标和右下角坐标,自行测试分辨率
#question_im = image.crop((45, 425, 1150, 780)) # iPhone 7P 冲顶大会
question_im = image.crop((45, 240, 1200, 600)) # iPhone 7P 芝士超人,西瓜视频
#choices_im = image.crop((45, 790, 1167, 1450)) # iPhone 7P 冲顶大会
choices_im = image.crop((58, 580, 1216, 1280)) # iPhone 7P 芝士超人,西瓜视频