Coder Social home page Coder Social logo

curve-text-rectification-using-pairs-of-points's Introduction

Curve-Text-Rectification-Using-Pairs-Of-Points

This repository is designed via traditional image processing, not deep learning.

It's a way to rectify curve text images using spatial transformer by pairs of points. This could be rectify the curve text image after text detection, and helps text recognition easily in OCR tasks.

This method is based on calibration technology of monocular vision. It depends on pairs of points by detector just like CRAFT.

Requirements

  • numpy
  • opencv-python

Usage

python3 test.py --image image_path --txt points_txt_path_corresponding_to_image --mode calibration
python3 test.py --image ./data/test_images/gt_86.jpg --txt ./data/test_txt/gt_86.txt --mode calibration

or

python3 curve_text_rectification.py --mode homography

Results will saved in results directory.

mode description
calibration Monocular Vision: 3-D model and fish-eye camera undistortion.
homography Split a curve text region up into several sub-4-points-bounding-box-images, homography transform and stitch. Higher FPS and lower precision

Interface

from curve_text_rectification import AutoRectifier
autoRectifier = AutoRectifier()

"""
run for texts in an image
:param image_data: numpy.ndarray. The shape is [h, w, 3]
:param points_list: [[x1,y1,x2,y2,x3,y3,...], [x1,y1,x2,y2,x3,y3,...], ...], clockwise order, (x1,y1) must be the top-left of first char.
:param interpolation: cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_AREA, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4
:param ratio_width:  roi_image width expansion. It should not be smaller than 1.0
:param ratio_height: roi_image height expansion. It should not be smaller than 1.0
:param loss_thresh: if loss greater than loss_thresh --> get_rotate_crop_image
:param mode: 'calibration' or 'homography'. when homography, ratio_width and ratio_height must be 1.0
:return: res: roi-image list, visualized_image: draw polys in original image
"""
res, visualized_image = autoRectifier.run(image_data, points_list, interpolation=cv2.INTER_LINEAR, ratio_width=1.0, ratio_height=1.0, loss_thresh=5.0, mode='calibration')

Demo

1

2

3

4

5

calibration failure

homography

Reference

curve-text-rectification-using-pairs-of-points's People

Contributors

frotms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

curve-text-rectification-using-pairs-of-points's Issues

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.