From b048575be524d51e5d20515ffec4728589c9986d Mon Sep 17 00:00:00 2001 From: Dale Thomas Date: Sat, 19 Sep 2026 07:43:27 -0700 Subject: [PATCH 1/5] Name templates with capture size and capture only on demand Template names cannot contain spaces and are saved as name_WIDTHxHEIGHT.jpg so a 2000x2000 snip is not used on a 640x400 locate. The Vision page no longer grabs a frame on load, and Capture Image no longer hits /captured_image twice. --- Web/README.md | 2 +- Web/app/static/css/arfbot-night.css | 7 +++ Web/app/templates/base.html | 2 +- Web/app/templates/vision/template.html | 77 ++++++++++++++++++++------ Web/app/vision.py | 49 +++++++++++++++- Web/tests/test_roi.py | 27 +++++++++ 6 files changed, 143 insertions(+), 21 deletions(-) diff --git a/Web/README.md b/Web/README.md index a6235e2..5428ed3 100644 --- a/Web/README.md +++ b/Web/README.md @@ -12,7 +12,7 @@ One Flask app on port 5000 that hosts the operator pages: `/` redirects to `/vision` when vision is enabled, `/bluetooth` on a `--plc-only` install, or `/animator` if that is the only enabled page. Old `/template`, `/files/`, and `/output_sized` URLs redirect to the new paths. -The CODESYS HMI loads `/vision/output_sized`. Template files still go to `/var/opt/codesys/PlcLogic/Application/Vision/Templates`. Locate search ROI is `.../Vision/roi.yaml`, set from the Vision page ROI tab (`GET`/`POST /vision/roi`). The latest processed image is still `/var/opt/codesys/PlcLogic/visu/outputimage.jpg`. +The CODESYS HMI loads `/vision/output_sized`. Template files still go to `/var/opt/codesys/PlcLogic/Application/Vision/Templates`. Names cannot contain spaces; the capture size is appended (`screwdriver_640x400.jpg`) so a 2000×2000 snip is not used on a 640×400 Locate. Locate search ROI is `.../Vision/roi.yaml`, set from the Vision page ROI tab (`GET`/`POST /vision/roi`). The latest processed image is still `/var/opt/codesys/PlcLogic/visu/outputimage.jpg`. ## Capture size and HQ camera FOV diff --git a/Web/app/static/css/arfbot-night.css b/Web/app/static/css/arfbot-night.css index a2f023d..52faa57 100644 --- a/Web/app/static/css/arfbot-night.css +++ b/Web/app/static/css/arfbot-night.css @@ -571,6 +571,13 @@ pre.log { max-width: min(100%, 640px); height: auto; } +#template-preview { + width: 100%; + margin: 0; + color: var(--muted); + font-size: 12px; + font-weight: 650; +} #canvas { cursor: crosshair; border: 1px solid var(--frame-soft); diff --git a/Web/app/templates/base.html b/Web/app/templates/base.html index e8c3e8e..09009e3 100644 --- a/Web/app/templates/base.html +++ b/Web/app/templates/base.html @@ -8,7 +8,7 @@ {% else %} ArfBot {% endif %} - + {% block head %}{% endblock %} diff --git a/Web/app/templates/vision/template.html b/Web/app/templates/vision/template.html index 6fee222..4ed4bc7 100644 --- a/Web/app/templates/vision/template.html +++ b/Web/app/templates/vision/template.html @@ -26,7 +26,7 @@

Click and Drag to Create a Template Capture size vs field of view (IMX477) -

libcamera picks a sensor mode from width×height, then center-crops to that aspect. Different sizes do not see the same scene. Use the same size for cal, ROI, templates, and Locate.

+

libcamera picks a sensor mode from width×height, then center-crops to that aspect. Different sizes do not see the same scene. Use the same size for cal, ROI, templates, and Locate. Saved templates are named name_WIDTHxHEIGHT.jpg so a 2000×2000 snip is not used on a 640×400 search.

@@ -42,16 +42,17 @@

Click and Drag to Create a Template
- + Capture an image to begin
- + +

Saved as: _640x400.jpg

RequestedSensor modeField of view