libs.extract_ROI
Utilities behind select_rois(): autodetection of rectangles,
residual finding, CLI glue, and the OpenCV selection widget.
- formhtr.libs.extract_ROI.autodect.extract_framebox(image)[source]
Detect the main framebox of the template. Used to avoid rectangle detection outside this area.
- Parameters:
image (Image) – given image
- Returns:
coordinates of the framebox
- Return type:
- formhtr.libs.extract_ROI.autodect.detect_rectangles(image, filter_scale)[source]
Automatically detect rectangle within given image. These can be then used as potential candidates for ROIs.
- formhtr.libs.extract_ROI.autodect.find_residuals(image, credentials)[source]
Detect printed text via Google Vision and convert hits to
Residualobjects.- Parameters:
image – Template page as
numpyarray (RGB/BGR).credentials – Path to Google service-account JSON (passed to
GoogleVision).
- Returns:
List of
Residualinstances for configto_ignoreentries.
- formhtr.libs.extract_ROI.cli_inputs.process_cli(widget)[source]
Dispatch keyboard commands for
SelectROIsWidget.- Parameters:
widget – Instance with
undo_add_rectangle.- Returns:
Nonewhen the user pressesqor Esc.