Giter Site home page Giter Site logo

ntcuong2103 / cocr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xuguodong1999/cocr

2.0 1.0 0.0 103.73 MB

OCR/OCSR on handwritting ⏣/chemical-structural-formulas with YOLO & CRNN models.

License: GNU General Public License v3.0

CMake 0.53% C++ 93.44% C 1.01% QML 0.01% HTML 0.06% CSS 0.01% TypeScript 0.38% JavaScript 0.38% Python 4.18%

cocr's Introduction

COCR

License support-wasm support-android support-windows support-linux support-macos

COCR is designed to convert an image of hand-writing chemical structure to graph of that molecule.

COCR, Optical Character Recognition for Chemical Structures, was once a demo for my undergraduate graduation thesis in 2021.6. It brings OCSR(optical chemical structure recognition) capability into handwriting cases. Below is a summary of supported items.

symbol strings ring solid L hash L wavy L single L double L triple L
looks like (CH2)2COOEt ~~ / // ///
supported ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

COCR is developed under Qt framework. It handles images with YOLO and CRNN models using opencv or ncnn backend.

In this repository, you can find stable version from release pages. Master branch is under development as it is not robust enough yet.

Features

v1.1

  • Add support on strings and wavy bond.
v1.1.on.Ubuntu.mp4

v1.0

Input Detection Render
png png png
  • Support single element symbols: C、H、O、N、P、B、S、F、Cl、Br、I.
  • Support bond types: single, double, triple, hash wedge, solid wedge, circle.

Architecture

Flow Chart

Build from source

OpenCV ≥4.5.1, Qt =5.15.2 are required for a minimal build.

git clone https://github.com/xuguodong1999/COCR.git
cd COCR && mkdir build && cd build

cmake .. -G "Ninja" \
  -DQt5_DIR:PATH=path/to/Qt/5.15.2/gcc_64/lib/cmake/Qt5 \
  -DOpenCV_DIR:PATH=path/to/opencv4/lib/cmake/opencv4

cmake --build . --parallel --config Release --target leafxy

Build opencv from source

Build libtorch from source

Data generation

COCR uses SCUT-COUCH2009 as meta handwriting data, and uses QtGui::QTextDocument as rich text renderer.

A chemical structure generator for handwriting cases is written to provider training data for YOLO and CRNN models, which composes meta-character into random chemical structure formulas. You can find related codes under src/data_gen.

After a minimal build above, a data_gen(.exe) can be found under $(BUILD_DIR)/out. There are following usages:

  1. Double click or run from shell WITHOUT arguments
this will display samples with cv::imshow
  1. Run with -yolo [number of samples] [an empty, existing directory path], for example,
# generate 10 object detection samples under ./yolo/
./data_gen -yolo 10 ./
  1. Run with -crnn [number of samples] [an empty, existing directory path], for example,
# generate 10 text recognition samples under ./crnn/
./data_gen -crnn 10 ./
  1. Run with -isomer [number of samples] [an empty, existing directory path], for example,
# generate all alkane isomers for C-num ≤ 16 namely {CARBON_NUM}.dat under ./
# dont play with number over 20 without taking a look at src/data_gen/isomers.cpp.
# it may comsume a lot of memory and cpus.
./data_gen -isomer 16 ./

License

GPLv3 Clause

cocr's People

Contributors

xuguodong1999 avatar

Stargazers

 avatar Cuong Tuan Nguyen 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.