OCR4all / LAREX

A semi-automatic open-source tool for Layout Analysis and Region EXtraction on early printed books.
MIT License
179 stars 33 forks source link

Feature/page orientation #258

Closed chaddy314 closed 3 years ago

chaddy314 commented 3 years ago

Larex now deskews images and regions according to the @orientation angle annotated. /PcGts/Page/@orientation is read from pageXML and is added to the PageAnnotations send to the client. The rotation of each region will be executed during controller.loadAnnotations() and rotated back on export. closes #173

maxnth commented 3 years ago

Running Segment on a page currently resets any orientation read from the file. As LAREX segmentation should only affect the Layout this probably isn't the expected behavior for most users (?)

https://user-images.githubusercontent.com/33344081/122058720-316af080-cdec-11eb-8b68-2e043b51ffdf.mp4

maxnth commented 3 years ago

Saving (via Ctrl+S or the Save Result button) throws the following error:

controller.js:2168 Uncaught ReferenceError: i is not defined
    at controller.js:2168
    at Array.forEach (<anonymous>)
    at Controller.unrotateSegments (controller.js:2167)
    at Controller.exportPageXML (controller.js:705)
    at HTMLDocument.KeyInput.document.onkeydown (keyInput.js:279)
maxnth commented 3 years ago

Saving should now work.

chaddy314 commented 3 years ago

Rebased to current dev version(57dd0d504413f3aa5193540ee586854f4b808e4b). Saving should now work again, as well as proper derotation of segments.

maxnth commented 3 years ago

Orientation doesn't reset on page change.

With this project structure: image The second page is rotate 90 degrees even though no XML exists: image

maxnth commented 3 years ago

This branch produces worse segmentation results for pages which were rotated.

The following segmentatione results were produces by LAREX segmentation with the same settings on the same pages: a) Rotated image b) Not rotated image

I guess we should also rotate the images in the backend before running the segmentation algorithm (or at least make it user configurable)

maxnth commented 3 years ago

I guess rotating directly when setting image https://github.com/OCR4all/LAREX/blob/005aaea52616ec869b776895b5a28d9d11c37e29/src/main/webapp/resources/js/viewer/controller.js#L209 instead of afterwards https://github.com/OCR4all/LAREX/blob/005aaea52616ec869b776895b5a28d9d11c37e29/src/main/webapp/resources/js/viewer/controller.js#L234 would be an improved as the non-rotated image wouldn't appear before rapidly being rotated.

chaddy314 commented 3 years ago

Orientation doesn't reset on page change.

fixed in latest commit

maxnth commented 3 years ago

All problems / bugs but the one regarding segmentation results seem to be resolved and ready for a merge into dev. While the open problem is IMO a very important one and one which has to be absolutely addressed before pushing the dev branch to staging I'll merge this PR already to ease testing this in combination with the other new features.