Skip to content

Commit

Permalink
Correct cuts in hOCR serialization
Browse files Browse the repository at this point in the history
Fixes #582
  • Loading branch information
mittagessen committed Apr 8, 2024
1 parent d539fde commit da6c0a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions kraken/rpred.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def _recognize_baseline_line(self, line):
pos = []
conf = []
for _, start, end, c in preds:
pos.append((self._scale_val(start, 0, self.box.size[0]),
self._scale_val(end, 0, self.box.size[0])))
pos.append([self._scale_val(start, 0, self.box.size[0]),
self._scale_val(end, 0, self.box.size[0])])
conf.append(c)
rec = BaselineOCRRecord(pred, pos, conf, line)
if self.bidi_reordering:
Expand All @@ -307,7 +307,7 @@ def __len__(self):

def _scale_val(self, val, min_val, max_val):
return int(round(min(max(((val*self.net_scale)-self.pad)*self.in_scale, min_val), max_val-1)))

def _choose_legacy_polygon_extractor(self, net) -> bool:
# grouping the checks here to display warnings only once
if net.nn.use_legacy_polygons:
Expand Down
2 changes: 1 addition & 1 deletion kraken/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def serialize(results: 'Segmentation',
# addition to bounding boxes
line = {'id': record.id,
'bbox': max_bbox([record.boundary]) if record.type == 'baselines' else record.bbox,
'cuts': record.cuts,
'cuts': [list(x) for x in record.cuts],
'confidences': record.confidences,
'recognition': [],
'boundary': [list(x) for x in record.boundary] if record.type == 'baselines' else [[record.bbox[0], record.bbox[1]],
Expand Down

0 comments on commit da6c0a4

Please sign in to comment.