dsh-image-read: A Deterministic Image Reading Tool for Rule-Based Scenarios

Introduction

The plugin-based architecture of DeepSeek Harness (DSH) allows developers to compose capabilities on demand. In a PTC (Persistent Tool Chain) session, processing images in sequence often requires implementing custom parsing logic or relying on unstable general-purpose vision models. The dsh-image-read plugin turns image reading in rule-based scenarios into a deterministic tool, ready for consecutive invocation in PTC sessions.

What It Is

This is a DeepSeek Harness (DSH) plugin maintained by cv588888888888888888888ju. It provides a set of image-processing tools targeting rule-based scenarios, performing only deterministic computation at the geometric / pixel level: chart curve fitting, slider-gap localization, rotation-angle estimation, curved-path extraction, and chained image operators. It does not provide general visual understanding and does not integrate with any VLM.

Core Tools

The plugin offers five tools, compared below by input and output:

Tool Input Returns
chart_read Chart screenshot + optional calibration Equation / R² / preview points per curve, plus data-table / SVG / overlay artifacts
captcha_slide Background image + puzzle piece Gap top-left x/y, score, trusted, overlay
captcha_rotate Target image + optional reference image Rotation angle angle (clockwise, (-180,180]), correction, trusted
captcha_curve Image containing a main curve Ordered point list points, endpoints, length_px, bbox, overlay
img_ops Image + operator array Per-step dimensions + final PNG artifact

Full parameters / return values / error codes: see INTERFACE.md.

Environment Requirements

  • Node.js >= 22.13 (DSH host)
  • Python 3; dependencies listed in requirements.txt: pip install -r requirements.txt
  • chart_read uses the bundled vendor/chart2data from the repo—no separate installation needed; add pdfplumber when reading PDF charts

Installation & Enablement

During development, install into the profile using link::

dsh plugin --profile web add link:/path/to/dsh-image-read

After restarting dsh web once (or entering the next turn), the five tools become available in PTC’s tools.

chart_read requires no external chart2data configuration: it defaults to the vendor/chart2data directory within the repo.

Typical Usage

// Chart: curves → equations / data points
const chart = await tools.chart_read({ image: '/abs/chart.png' })

// Slider
const slide = await tools.captcha_slide({ bg: '/abs/bg.png', slider: '/abs/piece.png' })

// Rotation (reliable when a reference image is provided)
const rot = await tools.captcha_rotate({ image: '/abs/rotated.png', reference: '/abs/upright.png' })

// Curve
const curve = await tools.captcha_curve({ image: '/abs/curve.png' })

// Chained image processing
const ops = await tools.img_ops({
  image: '/abs/in.png',
  ops: [{ op: 'rotate', angle: 90 }, { op: 'gray' }, { op: 'resize', width: 640, height: 480 }],
})

All return values are single-line JSON strings; when ok:false, check error.code (E_INPUT / E_DEP / E_SLIDE / E_ROTATE / E_CURVE / E_OP, etc.).

Configuration

All tunable values live in img.config.json: python interpreter, chart2dataRoot (defaults to vendor/chart2data; relative paths are resolved relative to the directory containing img.config.json), workDir, and per-tool thresholds.

Self-Test

node acceptance/selftest.mjs
# Use your own chart image:
CHART_FIXTURE=/path/to/chart.png node acceptance/selftest.mjs

The chart fixture is the bundled acceptance/fixtures/chart/sample_plot.png; the slider / rotation / curve fixtures are synthetic and can be regenerated with python3 acceptance/make_fixtures.py.

Limitations

  • Designed for rule-based scenarios only; photos / irregular images are not supported.
  • captcha_rotate has a 90° ambiguity without a reference image; trusted is always false.
  • captcha_curve assumes a single value per column and no self-intersection; for multiple curves, split the image first.
  • captcha_slide’s trusted is merely a score threshold—do not drag directly on low scores.

Directory Structure

index.js            Host-side tool registration
lib/bridge.js       Node → Python bridge
bridge/main.py      Algorithm implementation
img.config.json     Tunable values
INTERFACE.md        Contract
acceptance/         selftest + synthetic fixture generator
vendor/chart2data/  Chart screenshot → curves/data points (shipped with the repo, MIT)

Use Cases & Notes

  • Suitable for developers who need to handle rule-based scenarios such as charts, slider captchas, rotation captchas, and curved-path extraction.
  • The plugin runs with the current dsh process privileges; review the source code and license before installing.
  • MIT licensed; vendor/chart2data is also MIT-licensed code by the same repo author, distributed alongside this plugin.

Closing

dsh-image-read turns image reading in rule-based scenarios into deterministic tools, enabling consecutive invocation in PTC sessions. If you are working on chart curve fitting, slider-gap localization, rotation-angle estimation, curved-path extraction, or chained image operators, you can view details on the directory page: https://www.skillhub.cn/plugins/cv588888888888888888888ju/dsh-image-read; source code on GitHub: https://github.com/cv588888888888888888888ju/dsh-image-read.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye