{"record":{"id":"8dfd66e5c2933501","repo":"deeplearning4j/deeplearning4j","slug":"invalid-input-x1-y1-top-left-position-must-hav","errorCode":null,"errorMessage":"Invalid input: (x1,y1), top left position must have values less than\" +\n                    \" (x2,y2) bottom right position. Got: (\" + x1 + \",\" + y1 + \"), (\" + x2 + \",\" + y2 + \")","messagePattern":"Invalid input: \\(x1,y1\\), top left position must have values less than\" \\+\n                    \" \\(x2,y2\\) bottom right position\\. Got: \\(\" \\+ x1 \\+ \",\" \\+ y1 \\+ \"\\), \\(\" \\+ x2 \\+ \",\" \\+ y2 \\+ \"\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"datavec/datavec-data/datavec-data-image/src/main/java/org/datavec/image/recordreader/objdetect/ImageObject.java","lineNumber":36,"sourceCode":" *  *****************************************************************************\n */\n\npackage org.datavec.image.recordreader.objdetect;\n\nimport lombok.Data;\n\n@Data\npublic class ImageObject {\n\n    private final int x1;\n    private final int y1;\n    private final int x2;\n    private final int y2;\n    private final String label;\n\n    public ImageObject(int x1, int y1, int x2, int y2, String label){\n        if(x1 > x2 || y1 > y2){\n            throw new IllegalArgumentException(\"Invalid input: (x1,y1), top left position must have values less than\" +\n                    \" (x2,y2) bottom right position. Got: (\" + x1 + \",\" + y1 + \"), (\" + x2 + \",\" + y2 + \")\");\n        }\n\n        this.x1 = x1;\n        this.y1 = y1;\n        this.x2 = x2;\n        this.y2 = y2;\n        this.label = label;\n    }\n\n    public double getXCenterPixels(){\n        return (x1 + x2) / 2.0;\n    }\n\n    public double getYCenterPixels(){\n        return (y1 + y2) / 2.0;\n    }\n}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/datavec/datavec-data/datavec-data-image/src/main/java/org/datavec/image/recordreader/objdetect/ImageObject.java#L18-L54","documentation":"The ImageObject constructor validates bounding-box geometry: the top-left corner (x1,y1) must satisfy x1 <= x2 and y1 <= y2 relative to the bottom-right corner. Otherwise it throws IllegalArgumentException describing the offending coordinates. Note it only rejects strictly greater values — equal coordinates (a degenerate point/line box) are allowed.","triggerScenarios":"Creating ImageObject with swapped or negative-growth coordinates, e.g. new ImageObject(x2, y2, x1, y1, label), or parsing annotations where corner order differs (e.g. width/height instead of x2/y2).","commonSituations":"Custom LabelProvider implementations feeding wrong corner order; annotation formats that store (x, y, width, height) misread as (x1, y1, x2, y2); coordinate-system flips between image origins.","solutions":["Order the corners before constructing: x1 = min(ax,bx), y1 = min(ay,by), x2 = max(ax,bx), y2 = max(ay,by)","If your source stores width/height, convert: new ImageObject(x, y, x + w, y + h, label)","Validate parsed annotation values before constructing ImageObject"],"exampleFix":"// before\nnew ImageObject(bboxX + bboxW, bboxY + bboxH, bboxX, bboxY, label); // corners swapped\n// after\nnew ImageObject(bboxX, bboxY, bboxX + bboxW, bboxY + bboxH, label);","handlingStrategy":"validation","validationCode":"if (x1 > x2 || y1 > y2) {\n    int nx1 = Math.min(x1, x2), nx2 = Math.max(x1, x2);\n    int ny1 = Math.min(y1, y2), ny2 = Math.max(y1, y2);\n    x1 = nx1; y1 = ny1; x2 = nx2; y2 = ny2;\n}\nImageObject obj = new ImageObject(x1, y1, x2, y2, label);","typeGuard":null,"tryCatchPattern":"ImageObject obj;\ntry {\n    obj = new ImageObject(x1, y1, x2, y2, label);\n} catch (IllegalArgumentException e) {\n    // normalize corner order and retry\n    obj = new ImageObject(Math.min(x1,x2), Math.min(y1,y2), Math.max(x1,x2), Math.max(y1,y2), label);\n}","preventionTips":["Confirm your annotation source uses (x1,y1,x2,y2) not (x,y,w,h)","Normalize corner order with min/max before constructing boxes","Add a pre-construction assertion for bounding-box geometry in parsing code"],"tags":["illegal-argument","bounding-box","object-detection","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}