RSS-83: More improvements for section detection 2
This commit is contained in:
parent
d669f92a7d
commit
2ca8a4cf6b
@ -44,10 +44,9 @@ public class ClassificationService {
|
|||||||
for (Page page : document.getPages()) {
|
for (Page page : document.getPages()) {
|
||||||
Rectangle btf = page.isLandscape() ? landscapeBodyTextFrame : bodyTextFrame;
|
Rectangle btf = page.isLandscape() ? landscapeBodyTextFrame : bodyTextFrame;
|
||||||
|
|
||||||
// if (page.getRotation() == 180 || page.getRotation() == 270){
|
if (!page.isLandscape() && page.getRotation() == 270){
|
||||||
System.out.println(btf);
|
btf = getRectangle(btf, page.getCropbox());
|
||||||
btf = getRectangle(btf, page.getRotation(), page.getCropbox());
|
}
|
||||||
// }
|
|
||||||
System.out.println("CropBoxArea" + page.getCropBoxArea());
|
System.out.println("CropBoxArea" + page.getCropBoxArea());
|
||||||
page.setBodyTextFrame(btf);
|
page.setBodyTextFrame(btf);
|
||||||
classifyPage(btf, page, document, headlineFontSizes);
|
classifyPage(btf, page, document, headlineFontSizes);
|
||||||
@ -56,11 +55,10 @@ public class ClassificationService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Rectangle getRectangle(Rectangle rectangle, int rotation, PDRectangle cropbox) {
|
public Rectangle getRectangle(Rectangle rectangle, PDRectangle cropbox) {
|
||||||
|
|
||||||
|
|
||||||
Point2D bottomLeft = new Point2D.Double(rectangle.getMinX(), rectangle.getMinY());
|
Point2D bottomLeft = new Point2D.Double(rectangle.getMinX(), rectangle.getMinY());
|
||||||
Point2D topRight = new Point2D.Double(rectangle.getMaxX(), rectangle.getMaxY());
|
|
||||||
|
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
|
|
||||||
@ -70,19 +68,9 @@ public class ClassificationService {
|
|||||||
transform.rotate(Math.toRadians(180), 0, 0);
|
transform.rotate(Math.toRadians(180), 0, 0);
|
||||||
transform.translate(-ty, -ty);
|
transform.translate(-ty, -ty);
|
||||||
|
|
||||||
|
|
||||||
bottomLeft = transform.transform(bottomLeft, null);
|
bottomLeft = transform.transform(bottomLeft, null);
|
||||||
topRight = transform.transform(topRight, null);
|
|
||||||
|
|
||||||
// var r = new Rectangle((float)bottomLeft.getX(),(float) rectangle.getX() + (float) rectangle.getWidth(), (float)topRight.getX()- (float)bottomLeft.getX(), (float)topRight.getY()-(float) bottomLeft.getY());
|
|
||||||
|
|
||||||
|
|
||||||
var r = new Rectangle((float)bottomLeft.getX() - (float) rectangle.getHeight(),(float) rectangle.getX(), (float) rectangle.getWidth(), (float) rectangle.getHeight());
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println(r);
|
|
||||||
return r;
|
|
||||||
|
|
||||||
|
return new Rectangle((float)bottomLeft.getX() - (float) rectangle.getHeight(),(float) rectangle.getX(), (float) rectangle.getWidth(), (float) rectangle.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,10 +37,10 @@ public class PositionUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((textBlock.getRotation() == 0 || textBlock.getRotation() == 180) && textBlock.getMinX() < btf.getX()) {
|
if ((textBlock.getRotation() == 0 || textBlock.getRotation() == 180) && textBlock.getMinY() > btf.getY() + btf.getHeight()) {
|
||||||
// Its very strange, P{0,0} is on top left in this case, instead of lower left.
|
// Its very strange, P{0,0} is on top left in this case, instead of lower left.
|
||||||
return true;
|
return true;
|
||||||
} else if ((textBlock.getRotation() == 90 || textBlock.getRotation() == 270) && textBlock.getMinY() > btf.getY() + btf.getHeight()) {
|
} else if ((textBlock.getRotation() == 90 || textBlock.getRotation() == 270) && textBlock.getMinX() < btf.getX()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user