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

dev: java.lang.NullPointerException when setting cut lines #267

Closed andbue closed 3 years ago

andbue commented 3 years ago

Hi, @chreul asked me to test the dev branch to see if it's ready for production. This is the result: :innocent:

Caused by: java.lang.NullPointerException
    at java.util.LinkedList.addAll (LinkedList.java:408)
    at java.util.LinkedList.addAll (LinkedList.java:387)
    at java.util.LinkedList.<init> (LinkedList.java:119)
    at de.uniwue.web.model.Polygon.getPoints (Polygon.java:61)
    at de.uniwue.web.model.Polygon.toPointList (Polygon.java:70)

... when opening the test book, adding a "cut line" somewhere on the page and starting "segment". I tried it both on tomcat8 and jetty-maven-plugin with java-8-openjdk.

The problem might be that in the JSON sent from frontend, cuts are now defined like

{
    "c0": {
        "coords": {
            "isRelative": false,
            "points": [
                {
                    "x": 625,
                    "y": 819
                },
                {
                    "x": 625,
                    "y": 737
                },
                {
                    "x": 625,
                    "y": 737
                }
            ]
        },
        "id": "c0",
        "type": "other"
    }
}

which looks more like a web.model.Region to me, while here https://github.com/OCR4all/LAREX/blob/57dd0d504413f3aa5193540ee586854f4b808e4b/src/main/java/de/uniwue/web/facade/segmentation/FixedGeometry.java#L24-L26 they seem to be defined as polygons. This leads to polygons where points is not defined and therefore null, sending me in java exception hell. Unfortunately, it seems like I can't figure out neither how to use Eclipse properly nor how to force fasterxml.JsonCreator to produce valid polygons from this kind of input as well as the default points JSON, so I'm hoping for your ideas how to fix this!

maxnth commented 3 years ago

Hi, thanks a lot for testing the dev branch and reporting the bug. As hinted correctly, the changes to the model – and in particular changing what a Polygon represents – were the culprit. Adapting the cut action to the new model worked. Starting from b6a64b7 using the cut functionality should work correctly again.

andbue commented 3 years ago

Great, thanks for the quick fix!