Skip to content

added tutorial for text skewness correction - #16170

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
themechanicalcoder:tutorial_1
Jan 24, 2020
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
themechanicalcoder:tutorial_1

Conversation

@themechanicalcoder

@themechanicalcoder themechanicalcoder commented Dec 16, 2019 •

Copy link
Copy Markdown
Contributor

This pull request changes

Given an image containing a rotated block of text at an unknown angle in an image, it corrects the text skew by

  1. Detecting the block of text in the image .
  2. Computing the angle of the rotated text
  3. Rotating the image to correct for the skew.
    Before

    image
    After

    corrected

@asmorkalov asmorkalov added category: samples pr: needs rebase Rebase patch (and squash fixup commits) on the top of target branch labels Dec 16, 2019
@asmorkalov

Copy link
Copy Markdown
Contributor

This patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

@asmorkalov asmorkalov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@themechanicalcoder thanks for the example code. OpenCV repository already contains image with rotated text opencv/samples/data/imageTextR.png. Could you set it as default path to image. Ready to use example with example input makes things simpler.

@themechanicalcoder
themechanicalcoder changed the base branch from master to 3.4 December 23, 2019 09:31
@themechanicalcoder
themechanicalcoder changed the base branch from 3.4 to master December 23, 2019 14:29
@themechanicalcoder
themechanicalcoder changed the base branch from master to 3.4 December 23, 2019 14:29
@themechanicalcoder
themechanicalcoder changed the base branch from 3.4 to master December 23, 2019 15:02
@themechanicalcoder
themechanicalcoder changed the base branch from master to 3.4 December 23, 2019 15:09
@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder I helped you with the PR rebase and pushed changes to your branch. Please remove or rename your local git branch and fetch tutorial_1 branch from Github to continue development or fix remarks.

@asmorkalov asmorkalov removed the pr: needs rebase Rebase patch (and squash fixup commits) on the top of target branch label Dec 26, 2019
@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder Please adjust C++ code to general OpenCV coding guidelines: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#code-layout
General notes:

  • Please separate function parameters with spaces in consistent way.
  • Use the same approach for code blocks -- move braces to new line. Opening and closing braces should have the same identation.

@themechanicalcoder

Copy link
Copy Markdown
Contributor Author

@asmorkalov done

@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder Please cover remaining comments and squeeze commits in the branch to merge it as single change.

@themechanicalcoder
themechanicalcoder force-pushed the tutorial_1 branch 2 times, most recently from e0b7557 to cbd5847 Compare January 10, 2020 12:10
@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder Please fix formatting issues to unblock PR merge.

@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder Friendly reminder. There are pending review notes in the PR.

@themechanicalcoder

themechanicalcoder commented Jan 20, 2020 •

Copy link
Copy Markdown
Contributor Author

@themechanicalcoder Friendly reminder. There are pending review notes in the PR.

@asmorkalov which ones? I think I have applied all the suggestions that have come on this PR

@asmorkalov

Copy link
Copy Markdown
Contributor

I see my comments with pending status above in the thread. Let me highlight them.

@themechanicalcoder

Copy link
Copy Markdown
Contributor Author

@asmorkalov I went through all the comments and found that this one was the only one that I had missed

@asmorkalov

Copy link
Copy Markdown
Contributor

@themechanicalcoder I squashed commits in your branch and fixed bug in C++ code.

@asmorkalov

Copy link
Copy Markdown
Contributor

👍 @alalek please take a look and merge. Both Python and C++ versions has been tested with Ubuntu 18.04.


def main():
import sys
import argparse

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to move it on top to have all imports in one place.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder.

Mat thresh;
threshold(gray, thresh, 0, 255, THRESH_BINARY | THRESH_OTSU);

vector<Point2f>coords;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space is missing after type.

Mat gray;
cvtColor(image, gray, COLOR_BGR2GRAY );


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line is not required here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder.

# otherwise, just take the inverse of the angle to make
# it positive
else:
angle = -angle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty lines inside and after if statement are not consistent, it confuses reader.

@opencv-pushbot
opencv-pushbot merged commit a6359e4 into opencv:3.4 Jan 24, 2020
@alalek alalek mentioned this pull request Jan 28, 2020
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants