boneheadsscan

Scanner pipeline based on scanimage with image processing and OCR implemented in Python using PIL tesseract OCR.

Moderate Pure Nim score 35/100 · last commit 2026-03-07 · 1 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 1
Forks 0
Open Issues 0
Last Commit 2026-03-07
Downloads 0
Last Indexed 2026-11-23 09:07

Installation

nimble install boneheadsscan
choosenim install boneheadsscan
git clone https://gitlab.com/jns-v/boneheadsscan

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
boneheadsscan ✓ ✓ ✓ - - - - - - -

Source

Repository https://gitlab.com/jns-v/boneheadsscan
Homepage https://gitlab.com/jns-v/boneheadsscan
Registry Source gitlab

README

Boneheadsscan

Small project to facilitate hands-free scanning with older (USB) scanners. It's intended to run in Docker. The pipeline comprises scanbd monitoring scanner button presses and triggering the scan. Profiles can be defined in json format to specify based on the function knob setting. Image processing is realised in python and features - Blank detection, - Edge-finding and cropping/rotating, - Deghosting and - OCR and produces a pdf. Personally I specify the output directory to match my paperless-ngx instance's consume directory.

Originally, I built this for use with a Fujitsu fi-6110 but have since upgraded to an fi-6130. I realised that the latter required some fine-tuning for some parameters. To reflect this scanner specific options can be provided using another json profile.

I'm running this in a docker container on a TrueNAS instance that has a scanner attached via USB. For this reason there's a udev rule and a restart_pyscan script that restarts the container if the scanner comes alive. Otherwise the scanner wouldn't be visible within the container.

It's still WIP and there may be breaking changes in the future. Otherwise feel free to use.

Parameters

Several methods are implemented to set parameters for PyScan. setup.py processes them hierarchically in the following order 1. Default profile (fallback), 2. Device profile ($PYSCAN_CONFIG_DIR/devices.json), 3. Function (button) profile($PYSCAN_CONFIG_DIR/profiles.json), 4. Parameters file ($PYSCAN_RAW_DIR/tmp.XXXXXXXXXX.prm) and 5. Command line arguments. Consequently, options will be overridden if they are set in multiple locations. The use of the .prm file may at some point be phased out.

Available options are | Option | Description | | -------------------------------- | ----------------------------------------------------------------------------- | | src: Path | Directory containing the raw images | | out: Path | Output filename | | type: str | Any of 'A4', 'Receipt' | | detect_blanks: bool | If PyScan should check for blank pages | | device: str | The scanner name as reported by scanbd | | resolution: int | Image resolution | | deblur: bool | If PyScan should apply deblurring | | deghost: bool | If PyScan should attempt to remove bleed-through | | find_edge: bool | If PyScan should find edges and crop/transform the image | | use_getbbox: bool | If PIL.Image.getbbox() should be used as initial estimate of the page borders | | blank_contrast: float | Contrast level to apply before blank detection | | blank_sterr: float | Page not blank if sterr greater than this value | | blank_upper_threshold: float | Upper limit for the black/white threshold | | blank_lower_threshold: float | Lower limit for the black/white threshold | | blank_tol: float | Determines the p-Value for blank_detection | | approx_edge_blur_radius: float | | | approx_edge_tol: float | Influence edge detection sensitivity | | approx_edge_tol_b: float | ... for the bottom edge | | approx_edge_tol_l: float | ... for the left edge | | approx_edge_tol_r: float | ... for the right edge | | approx_edge_tol_t: float | ... for the top edge | | trim_edges: float | Trim amount in mm | | overscan_color: int | | ransac_residual: float | | deblur_percent: float | | deblur_radius: float | | deblur_threshold: float | | hBox: int | | vBox: int | | deghost_blur_radius: float | | deghost_tol: float | | deghost_value_limit: int | | deghost_saturation_limit: int | | thResidual: int | | owner: str |

Dependencies

Python

  • pillow: Image processing
  • joblib: Parallel processing
  • numpy: Some statistics
  • pypdf: Generating PDF output
  • scikit-learn: Edge detection
  • pytesseract: OCR
  • pathlib: Easy path handling

Native

  • curl: Don't remember
  • libgl1: Don't know
  • scanbd: Polling scanner
  • sane-utils: Scanning
  • python3: Well...
  • python3-pip: ...who knows
  • python3-venv: For some reason installing systemwide doesn't work nicely
  • pipx: Don't know. Probably unneeded
  • bash: Convenience (peeking inside container)
  • tesseract-ocr: OCR engine
  • tesseract-ocr-deu: German language
  • build-essential: Dunno
  • libjpeg-dev: Dunno
  • zlib1g-dev: Dunno
  • libpng-dev: Dunno
  • libopenjp2-7-dev: Dunno
  • libtiff-dev: Dunno
  • usbutils: Dunno
  • dbus: Dunno
  • vim: Convenience
  • procps: Dunno
  • cron: Watching for new scans
  • jq: Reading profiles in bash

License

This project has a number of dependencies and licenses

Software License
pillow MIT
NumPy BSD 3
SciPy BSD 3
scikit-learn BSD 3
joblib BSD 3
pypdf BSD 3
pytesseract Apache 2.0
Tesseract OCR Apache 2.0
scanbd GPL 2
sane-utils GPL 2