轻量级公式 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
青尘工作室
一个喜欢做有趣事情的工作室。
青尘工作室
RepMLP: Re-parameterizing Convolutions into Fully-connected Layers for Image Recognition

RepMLP RepMLP: Re-parameterizing Convolutions into Fully-connected Layers for Image Recognition Released the code of RepMLP together with an example o

260 Jan 03, 2023
APS 6º Semestre - UNIP (2021)

UNIP - Universidade Paulista Ciência da Computação (CC) DESENVOLVIMENTO DE UM SISTEMA COMPUTACIONAL PARA ANÁLISE E CLASSIFICAÇÃO DE FORMAS Link do git

Eduardo Talarico 5 Mar 09, 2022
Implement 'Single Shot Text Detector with Regional Attention, ICCV 2017 Spotlight'

SSTDNet Implement 'Single Shot Text Detector with Regional Attention, ICCV 2017 Spotlight' using pytorch. This code is work for general object detecti

HotaekHan 84 Jan 05, 2022
The virtual calculator will be above the live streaming from your camera

The virtual calculator is above the live streaming from my camera usb , the program first detect my hand and in each frame calculate the distance between two finger ,if the distance is lower than the

gasbaoui mohammed al amine 5 Jul 01, 2022
([email protected]) Boosting Co-teaching with Compression Regularization for Label Noise

Nested-Co-teaching ([email protected]) Pytorch implementation of paper "Boosting Co-tea

YINGYI CHEN 41 Jan 03, 2023
The Open Source Framework for Machine Vision

SimpleCV Quick Links: About Installation [Docker] (#docker) Ubuntu Virtual Environment Arch Linux Fedora MacOS Windows Raspberry Pi SimpleCV Shell Vid

Sight Machine 2.6k Dec 31, 2022
Developed an AI-based system to control the mouse cursor using Python and OpenCV with the real-time camera.

Developed an AI-based system to control the mouse cursor using Python and OpenCV with the real-time camera. Fingertip location is mapped to RGB images to control the mouse cursor.

Ravi Sharma 71 Dec 20, 2022
Augmenting Anchors by the Detector Itself

Augmenting Anchors by the Detector Itself Introduction It is difficult to determine the scale and aspect ratio of anchors for anchor-based object dete

4 Nov 06, 2022
Python package for handwriting and sketching in Jupyter cells

ipysketch A Python package for handwriting and sketching in Jupyter notebooks. Usage A movie is worth a thousand pictures is worth a million words...

Matthias Baer 16 Jan 05, 2023
A curated list of papers and resources for scene text detection and recognition

Awesome Scene Text A curated list of papers and resources for scene text detection and recognition The year when a paper was first published, includin

Jan Zdenek 43 Mar 15, 2022
A simple OCR API server, seriously easy to be deployed by Docker, on Heroku as well

ocrserver Simple OCR server, as a small working sample for gosseract. Try now here https://ocr-example.herokuapp.com/, and deploy your own now. Deploy

Hiromu OCHIAI 541 Dec 28, 2022
Memory tests solver with using OpenCV

Human Benchmark project This project is OpenCV based programs which are puzzle solvers for 7 different games for https://humanbenchmark.com/. made as

Bahadır Araz 24 Dec 27, 2022
Hand Detection and Finger Detection on Live Feed

Hand-Detection-On-Live-Feed Hand Detection and Finger Detection on Live Feed Getting Started Install the dependencies $ git clone https://github.com/c

Chauhan Mahaveer 2 Jan 02, 2022
Official code for :rocket: Unsupervised Change Detection of Extreme Events Using ML On-Board :rocket:

RaVAEn The RaVÆn system We introduce the RaVÆn system, a lightweight, unsupervised approach for change detection in satellite data based on Variationa

SpaceML 35 Jan 05, 2023
When Age-Invariant Face Recognition Meets Face Age Synthesis: A Multi-Task Learning Framework (CVPR 2021 oral)

MTLFace This repository contains the PyTorch implementation and the dataset of the paper: When Age-Invariant Face Recognition Meets Face Age Synthesis

Hzzone 120 Jan 05, 2023
EQFace: An implementation of EQFace: A Simple Explicit Quality Network for Face Recognition

EQFace: A Simple Explicit Quality Network for Face Recognition The first face recognition network that generates explicit face quality online.

DeepCam Shenzhen 141 Dec 31, 2022
Handwritten Text Recognition (HTR) system implemented with TensorFlow.

Handwritten Text Recognition with TensorFlow Update 2021: more robust model, faster dataloader, word beam search decoder also available for Windows Up

Harald Scheidl 1.5k Jan 07, 2023
A python programusing Tkinter graphics library to randomize questions and answers contained in text files

RaffleOfQuestions Um programa simples em python, utilizando a biblioteca gráfica Tkinter para randomizar perguntas e respostas contidas em arquivos de

Gabriel Ferreira Rodrigues 1 Dec 16, 2021
Characterizing possible failure modes in physics-informed neural networks.

Characterizing possible failure modes in physics-informed neural networks This repository contains the PyTorch source code for the experiments in the

Aditi Krishnapriyan 55 Jan 02, 2023
Deskewing images with slanted content

skew_correction De-skewing images with slanted content by finding the deviation using Canny Edge Detection. To Run: In python 3.6, from deskew import

13 Aug 27, 2022