-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added the geometric operations to BoundingBox #136
feat: added the geometric operations to BoundingBox #136
Conversation
Signed-off-by: Peter Staar <[email protected]>
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWonderful, this rule succeeded.When test data is updated, we require two reviewers
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that we get more functions but we should never add page_height as an argument, neither to existing nor to new methods. If the "other" bbox does not agree in coord_origin with the self bbox, it must raise an exception instead. It is user business to ensure this beforehand.
This is also a useful geometric operation to add: https://github.com/DS4SD/docling/blob/main/docling/models/base_model.py#L71 |
…aled and normalize Signed-off-by: Peter Staar <[email protected]>
Just mentioning here one possibility that was discussed. One wish is a simple way of dealing with rescaling from a given page size to a new one. In the current solution this can be done as a combination of Would it worth leaving the def resize_by_scale(self, x_scale: float, y_scale: float):
return BoundingBox(
l=self.l * x_scale,
r=self.r * x_scale,
t=self.t * y_scale,
b=self.b * y_scale,
coord_origin=self.coord_origin,
)
def scale_to_size(self, orig_page_size: Size, new_page_size: Size):
return self.resize_by_scale(x_scale=new_page_size.width/orig_page_size.width, y_scale=new_page_size.height/orig_page_size.height)
# same as before, but using the implementation above
def scale(self, scale: float):
return self.resize_by_scale(scale, scale)
# same as before, but using the implementation above
def normalized(self, page_size: Size):
return self.scale_to_size(orig_page_size=page_size, new_page_size=Size(1.0,1.0)) |
well, that was basically what was originally proposed, just different names. Anyhow, adapted this now ... |
Signed-off-by: Peter Staar <[email protected]>
Signed-off-by: Peter Staar <[email protected]>
Tested within Docling here DS4SD/docling#830 |
No description provided.