Closed thejiangcj closed 5 months ago
I think you're right, the third coordinate is the width and not the height.
Just found some code and I did this:
{"page": box[0], "x": box[1], "y": box[2], "width": box[3], "height": box[4]}
This is also confirmed by the grobid code:
public String toString() {
return String.format("%d,%.2f,%.2f,%.2f,%.2f", page, x, y, width, height);
}
Actually the documentation is correct, looking at the Coordinates in JSON results
you might have assumed that it was the order, however it's the same order as in the JSON result, where the h
is coming before the w
.
If you check down in the Coordinates in TEI/XML results
the examples are correctly mapping the third element as the width and the fourth as the height.
I have look at official documents about coordinate, which describes:
However ,pymupdf support coordinate: (x1,y1,x2,y2), which is (x1,y1) is the upper-left coord and (x2,y2) is the bottom-right coord.
So in order to crop image, should compute:
However I get wrong result but I revise the code to
which get right image and crop suitable.
So i wonder why my first compute result is wrong? could someone give me a detail explaination?