Giter Site home page Giter Site logo

pablopicassogg / topsup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wowliao/topsup

0.0 1.0 0.0 1.81 MB

本程序抄至Skyexu的TopSup,仅修改了说明文档和部分代码以适配Mac+iOS。原文链接:

Home Page: https://github.com/Skyexu/TopSup

Python 100.00%

topsup's Introduction

答题辅助(Mac+iOS)

可用APP:冲顶大会、芝士超人、西瓜视频。 注:不同的APP需更改 common/ocr.py 中的分辨率。

非常感谢关注,欢迎大家PR新的想法和优化。

版本说明

  • 谷歌 Tesseract

具体做法

  1. 获取手机截屏

  2. OCR 识别题目与选项文字

​ 两个方法:

  • 谷歌 Tesseract ,安装软件即可,接下来主要使用这个方法
  • 百度 OCR需要注册百度 API,每天调用次数有限
  1. 搜索判断

结果判断方式

  1. 直接打开浏览器搜索问题
  2. 题目+每个选项都通过搜索引擎搜索,从网页代码中提取搜索结果计数
  3. 只用题目进行搜索,统计结果页面代码中包含选项的词频

以下为两个示例结果

参考了 I Hacked HQ Trivia But Here’s How They Can Stop Me

使用步骤 (谷歌 Tesseract)

Mac+IOS

1. 安装 WebDriverAgent

教程:https://github.com/wowliao/TopSup/wiki/WebDriveAgent%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B

2. 安装 python 3

3. 安装所需 python 包

pip install pytesseract pip install pillow
pip install requests pip install colorama

4. 安装 python-wda

安装 python-wda

5. 安装 谷歌 Tesseract

https://github.com/tesseract-ocr/tesseract/wiki

6. 修改 common/ocr.py 代码相应目录信息

# 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'

7. 运行脚本

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 芝士超人,西瓜视频

topsup's People

Contributors

wowliao avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.