chore: prune boilerplate and refresh stale docs
- Remove 257 redundant per-definition comment stubs across the package - Drop dead nonlocal declarations in autoslicer_detection.py - Document the swapped flag and swap_left_right in architecture docs - Remove unsupported 'legacy override' claims from autotune/runtime docs
This commit is contained in:
parent
929c828438
commit
426a18f342
24 changed files with 5 additions and 264 deletions
|
|
@ -2,9 +2,7 @@ import numpy as np
|
|||
import cv2
|
||||
|
||||
|
||||
# PhotoSlice: class definition for ScanSlicer behavior.
|
||||
class PhotoSlice:
|
||||
# __init__: function definition for ScanSlicer behavior.
|
||||
def __init__(self, bbox=None):
|
||||
self._bbox = None
|
||||
self._rect_cache = None
|
||||
|
|
@ -23,18 +21,15 @@ class PhotoSlice:
|
|||
self.swapped = False
|
||||
|
||||
@property
|
||||
# bbox: function definition for ScanSlicer behavior.
|
||||
def bbox(self):
|
||||
return self._bbox
|
||||
|
||||
@bbox.setter
|
||||
# bbox: function definition for ScanSlicer behavior.
|
||||
def bbox(self, value):
|
||||
self._bbox = np.array(value, dtype=np.float64).reshape(4, 2)
|
||||
self._rect_cache = None
|
||||
self._rect_cache_tol = None
|
||||
|
||||
# normalize_top_left: function definition for ScanSlicer behavior.
|
||||
def normalize_top_left(self):
|
||||
# Assume the top-left point of the quad is the image upper-left corner.
|
||||
top_left_index = np.lexsort((self.bbox[:, 0], self.bbox[:, 1]))[0]
|
||||
|
|
@ -44,7 +39,6 @@ class PhotoSlice:
|
|||
# the most horizontal "top" edge.
|
||||
reversed_winding = np.array([ordered[0], ordered[3], ordered[2], ordered[1]])
|
||||
|
||||
# horizontal_score: function definition for ScanSlicer behavior.
|
||||
def horizontal_score(points):
|
||||
edge = points[1] - points[0]
|
||||
return (abs(edge[0]) - abs(edge[1]), edge[0])
|
||||
|
|
@ -59,7 +53,6 @@ class PhotoSlice:
|
|||
|
||||
self.bbox = ordered
|
||||
|
||||
# swap_left_right: function definition for ScanSlicer behavior.
|
||||
def swap_left_right(self):
|
||||
# Mirror left/right: swap the two top corners and the two bottom
|
||||
# corners, keeping the top (edge 0->1) and bottom edges in place.
|
||||
|
|
@ -69,14 +62,12 @@ class PhotoSlice:
|
|||
self._rect_cache = None
|
||||
self._rect_cache_tol = None
|
||||
|
||||
# toggle_locked: function definition for ScanSlicer behavior.
|
||||
def toggle_locked(self, locked=None):
|
||||
if locked is not None:
|
||||
self.locked = locked
|
||||
else:
|
||||
self.locked = not self.locked
|
||||
|
||||
# update_corner: function definition for ScanSlicer behavior.
|
||||
def update_corner(self, ci, x, y):
|
||||
self._bbox[ci][0] = x
|
||||
self._bbox[ci][1] = y
|
||||
|
|
@ -85,7 +76,6 @@ class PhotoSlice:
|
|||
# Freeform corner edits exit side-handle mode.
|
||||
self.side_handles_enabled = False
|
||||
|
||||
# is_perfect_rectangle: function definition for ScanSlicer behavior.
|
||||
def is_perfect_rectangle(self, tol=1e-3):
|
||||
if self._rect_cache is not None and self._rect_cache_tol == tol:
|
||||
return self._rect_cache
|
||||
|
|
@ -121,7 +111,6 @@ class PhotoSlice:
|
|||
self._rect_cache_tol = tol
|
||||
return True
|
||||
|
||||
# squarize: function definition for ScanSlicer behavior.
|
||||
def squarize(self):
|
||||
points = np.array(self.bbox, dtype=np.float64).reshape(4, 2)
|
||||
center = np.mean(points, axis=0)
|
||||
|
|
@ -173,7 +162,6 @@ class PhotoSlice:
|
|||
self.normalize_top_left()
|
||||
self.side_handles_enabled = True
|
||||
|
||||
# reset_rotation: function definition for ScanSlicer behavior.
|
||||
def reset_rotation(self):
|
||||
points = np.array(self.bbox, dtype=np.float64).reshape(4, 2)
|
||||
center = np.mean(points, axis=0)
|
||||
|
|
@ -201,7 +189,6 @@ class PhotoSlice:
|
|||
self.side_handles_enabled = True
|
||||
|
||||
|
||||
# polys_iou: function definition for ScanSlicer behavior.
|
||||
def polys_iou(poly1, poly2):
|
||||
a = np.array(poly1, dtype=np.float32).reshape(-1, 2)
|
||||
b = np.array(poly2, dtype=np.float32).reshape(-1, 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue