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:
dan 2026-09-11 23:07:30 +02:00
parent 929c828438
commit 426a18f342
24 changed files with 5 additions and 264 deletions

View file

@ -2,10 +2,8 @@ import cv2
import numpy as np
# AutoslicerDetectionMixin: class definition for ScanSlicer behavior.
class AutoslicerDetectionMixin:
# Find all bbox related to n
# get_box_relatives: function definition for ScanSlicer behavior.
def get_box_relatives(self, hierarchy, n):
relatives = []
@ -17,7 +15,6 @@ class AutoslicerDetectionMixin:
else:
return relatives
# _poly_iou_prepared: function definition for ScanSlicer behavior.
def _poly_iou_prepared(self, a, b, area_a=None, area_b=None):
if area_a is None:
area_a = cv2.contourArea(a)
@ -36,13 +33,11 @@ class AutoslicerDetectionMixin:
return 0.0
return float(inter_area / union_area)
# poly_iou: function definition for ScanSlicer behavior.
def poly_iou(self, poly_a, poly_b):
a = np.asarray(poly_a, dtype=np.float32).reshape(-1, 2)
b = np.asarray(poly_b, dtype=np.float32).reshape(-1, 2)
return self._poly_iou_prepared(a, b)
# suppress_border_bar_artifacts: function definition for ScanSlicer behavior.
def suppress_border_bar_artifacts(self, mask, update_status_callback=None, status_prefix=""):
if mask is None or mask.ndim != 2:
return mask
@ -84,9 +79,8 @@ class AutoslicerDetectionMixin:
min_band_long_h = max(20, int(round(h * 0.2)))
trimmed = 0
# trim_horizontal_band: function definition for ScanSlicer behavior.
def trim_horizontal_band(row_start, row_end):
nonlocal cleaned, trimmed
nonlocal trimmed
band = cleaned[row_start:row_end, :]
if band.size == 0:
return
@ -108,9 +102,8 @@ class AutoslicerDetectionMixin:
trimmed += 1
cleaned[row_start:row_end, :] = band
# trim_vertical_band: function definition for ScanSlicer behavior.
def trim_vertical_band(col_start, col_end):
nonlocal cleaned, trimmed
nonlocal trimmed
band = cleaned[:, col_start:col_end]
if band.size == 0:
return
@ -153,7 +146,6 @@ class AutoslicerDetectionMixin:
return mask
# extract_boxes_from_mask: function definition for ScanSlicer behavior.
def extract_boxes_from_mask(self, mask, update_status_callback=None, status_prefix=""):
mask = self.suppress_border_bar_artifacts(mask, update_status_callback, status_prefix)
self.update_status(update_status_callback, status_prefix + "Finding contours...")
@ -290,7 +282,6 @@ class AutoslicerDetectionMixin:
return boxes
# apply_morphology: function definition for ScanSlicer behavior.
def apply_morphology(self, mask, update_status_callback=None):
operation = self.params.morph_op.get()
kernel_size = self.params.dilate_kernel.get()
@ -312,7 +303,6 @@ class AutoslicerDetectionMixin:
return cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)
return mask
# apply_threshold_pipeline: function definition for ScanSlicer behavior.
def apply_threshold_pipeline(self, image_gray, update_status_callback=None):
# Binary filter
if self.params.bw_method.get() == 0:
@ -348,14 +338,12 @@ class AutoslicerDetectionMixin:
)
return mask
# apply_canny_pipeline: function definition for ScanSlicer behavior.
def apply_canny_pipeline(self, image_gray, update_status_callback=None):
self.update_status(update_status_callback, "Canny edge detection...")
low = min(self.params.canny_low.get(), self.params.canny_high.get())
high = max(self.params.canny_low.get(), self.params.canny_high.get())
return cv2.Canny(image_gray, low, high)
# extract_boxes_from_mask_relaxed: function definition for ScanSlicer behavior.
def extract_boxes_from_mask_relaxed(self, mask, update_status_callback=None, status_prefix="", return_areas=False):
mask = self.suppress_border_bar_artifacts(mask, update_status_callback, status_prefix)
self.update_status(update_status_callback, status_prefix + "Finding contours...")
@ -435,7 +423,6 @@ class AutoslicerDetectionMixin:
return boxes, box_areas
return boxes
# white_background_fallback: function definition for ScanSlicer behavior.
def white_background_fallback(self, image_gray, update_status_callback=None):
self.update_status(update_status_callback, "Fallback: trying white-background recovery...")
@ -503,7 +490,6 @@ class AutoslicerDetectionMixin:
return best_boxes, best_mask
# autodetect_slices: function definition for ScanSlicer behavior.
def autodetect_slices(self, update_status_callback=None, preview_filter_output=False, fast_mode=False):
filter_out = self.image_gray
self.abort_flag = False