MCPcopy
hub / github.com/datalab-to/marker / rescale

Method rescale

marker/schema/polygon.py:156–168  ·  view source on GitHub ↗
(self, old_size, new_size)

Source from the content-addressed store, hash-verified

154 return ((self.bbox[0] - other.bbox[0]) ** 2 + (self.bbox[1] - other.bbox[1]) ** 2) ** 0.5
155
156 def rescale(self, old_size, new_size):
157 # Point is in x, y format
158 page_width, page_height = old_size
159 img_width, img_height = new_size
160
161 width_scaler = img_width / page_width
162 height_scaler = img_height / page_height
163
164 new_corners = copy.deepcopy(self.polygon)
165 for corner in new_corners:
166 corner[0] = corner[0] * width_scaler
167 corner[1] = corner[1] * height_scaler
168 return PolygonBox(polygon=new_corners)
169
170 def fit_to_bounds(self, bounds):
171 new_corners = copy.deepcopy(self.polygon)

Callers 14

add_blocks_to_pagesMethod · 0.80
get_all_linesMethod · 0.80
filter_blank_linesMethod · 0.80
spans_from_html_charsMethod · 0.80
get_imageMethod · 0.80
get_imageMethod · 0.80
draw_pdf_debug_imagesMethod · 0.80
render_layout_boxesMethod · 0.80
__call__Method · 0.80
__call__Method · 0.80

Calls 1

PolygonBoxClass · 0.85

Tested by

no test coverage detected