Page MenuHomePhabricator

Add rotate option to OCR tool
Open, Needs TriagePublicFeature

Description

Feature summary:

Need to be able to rotate images of text before OCRing

Use case(s):

Many scans of old documents include pages that are rotated compared to the main body of the work, for example:

https://ocr.wmcloud.org/?engine=google&langs[]=&image=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Fa%2Fac%2FNotes_and_collections_relating_to_the_parish_of_Aldridge%252C_Part_2.djvu%2Fpage57-2048px-Notes_and_collections_relating_to_the_parish_of_Aldridge%252C_Part_2.djvu.jpg&line_id=&uselang=en

Benefits:

Improve productivity of Wikisource contributors, etc.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Can I work on this task (add rotate option to the OCR tool) as my first contribution?
If yes, could you please confirm where the current OCR tool UI code lives (repo/file) so I start from the right place?

There was a patch and a task for this from Inductive a while back, lemme go fish it out.

There was a patch and a task for this from Inductive a while back, lemme go fish it out.

Thanks! That would be really helpful. I’m happy to review or continue from the earlier patch once you find it.

@Shraddhaa09 Please see https://www.mediawiki.org/wiki/New_Developers which answer all these questions - thanks!

I've completed the implementation and submitted a pull request on GitHub:

GitHub PR: https://github.com/wikimedia/wikimedia-ocr/pull/147

@Okerekechinweotito @Shraddhaa09 @Agamyasamuel All three of you now have PRs for this task.

https://github.com/wikimedia/wikimedia-ocr/pull/147
https://github.com/wikimedia/wikimedia-ocr/pull/148
https://github.com/wikimedia/wikimedia-ocr/pull/158

@Shraddhaa09 you were the first, so it seems most fair if your patch is the main one, and the others help you get it finished.

But it doesn't matter which one it is, I'd just suggest that one of you assign this task to yourself, and the other two help. There are plenty of other things to work on with the OCR tool, you don't have to be treading on each other's toes! :-)

I have gone ahead to claim the task since I am available to iterate and make any required changes ASAP
@Shraddhaa09 Please let me know if you are still available to collaborate and complete your patch, please feel free to indicate so I can unclaim the task and take a supporting role instead

Thanks for the clarification. I’ll continue exploring the OCR tool and related microtasks to understand the codebase better.

If there are other beginner-friendly issues around the OCR tool or Wikisource extension, I’d be happy to work on them.

Change #1257314 had a related patch set uploaded (by Vidya_sri_ganesh; author: Vidya_sri_ganesh):

[mediawiki/extensions/Wikisource@master] Add rotate buttons to OCR tool UI Bug: T413556

https://gerrit.wikimedia.org/r/1257314

Submitted a patch to add rotate buttons to the OCR tool UI:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikisource/+/1257314

This patch introduces basic UI controls (Rotate Left / Rotate Right) as a first step towards implementing the rotation feature.

Change #1257314 had a related patch set uploaded (by Pppery; author: Vidya_sri_ganesh):

[mediawiki/extensions/Wikisource@master] Add rotate buttons to OCR tool UI

https://gerrit.wikimedia.org/r/1257314

I hvae uploaded a patchset for this task can you review it please

Change #1262970 had a related patch set uploaded (by RisXeng; author: RisXeng):

[mediawiki/extensions/Wikisource@master] Add rotate buttons to OCR tool UI Add rotate left and right buttons to the Bulk OCR widget that allow users to specify image rotation before OCR processing. Rotation angle is passed to the OCR API via the rotate parameter.

https://gerrit.wikimedia.org/r/1262970

Change #1262970 abandoned by RisXeng:

[mediawiki/extensions/Wikisource@master] Add rotate buttons to OCR tool UI

https://gerrit.wikimedia.org/r/1262970

The OCR tool Git repo has now moved to GitLab. Sorry to make extra work, but could any still-active PRs above please be pushed to https://gitlab.wikimedia.org/toolforge-repos/ocr instead of GitHub? Thanks!

The OCR tool Git repo has now moved to GitLab. Sorry to make extra work, but could any still-active PRs above please be pushed to https://gitlab.wikimedia.org/toolforge-repos/ocr instead of GitHub? Thanks!

Pull request moved to Gitlab
https://gitlab.wikimedia.org/toolforge-repos/ocr/-/merge_requests/10

samwilson updated https://gitlab.wikimedia.org/toolforge-repos/ocr/-/merge_requests/10

T413556 - Add image rotation functionality with UI controls and localization

samwilson merged https://gitlab.wikimedia.org/toolforge-repos/ocr/-/merge_requests/10

T413556 - Add image rotation functionality with UI controls and localization

@Okerekechinweotito It looks like there might be an issue when an image is rotated and cropped, it works when first requested, but the crop is shown with the wrong offset.

Thanks! Merged and released in 1.10.1.

I'm not quite sure things are fully fixed: if I open this image, rotate it right, and pan it across to the bottom right, and put a crop box around the £1314/9/11. When the page reloads, the crop box is in the wrong place.

Before submittingAfter
image.png (582×745 px, 341 KB)
image.png (577×759 px, 287 KB)

okerekechinweotito updated https://gitlab.wikimedia.org/toolforge-repos/ocr/-/merge_requests/12

 T413556- fix: add canvas data handling for image cropping and rotation

Samwilson removed Due Date which was set to Sat, Jun 6, 12:00 AM.Sat, Jun 6, 2:20 AM