pagescan.ScanConfig#

class pagescan.ScanConfig(background_hsv_low=(0, 65, 30), background_hsv_high=(45, 255, 255), background_hsv_strict_s=90, output_width=2480, output_height=3508, output_dpi=300, output_margin=50, jpeg_quality=50, auto_orient=True, deskew=True, enhance=True, shadow_removal=True, white_balance=True, use_ml=True, use_cascade=True, detector_conf_threshold=0.25, min_doc_coverage=0.05, debug=False, debug_dir='pagescan_debug')[source]#

Bases: object

Configuration for the document scanning pipeline.

Parameters:
background_hsv_low#

Lower HSV bound for background detection (e.g. wood table). Default targets warm wood: H=0-45, S>=65 (paper is S=40-60), V>=30.

background_hsv_high#

Upper HSV bound for background detection.

background_hsv_strict_s#

Stricter saturation minimum for edge detection. Prevents cream-colored paper (S=65-85) from being matched as background.

output_width#

Output canvas width in pixels.

output_height#

Output canvas height in pixels.

output_dpi#

DPI for PDF output.

output_margin#

Margin in pixels when placing document on canvas.

jpeg_quality#

JPEG quality for PDF embedding (lower = smaller file).

auto_orient#

Run OCR-based auto-rotation to fix document orientation.

deskew#

Run Hough-based deskew to correct text tilt.

enhance#

Apply scan-like enhancement (grayscale, contrast, sharpen).

shadow_removal#

Apply illumination normalization before enhancement.

white_balance#

Adjust white balance so paper becomes pure white.

use_ml#

Master switch for ML-based corner detection. When False, skips both cascade and legacy ML and goes straight to the conservative-crop fallback. Useful for fast/headless modes.

use_cascade#

Use the YOLO11 + HQ-SAM cascade as the primary detection path. When False (or when the cascade weights are missing), pagescan falls back to the legacy SA24+LCNet ML chain. The cascade requires the optional [ml] extras.

detector_conf_threshold#

Minimum YOLO confidence for accepting a detection. Below this, cascade falls through to legacy.

min_doc_coverage#

Over-crop guard. Predicted quads whose area is below this fraction of the image are rejected as too small (typical failure: SAM segments an inner text block instead of the full page). Default 0.05; raise toward 0.10 if your documents always fill ≥10% of the frame.

debug#

Save intermediate images to debug_dir.

debug_dir#

Directory for debug output.

__init__(background_hsv_low=(0, 65, 30), background_hsv_high=(45, 255, 255), background_hsv_strict_s=90, output_width=2480, output_height=3508, output_dpi=300, output_margin=50, jpeg_quality=50, auto_orient=True, deskew=True, enhance=True, shadow_removal=True, white_balance=True, use_ml=True, use_cascade=True, detector_conf_threshold=0.25, min_doc_coverage=0.05, debug=False, debug_dir='pagescan_debug')#
Parameters:
Return type:

None

Methods

__init__([background_hsv_low, ...])

Attributes