轻量级公式 OCR 小工具:一键识别各类公式图片,并转换为 LaTeX 格式

Overview

QC-Formula | 青尘公式 OCR

介绍

0_QCFormula.png

轻量级开源公式 OCR 小工具:一键识别公式图片,并转换为 LaTeX 格式。

  • 支持从 电脑本地 导入公式图片;(后续版本将支持直接从网页导入图片)
  • 公式图片支持 .png / .jpg / .bmp,大小为 4M 以内均可;
  • 支持印刷体手写体,前者识别效果更佳。

软件下载地址:https://github.com/QingchenWait/QC-Formula/releases

1 软件架构

  • 软件基于 Python 3.7 开发,界面基于 PyQt 5,项目 完全开源
  • 软件在 macOS 10.15.1 、Windows 10 测试通过,Linux 平台用户亦可自行编译。

2 使用教程

2.1 获取 API(必需)

本软件调用了 讯飞 的 API(后续有望增加更多源,以提高准确率),目前的免费额度为 500次 / 天,可以满足个人用户的使用需求。

在进行识别前,需要先自行申请 API 额度,然后在软件的 设置 页面,填写获得的 API。

API 的获取方法如下:

  1. 进入讯飞开放平台注册页面,注册一个新的账号;

  2. 进入公式识别业务页面,可以在首页顶栏的 “产品服务 - 文字识别 - 公式识别” 中找到;

    1_mainpage.png
  3. 点击 “服务管理”,会提示创建一个应用(如果之前没有账号的话),界面如下图所示。

    依次填写 “应用名称”、“应用分类” 与 “应用功能描述” 项,可以按自己喜好任意填写。

    2_CreateAPP.png
  4. 点击 “提交” ,即可进入服务管理页面,如下图所示。

    右侧的 APPIDAPISecretAPIKey 三项,即是我们需要的 API 值。

    3_APIInfo_B.png

2.2 将获取的 API 填入软件

  • 进入软件,点击 设置 页面,可以看到如下图所示的界面。

  • 将获取到的 APPIDAPISecretAPIKey 三项,分别填入对应的位置,然后点击 确定

至此,软件已经配置成功!可以选择需要的公式,进行识别了!

3 开发说明

3.1 软件需求

  • Python IDE 及环境:PyCharm Community 2020.2 + Python 3.7

    • 建议新建项目及 venv 虚拟环境进行开发。
    • 注意:在上述开发环境中,较高的 pip 版本似乎会导致在 PyCharm 中添加包失败。如果出现了同样的错误,请使用命令行将 pip 版本手动降级至 20.2.4 及以下,或尝试使用最新版本的 PyCharm。
  • GUI 编辑工具:PyQt5

    • 安装 Qt Designer,随后在 对应的 PyCharm 工程中配置 External Tools:Qt Designer 、 PyUIC 与 PyRcc。

    • 可参照下列教程进行配置:

      PyCharm 安装 PyQt5 及其工具(Qt Designer、PyUIC、PyRcc)详细教程

    • 若不需要使用 Qt Designer 进行可视化开发,或不打算对界面 GUI 进行修改,可以不安装 pyqt5-tools 包,在配置 External Tools 的过程中也不需要配置 Qt Designer 与 PyUIC 项。

3.2 文件树

  • /Examples :存放示例图片。
  • main_v104.py:软件主程序。
    • 此文件调用了 Init_Window_v104.pyOCR_iFLY_v104.py 中定义的类。
  • Init_Window_v104.py:PyQt GUI 控件定义及绘制源码,使用 PyUIC 生成。
  • Init_Window_v104.ui:Qt 窗口样式文件,可使用 Qt Designer 打开及编辑。
  • OCR_iFLY_v104.py:定义公式识别相关后端函数(讯飞接口)。
  • config.ini:配置文件,存放公式图片路径及 API 参数。
  • requirements.txt:程序的依赖项列表。

3.3 依赖配置

  • 程序的第三方依赖项已经包含在根目录的 requirements.txt 文档中,使用 pipreqs 生成。

  • 除此之外,还包含一个使用 pip freeze 命令生成的 requirements_all.txt 文档,包含此程序所需的所有依赖包。

    可以根据需求,选用以上两个文档中的一个。

  • 文档的使用方式:

    在命令行或使用 PyCharm 建立的虚拟环境中,使用以下命令:pip install -r requirements.txt

3.4 调试方法

  • 在 PyCharm 等 IDE 中,使用 requirements.txt 安装好相关依赖,随后运行 main_v104.py ,即可运行程序。
  • 程序的部分运行状态(如图片加载状态、公式识别结果完整 JSON 文本等)会输出到终端中,便于实时查看和调试。

4 目前已知的问题

  • 请勿使用 Windows 记事本直接编辑及保存 config.ini 配置文件!!!
    • 原因:Windows 记事本默认使用 ANCI 编码方式保存文件,而本程序使用 utf-8 编码格式读取,在读取中文路径 的时候会产生冲突。
    • 报错解决方式:若程序无法打开,并提示:UnicodeDecodeError:'utf-8' code can't ... ,则执行以下步骤:
      1. 使用记事本打开 config.ini 文件,选择 “文件 - 另存为”;
      2. 文件名填写 “config.ini”,保存类型填写 “所有文件”,最下方的编码选择 “utf-8”。
      3. 确认替换,重新打开软件即可。
  • 对于结构比较复杂的公式,识别准确率不高。后续将尝试引入其他识别 API 以提高准确率。

5 参与贡献

这个软件的界面和功能还非常原始,随时欢迎大家对它进行后续的开发。

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

6 关于作者

软件作者:青尘工作室

官方网站:https://qingchen1995.gitee.io

本程序 GitHub 仓库地址:https://github.com/QingchenWait/QC-Formula

本程序码云地址:https://gitee.com/qingchen1995/qc-formula

You might also like...
A pure pytorch implemented ocr project including text detection and recognition
A pure pytorch implemented ocr project including text detection and recognition

ocr.pytorch A pure pytorch implemented ocr project. Text detection is based CTPN and text recognition is based CRNN. More detection and recognition me

python ocr using tesseract/ with EAST opencv detector

pytextractor python ocr using tesseract/ with EAST opencv text detector Uses the EAST opencv detector defined here with pytesseract to extract text(de

Run tesseract with the tesserocr bindings with @OCR-D's interfaces

ocrd_tesserocr Crop, deskew, segment into regions / tables / lines / words, or recognize with tesserocr Introduction This package offers OCR-D complia

A set of workflows for corpus building through OCR, post-correction and normalisation
A set of workflows for corpus building through OCR, post-correction and normalisation

PICCL: Philosophical Integrator of Computational and Corpus Libraries PICCL offers a workflow for corpus building and builds on a variety of tools. Th

Tensorflow-based CNN+LSTM trained with CTC-loss for OCR

Overview This collection demonstrates how to construct and train a deep, bidirectional stacked LSTM using CNN features as input with CTC loss to perfo

🖺 OCR using tensorflow with attention

tensorflow-ocr 🖺 OCR using tensorflow with attention, batteries included Installation git clone --recursive http://github.com/pannous/tensorflow-ocr

This is the implementation of the paper
This is the implementation of the paper "Gated Recurrent Convolution Neural Network for OCR"

Gated Recurrent Convolution Neural Network for OCR This project is an implementation of the GRCNN for OCR. For details, please refer to the paper: htt

A tool for extracting text from scanned documents (via OCR), with user-defined post-processing.

The project is based on older versions of tesseract and other tools, and is now superseded by another project which allows for more granular control o

MXNet OCR implementation. Including text recognition and detection.

insightocr Text Recognition Accuracy on Chinese dataset by caffe-ocr Network LSTM 4x1 Pooling Gray Test Acc SimpleNet N Y Y 99.37% SE-ResNet34 N Y Y 9

Releases(v1.0.4)
  • v1.0.4(Dec 24, 2021)

    青尘公式 OCR 的第一个发行版,基于 v1.0.4 版本源码,使用 PyInstaller 编译并打包。

    • 适用系统:
      • Windows / macOS 系统,可以下载对应版本的 zip 压缩包。Linux 平台用户可下载源码并自行编译打包。
      • 在 Windows 10 / macOS 10.15 平台测试通过,其余版本系统的兼容性暂时未测试。
    • 使用方法:
      • Windows 系统:下载并解压 QC-Formula-v1.0.4-win10-64bit.zip 压缩包,打开 青尘公式 OCR.exe 即可运行。
      • macOS 系统:下载并解压 QC-Formula-v1.0.4-macOS10.15-64bit.zip 压缩包,打开 QC-Formula-v104.exec 即可运行。
      • 首次打开后,需要进行公式识别 API 的配置。 方法可以参考:使用教程
    • v1.0.4 更新与修复:
      1. 修改了部分 PyQt 控件尺寸,使控件在 1920x1080 分辨率屏幕中,也能够以相对正常的尺寸显示。
      2. 修复了 Windows 系统下,当路径存在中文时,程序闪退的问题。(如果依然发生闪退,可以参考:解决方案
    Source code(tar.gz)
    Source code(zip)
    QC-Formula-v1.0.4-macOS10.15-64bit.zip(34.37 MB)
    QC-Formula-v1.0.4-win10-64bit.zip(34.89 MB)
Owner
青尘工作室
一个喜欢做有趣事情的工作室。
青尘工作室
A Tensorflow model for text recognition (CNN + seq2seq with visual attention) available as a Python package and compatible with Google Cloud ML Engine.

Attention-based OCR Visual attention-based OCR model for image recognition with additional tools for creating TFRecords datasets and exporting the tra

Ed Medvedev 933 Dec 29, 2022
Using python libraries to track hands

Python-HandTracking Using python libraries to track hands on a camera Uses cv2 and mediapipe libraries custom hand tracking module PyCharm IDE Final E

Martin Matsudaira 1 Dec 17, 2021
Demo for the paper "Overlap-aware low-latency online speaker diarization based on end-to-end local segmentation"

Streaming speaker diarization Overlap-aware low-latency online speaker diarization based on end-to-end local segmentation by Juan Manuel Coria, Hervé

Juanma Coria 185 Jan 01, 2023
Course material for the Multi-agents and computer graphics course

TC2008B Course material for the Multi-agents and computer graphics course. Setup instructions Strongly recommend using a custom conda environment. Ins

16 Dec 13, 2022
Train custom VR face tracking parameters

Pal Buddy Guy: The anipal's best friend This is a small script to improve upon the tracking capabilities of the Vive Pro Eye and facial tracker. You c

7 Dec 12, 2021
Code for the paper "Controllable Video Captioning with an Exemplar Sentence"

SMCG Code for the paper "Controllable Video Captioning with an Exemplar Sentence" Introduction We investigate a novel and challenging task, namely con

10 Dec 04, 2022
scene-linear test images

Scene-Referred Image Collection A collection of OpenEXR Scene-Referred images, encoded as max 2048px width, DWAA 80 compression. All exrs are encoded

Gralk Klorggson 7 Aug 25, 2022
TextBoxes: A Fast Text Detector with a Single Deep Neural Network https://github.com/MhLiao/TextBoxes 基于SSD改进的文本检测算法,textBoxes_note记录了之前整理的笔记。

TextBoxes: A Fast Text Detector with a Single Deep Neural Network Introduction This paper presents an end-to-end trainable fast scene text detector, n

zhangjing1 24 Apr 28, 2022
Visual Attention based OCR

Attention-OCR Authours: Qi Guo and Yuntian Deng Visual Attention based OCR. The model first runs a sliding CNN on the image (images are resized to hei

Yuntian Deng 1.1k Jan 02, 2023
color detection using python

colordetection color detection using python In this color detection Python project, we are going to build an application through which you can automat

Ruchith Kumar 1 Nov 04, 2021
This is a GUI for scrapping PDFs with the help of optical character recognition making easier than ever to scrape PDFs.

pdf-scraper-with-ocr With this tool I am aiming to facilitate the work of those who need to scrape PDFs either by hand or using tools that doesn't imp

Jacobo José Guijarro Villalba 75 Oct 21, 2022
Fully-automated scripts for collecting AI-related papers

AI-Paper-Collector Web demo: https://ai-paper-collector.vercel.app/ (recommended) Colab notebook: here Motivation Fully-automated scripts for collecti

772 Dec 30, 2022
Text layer for bio-image annotation.

napari-text-layer Napari text layer for bio-image annotation. Installation You can install using pip: pip install napari-text-layer Keybindings and m

6 Sep 29, 2022
Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Visual Behavior 86 Dec 28, 2022
Binarize document images

Binarization Binarization for document images Examples Introduction This tool performs document image binarization (i.e. transform colour/grayscale to

QURATOR-SPK 48 Jan 02, 2023
Hiiii this is the Spanish for Linux and win 10 and in the near future the english version of PortScan my new tool on which you can see what ports are Open only with the IP adress.

PortScanner-by-IIT PortScanner es una herramienta programada en Python3. Como su nombre indica esta herramienta escanea los primeros 150 puertos de re

5 Sep 19, 2022
Motion detector, Full body detection, Upper body detection, Cat face detection, Smile detection, Face detection (haar cascade), Silverware detection, Face detection (lbp), and Sending email notifications

Security camera running OpenCV for object and motion detection. The camera will send email with image of any objects it detects. It also runs a server that provides web interface with live stream vid

Peace 10 Jun 30, 2021
POT : Python Optimal Transport

This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning.

Python Optimal Transport 1.7k Jan 04, 2023
Run tesseract with the tesserocr bindings with @OCR-D's interfaces

ocrd_tesserocr Crop, deskew, segment into regions / tables / lines / words, or recognize with tesserocr Introduction This package offers OCR-D complia

OCR-D 38 Oct 14, 2022