@trillboards/edge-sdk 0.2.197 → 0.2.203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/test_colors_v2.py +79 -0
- package/deploy/detector/tests/test_detection_colors_wire.py +25 -0
- package/deploy/detector/tests/test_held_phone_customer_packaging.py +102 -0
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/colors.py +30 -11
- package/deploy/detector/trillboards_detector/server.py +1 -1
- package/deploy/macos/build-macos-pkg.sh +14 -2
- package/deploy/windows/build-windows.ps1 +12 -2
- package/deploy/windows/ci/test-published-install.ps1 +486 -15
- package/deploy/windows/setup-detector.ps1 +4 -1
- package/dist/DetectionColors.d.ts +11 -4
- package/dist/DetectionColors.d.ts.map +1 -1
- package/dist/DetectionColors.js +5 -2
- package/dist/DetectionColors.js.map +1 -1
- package/dist/DetectorFields.d.ts +138 -4
- package/dist/DetectorFields.d.ts.map +1 -1
- package/dist/DetectorFields.js +101 -11
- package/dist/DetectorFields.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/LiteRtVlmProvider.d.ts.map +1 -1
- package/dist/LiteRtVlmProvider.js +10 -1
- package/dist/LiteRtVlmProvider.js.map +1 -1
- package/dist/PhoneEmbeddingClassifier.d.ts +28 -0
- package/dist/PhoneEmbeddingClassifier.d.ts.map +1 -0
- package/dist/PhoneEmbeddingClassifier.js +40 -0
- package/dist/PhoneEmbeddingClassifier.js.map +1 -0
- package/dist/RetainedFieldContract.d.ts +9 -1
- package/dist/RetainedFieldContract.d.ts.map +1 -1
- package/dist/RetainedFieldContract.js +19 -3
- package/dist/RetainedFieldContract.js.map +1 -1
- package/dist/ScopedVlmReview.d.ts +6 -2
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +55 -5
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +6 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +7 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSensing.d.ts +5 -2
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +56 -8
- package/dist/localSensing.js.map +1 -1
- package/package.json +3 -3
- package/retained/ProfileAuthorityClient.cjs +1 -1
- package/retained/RetainedCaptureClient.cjs +2 -1
- package/retained/WebsiteAdmissionCaptureClient.cjs +478 -0
- package/retained/WebsiteAdmissionState.cjs +75 -0
- package/retained/__tests__/actor-perception.test.cjs +1 -1
- package/retained/__tests__/actor-window.test.cjs +1 -1
- package/retained/__tests__/archive-lifecycle.test.cjs +1 -1
- package/retained/__tests__/runtime.test.cjs +30 -2
- package/retained/__tests__/website-admission-realtime.test.cjs +503 -0
- package/retained/__tests__/website-admission.test.cjs +806 -0
- package/retained/manager.cjs +4 -1
- package/retained/pilot-profile-client.cjs +2 -1
|
@@ -10,7 +10,7 @@ name = "trillboards-detector"
|
|
|
10
10
|
# constant, a `labels.py`-only change survives `uv tool install` AND
|
|
11
11
|
# `uv tool install --force`; move the version and a bare `uv tool install`
|
|
12
12
|
# reinstalls. See `stamp_version.py`.
|
|
13
|
-
version = "0.2.0+src.
|
|
13
|
+
version = "0.2.0+src.42da00861e2b"
|
|
14
14
|
description = "On-device object-detector service for the Trillboards BYO-CCTV connector (loopback HTTP, ONNX Runtime)."
|
|
15
15
|
requires-python = ">=3.10"
|
|
16
16
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Bounded colour contract; synthetic fixtures establish arithmetic, never field accuracy."""
|
|
2
|
+
import importlib.util
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from trillboards_detector.colors import validate_color_request, build_color_response
|
|
6
|
+
|
|
7
|
+
V1 = {"version": 1, "minScore": .25, "maxBoxes": 32, "hue": [[0, 10], [240, 255]],
|
|
8
|
+
"minSaturation": 100, "minValue": 60}
|
|
9
|
+
V2 = {"version": 2, "minScore": .25, "maxBoxes": 32, "hue": [[0, 255]],
|
|
10
|
+
"minSaturation": 0, "maxSaturation": 40, "minValue": 60, "maxValue": 199}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BoundedColourContractTest(unittest.TestCase):
|
|
14
|
+
def test_v1_request_and_response_are_unchanged(self):
|
|
15
|
+
self.assertEqual(validate_color_request(V1), V1)
|
|
16
|
+
self.assertEqual(build_color_response(V1, [2], [.08], "a" * 64, (160, 120)),
|
|
17
|
+
{"version": 1, "imageSha256": "a" * 64, "frameSize": {"width": 160, "height": 120},
|
|
18
|
+
"request": V1, "people": [{"detectionIndex": 2, "fraction": .08}]})
|
|
19
|
+
with self.assertRaises(ValueError):
|
|
20
|
+
validate_color_request({**V1, "maxValue": 255})
|
|
21
|
+
|
|
22
|
+
def test_v2_accepts_bounds_and_echoes_its_own_version(self):
|
|
23
|
+
self.assertEqual(validate_color_request(V2), V2)
|
|
24
|
+
result = build_color_response(V2, [2, 1], [.08, 0.0], "b" * 64, (160, 120))
|
|
25
|
+
self.assertEqual(result["version"], 2)
|
|
26
|
+
self.assertEqual(result["request"], V2)
|
|
27
|
+
self.assertEqual(result["people"], [{"detectionIndex": 2, "fraction": .08},
|
|
28
|
+
{"detectionIndex": 1, "fraction": 0.0}])
|
|
29
|
+
|
|
30
|
+
def test_v2_accepts_equal_inclusive_endpoints(self):
|
|
31
|
+
request = {**V2, "minSaturation": 40, "maxSaturation": 40, "minValue": 199, "maxValue": 199}
|
|
32
|
+
self.assertEqual(validate_color_request(request), request)
|
|
33
|
+
|
|
34
|
+
def test_v2_refuses_missing_unknown_or_invalid_bounds(self):
|
|
35
|
+
bad = [{**V2, "version": 3}, {**V2, "version": True},
|
|
36
|
+
{k: v for k, v in V2.items() if k != "maxValue"},
|
|
37
|
+
{k: v for k, v in V2.items() if k != "maxSaturation"},
|
|
38
|
+
{**V2, "minSaturation": 41}, {**V2, "minValue": 200},
|
|
39
|
+
{**V2, "maxSaturation": 256}, {**V2, "maxValue": -1},
|
|
40
|
+
{**V2, "maxValue": True}, {**V2, "maxValue": 199.5},
|
|
41
|
+
{**V2, "hue": [[10, 0]]}, {**V2, "maxBoxes": 33}, {**V2, "extra": 1}]
|
|
42
|
+
for request in bad:
|
|
43
|
+
with self.subTest(request=request), self.assertRaises(ValueError):
|
|
44
|
+
validate_color_request(request)
|
|
45
|
+
|
|
46
|
+
def test_v2_empty_selection_remains_an_explicit_empty_result(self):
|
|
47
|
+
result = build_color_response(V2, [], [], "c" * 64, (160, 120))
|
|
48
|
+
self.assertEqual(result["version"], 2)
|
|
49
|
+
self.assertEqual(result["people"], [])
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@unittest.skipUnless(importlib.util.find_spec("numpy"), "NumPy unavailable for actual HSV arithmetic")
|
|
53
|
+
class BoundedColourArithmeticTest(unittest.TestCase):
|
|
54
|
+
def test_upper_and_lower_bounds_and_red_hue_wrap_are_inclusive(self):
|
|
55
|
+
import numpy as np
|
|
56
|
+
from trillboards_detector.colors import color_pixel_mask
|
|
57
|
+
hsv = np.asarray([[[0, 100, 60], [10, 200, 199], [240, 200, 199], [255, 200, 199],
|
|
58
|
+
[11, 100, 60], [239, 100, 60], [0, 99, 60], [0, 201, 60],
|
|
59
|
+
[0, 100, 59], [0, 100, 200]]], dtype=np.int16)
|
|
60
|
+
request = {**V2, "hue": [[0, 10], [240, 255]], "minSaturation": 100, "maxSaturation": 200}
|
|
61
|
+
self.assertEqual(color_pixel_mask(hsv, request).tolist(),
|
|
62
|
+
[[True, True, True, True, False, False, False, False, False, False]])
|
|
63
|
+
self.assertEqual(color_pixel_mask(hsv, V1).tolist(),
|
|
64
|
+
[[True, True, True, True, False, False, False, True, False, True]])
|
|
65
|
+
|
|
66
|
+
def test_black_white_and_grey_are_distinguished_by_value_and_saturation(self):
|
|
67
|
+
import numpy as np
|
|
68
|
+
from trillboards_detector.colors import color_pixel_mask
|
|
69
|
+
hsv = np.asarray([[[0, 0, 0], [200, 255, 59], [0, 0, 60], [255, 40, 199],
|
|
70
|
+
[0, 0, 200], [255, 40, 255], [0, 41, 200]]], dtype=np.int16)
|
|
71
|
+
black = {**V2, "maxSaturation": 255, "minValue": 0, "maxValue": 59}
|
|
72
|
+
white = {**V2, "minValue": 200, "maxValue": 255}
|
|
73
|
+
self.assertEqual(color_pixel_mask(hsv, black).tolist(), [[True, True, False, False, False, False, False]])
|
|
74
|
+
self.assertEqual(color_pixel_mask(hsv, V2).tolist(), [[False, False, True, True, False, False, False]])
|
|
75
|
+
self.assertEqual(color_pixel_mask(hsv, white).tolist(), [[False, False, False, False, True, True, False]])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
unittest.main()
|
|
@@ -123,6 +123,31 @@ class DetectionColorsWireTest(unittest.TestCase):
|
|
|
123
123
|
self.assertNotIn("detections", body)
|
|
124
124
|
self.assertEqual(self.source.calls, 0)
|
|
125
125
|
|
|
126
|
+
def test_v2_bounds_select_grey_without_matching_the_saturated_red_half(self):
|
|
127
|
+
self.start([Detection("person", .9, 10, 10, 40, 80), Detection("person", .8, 100, 10, 40, 80)])
|
|
128
|
+
request = {"version": 2, "minScore": .25, "maxBoxes": 32, "hue": [[0, 255]],
|
|
129
|
+
"minSaturation": 0, "maxSaturation": 40, "minValue": 60, "maxValue": 199}
|
|
130
|
+
status, body = self.post(detection_colors=request)
|
|
131
|
+
self.assertEqual(status, 200)
|
|
132
|
+
colors = body["detection_colors"]
|
|
133
|
+
self.assertEqual(colors["version"], 2)
|
|
134
|
+
self.assertEqual(colors["request"], request)
|
|
135
|
+
self.assertEqual(colors["imageSha256"], hashlib.sha256(self.jpeg).hexdigest())
|
|
136
|
+
self.assertEqual(colors["frameSize"], {"width": 160, "height": 120})
|
|
137
|
+
self.assertEqual(colors["people"], [{"detectionIndex": 0, "fraction": 1.0},
|
|
138
|
+
{"detectionIndex": 1, "fraction": 0.0}])
|
|
139
|
+
|
|
140
|
+
def test_v2_invalid_or_incomplete_bounds_are_refused_before_detection(self):
|
|
141
|
+
self.start([Detection("person", .9, 100, 10, 40, 80)])
|
|
142
|
+
request = {**UNIFORM, "version": 2, "maxSaturation": 255, "maxValue": 255}
|
|
143
|
+
for change in [{"maxSaturation": 99}, {"maxValue": 59}, {"maxValue": True},
|
|
144
|
+
{"maxValue": 256}, {"extra": 1}]:
|
|
145
|
+
status, _ = self.post(detection_colors={**request, **change})
|
|
146
|
+
self.assertEqual(status, 400, change)
|
|
147
|
+
status, _ = self.post(detection_colors={key: value for key, value in request.items() if key != "maxValue"})
|
|
148
|
+
self.assertEqual(status, 400)
|
|
149
|
+
self.assertEqual(self.source.calls, 0)
|
|
150
|
+
|
|
126
151
|
def test_an_unrequested_colour_task_is_absent(self):
|
|
127
152
|
self.start([Detection("person", .9, 100, 10, 40, 80)])
|
|
128
153
|
status, body = self.post(detection_colors=None)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Customer manifest and tiny source-staging fixtures; no installer/model run."""
|
|
2
|
+
import base64
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
import unittest
|
|
11
|
+
|
|
12
|
+
SDK = Path(__file__).resolve().parents[3]
|
|
13
|
+
DEPLOY = SDK / "deploy"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HeldPhoneCustomerPackaging(unittest.TestCase):
|
|
17
|
+
def test_npm_manifest_excludes_frozen_phone_but_keeps_other_retained_and_rf_pose(self):
|
|
18
|
+
result = subprocess.run(["npm", "pack", "--dry-run", "--json", "--ignore-scripts"],
|
|
19
|
+
cwd=SDK, capture_output=True, text=True, timeout=40)
|
|
20
|
+
self.assertEqual(result.returncode, 0, result.stderr)
|
|
21
|
+
if os.environ.get("HELD_PHONE_NPM_MANIFEST"):
|
|
22
|
+
Path(os.environ["HELD_PHONE_NPM_MANIFEST"]).write_text(result.stdout)
|
|
23
|
+
files = {row["path"] for row in json.loads(result.stdout)[0]["files"]}
|
|
24
|
+
self.assertFalse(sorted(p for p in files if p.startswith("retained/phone-embedding/")))
|
|
25
|
+
tracked = subprocess.check_output(["git", "ls-files", "--", "retained"], cwd=SDK, text=True).splitlines()
|
|
26
|
+
expected = {p for p in tracked if not p.startswith("retained/phone-embedding/")
|
|
27
|
+
and Path(p).name not in (".npmignore", ".gitignore", ".gitattributes")}
|
|
28
|
+
self.assertTrue(expected)
|
|
29
|
+
self.assertEqual(sorted(expected-files), [])
|
|
30
|
+
for relative in ["deploy/detector/pyproject.toml", "deploy/detector/trillboards_detector/loader.py",
|
|
31
|
+
"deploy/detector/trillboards_detector/pose.py", "deploy/detector/trillboards_detector/session.py"]:
|
|
32
|
+
self.assertIn(relative, files)
|
|
33
|
+
self.assertNotIn("ai-edge-litert", (DEPLOY / "detector/pyproject.toml").read_text())
|
|
34
|
+
|
|
35
|
+
def test_actual_windows_copy_omits_only_phone_and_preserves_original(self):
|
|
36
|
+
powershell = shutil.which("powershell.exe")
|
|
37
|
+
if not powershell:
|
|
38
|
+
self.skipTest("Windows PowerShell is required for the Windows copy fixture")
|
|
39
|
+
source = DEPLOY / "windows/build-windows.ps1"
|
|
40
|
+
source_text = source.read_text()
|
|
41
|
+
self.assertIn('Copy-RetainedRuntime -Source "$PkgRoot\\retained"', source_text)
|
|
42
|
+
self.assertIn('Copy-RetainedRuntime -Source "$src\\retained"', source_text)
|
|
43
|
+
source_path = str(source) if os.name == "nt" else subprocess.check_output(["wslpath", "-w", str(source)], text=True).strip()
|
|
44
|
+
script = r"""
|
|
45
|
+
$ErrorActionPreference='Stop';$ProgressPreference='SilentlyContinue'
|
|
46
|
+
$tokens=$null;$errors=$null
|
|
47
|
+
$tree=[Management.Automation.Language.Parser]::ParseInput([IO.File]::ReadAllText('%s',[Text.Encoding]::UTF8),[ref]$tokens,[ref]$errors)
|
|
48
|
+
if($errors){throw 'Staging source parse failed'}
|
|
49
|
+
$definition=$tree.Find({param($node)$node -is [Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Copy-RetainedRuntime'},$true)
|
|
50
|
+
if(-not $definition){throw 'Missing actual staging function'}
|
|
51
|
+
Invoke-Expression $definition.Extent.Text
|
|
52
|
+
$base=[IO.Path]::GetFullPath([IO.Path]::GetTempPath())
|
|
53
|
+
$root=Join-Path $base ('trillboards-held-phone-copy-'+[Guid]::NewGuid().ToString('N'))
|
|
54
|
+
try {
|
|
55
|
+
$source=Join-Path $root 'source'
|
|
56
|
+
New-Item -ItemType Directory -Force -Path (Join-Path $source 'phone-embedding\source'),(Join-Path $source 'other')|Out-Null
|
|
57
|
+
foreach($name in @('manager.cjs','.evidence','other\keep.json','phone-embedding\source\model.tflite')) {
|
|
58
|
+
Set-Content -LiteralPath (Join-Path $source $name) -Value 'non-model fixture'
|
|
59
|
+
}
|
|
60
|
+
$results=@()
|
|
61
|
+
foreach($relative in @('lib\edge-sdk\retained','lib\node_modules\@trillboards\edge-sdk\retained')){
|
|
62
|
+
$dest=Join-Path $root $relative
|
|
63
|
+
Copy-RetainedRuntime -Source $source -Destination $dest
|
|
64
|
+
$results+=,@(Get-ChildItem -LiteralPath $dest -Recurse -Force -File|ForEach-Object{$_.FullName.Substring($dest.Length+1)}|Sort-Object)
|
|
65
|
+
}
|
|
66
|
+
[pscustomobject]@{results=@($results);originalPreserved=(Test-Path -LiteralPath (Join-Path $source 'phone-embedding\source\model.tflite'))}|ConvertTo-Json -Compress -Depth 5
|
|
67
|
+
}finally{
|
|
68
|
+
$resolved=[IO.Path]::GetFullPath($root)
|
|
69
|
+
if(-not $resolved.StartsWith($base,[StringComparison]::OrdinalIgnoreCase) -or [IO.Path]::GetFileName($resolved) -notlike 'trillboards-held-phone-copy-*'){throw 'Fixture cleanup escaped temp root'}
|
|
70
|
+
Remove-Item -LiteralPath $resolved -Recurse -Force -ErrorAction SilentlyContinue
|
|
71
|
+
}
|
|
72
|
+
""" % source_path.replace("'", "''")
|
|
73
|
+
result = subprocess.run([powershell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand",
|
|
74
|
+
base64.b64encode(script.encode("utf-16le")).decode()],
|
|
75
|
+
capture_output=True, text=True, timeout=15)
|
|
76
|
+
self.assertEqual(result.returncode, 0, result.stdout+result.stderr)
|
|
77
|
+
self.assertEqual(json.loads(result.stdout.strip().splitlines()[-1]),
|
|
78
|
+
{"results": [[".evidence", "manager.cjs", "other\\keep.json"]]*2, "originalPreserved": True})
|
|
79
|
+
|
|
80
|
+
def test_actual_macos_copy_omits_only_phone_and_preserves_original(self):
|
|
81
|
+
source = (DEPLOY / "macos/build-macos-pkg.sh").read_text()
|
|
82
|
+
match = re.search(r"^copy_retained_runtime\(\) \{.*?^\}", source, re.M | re.S)
|
|
83
|
+
self.assertIsNotNone(match)
|
|
84
|
+
self.assertIn('copy_retained_runtime "$PKG_ROOT/retained"', source)
|
|
85
|
+
self.assertIn('copy_retained_runtime "$src/retained"', source)
|
|
86
|
+
with tempfile.TemporaryDirectory(prefix="held-phone-copy-") as temp:
|
|
87
|
+
root=Path(temp)
|
|
88
|
+
for name in ["manager.cjs", ".evidence", "other/keep.json", "phone-embedding/source/model.tflite"]:
|
|
89
|
+
file=root/"source"/name;file.parent.mkdir(parents=True,exist_ok=True);file.write_text("non-model fixture")
|
|
90
|
+
for relative in ["lib/edge-sdk/retained", "lib/node_modules/@trillboards/edge-sdk/retained"]:
|
|
91
|
+
dest=root/relative
|
|
92
|
+
result=subprocess.run(["bash","-c",match.group()+'\ncopy_retained_runtime "$1" "$2"',
|
|
93
|
+
"held-phone-copy-fixture",str(root/"source"),str(dest)],
|
|
94
|
+
capture_output=True,text=True,timeout=5)
|
|
95
|
+
self.assertEqual(result.returncode,0,result.stderr)
|
|
96
|
+
self.assertEqual(sorted(p.relative_to(dest).as_posix() for p in dest.rglob("*") if p.is_file()),
|
|
97
|
+
[".evidence","manager.cjs","other/keep.json"])
|
|
98
|
+
self.assertTrue((root/"source/phone-embedding/source/model.tflite").is_file())
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
unittest.main()
|
|
@@ -4,7 +4,9 @@ A uniform is the cheapest staff cue a ceiling camera sees: the Texas paint
|
|
|
4
4
|
counter's staff wear the store's red vest or shirt, its customers almost never
|
|
5
5
|
do. The connector decides "is a staff member here" from the share of a
|
|
6
6
|
person's box that is uniform-coloured; this module measures that share and
|
|
7
|
-
nothing else. It runs no model and makes no decision.
|
|
7
|
+
nothing else. It runs no model and makes no decision. Version 2 also supports
|
|
8
|
+
upper saturation/value bounds for selected achromatic and bounded colours;
|
|
9
|
+
neither version identifies garment type.
|
|
8
10
|
|
|
9
11
|
The arithmetic is the one the 2026-11-04 measurement used
|
|
10
12
|
(docs/runbooks/cctv-detector-tier.md section 5b): Pillow decodes the original
|
|
@@ -26,20 +28,28 @@ MAX_HUE_RANGES = 4
|
|
|
26
28
|
|
|
27
29
|
def validate_color_request(value):
|
|
28
30
|
"""`detection_colors` -> the same dict, or ValueError."""
|
|
31
|
+
bounded = isinstance(value, dict) and value.get("version") == 2
|
|
32
|
+
fields = {"version", "minScore", "maxBoxes", "hue", "minSaturation", "minValue"}
|
|
33
|
+
if bounded:
|
|
34
|
+
fields |= {"maxSaturation", "maxValue"}
|
|
29
35
|
if (not isinstance(value, dict)
|
|
30
|
-
or set(value) !=
|
|
31
|
-
or type(value["version"]) is not int or value["version"]
|
|
36
|
+
or set(value) != fields
|
|
37
|
+
or type(value["version"]) is not int or value["version"] not in (1, 2)
|
|
32
38
|
or isinstance(value["minScore"], bool) or not isinstance(value["minScore"], (int, float))
|
|
33
39
|
or not math.isfinite(value["minScore"]) or not 0 < value["minScore"] <= 1
|
|
34
40
|
or type(value["maxBoxes"]) is not int or not 1 <= value["maxBoxes"] <= MAX_COLOR_BOXES
|
|
35
41
|
or type(value["minSaturation"]) is not int or not 0 <= value["minSaturation"] <= 255
|
|
36
42
|
or type(value["minValue"]) is not int or not 0 <= value["minValue"] <= 255
|
|
43
|
+
or bounded and (type(value["maxSaturation"]) is not int
|
|
44
|
+
or not value["minSaturation"] <= value["maxSaturation"] <= 255
|
|
45
|
+
or type(value["maxValue"]) is not int
|
|
46
|
+
or not value["minValue"] <= value["maxValue"] <= 255)
|
|
37
47
|
or not isinstance(value["hue"], list) or not 1 <= len(value["hue"]) <= MAX_HUE_RANGES
|
|
38
48
|
or any(not isinstance(r, list) or len(r) != 2 or any(type(v) is not int for v in r)
|
|
39
49
|
or not 0 <= r[0] <= r[1] <= 255 for r in value["hue"])):
|
|
40
50
|
raise ValueError(
|
|
41
|
-
"detection_colors needs version 1
|
|
42
|
-
"1..%d hue ranges of whole 0..255 values
|
|
51
|
+
"detection_colors needs version 1 floors or version 2 saturation/value bounds, "
|
|
52
|
+
"minScore in (0, 1], maxBoxes 1..%d, and 1..%d hue ranges of whole 0..255 values"
|
|
43
53
|
% (MAX_COLOR_BOXES, MAX_HUE_RANGES))
|
|
44
54
|
return {**value, "hue": [list(r) for r in value["hue"]]}
|
|
45
55
|
|
|
@@ -52,6 +62,19 @@ def color_box_indices(detections, request):
|
|
|
52
62
|
return [index for index, _ in people[:request["maxBoxes"]]]
|
|
53
63
|
|
|
54
64
|
|
|
65
|
+
def color_pixel_mask(hsv, request):
|
|
66
|
+
"""Inclusive Pillow 8-bit HSV predicate; version 1 retains its measured floors."""
|
|
67
|
+
import numpy as np
|
|
68
|
+
hue, sat, val = hsv[..., 0], hsv[..., 1], hsv[..., 2]
|
|
69
|
+
in_hue = np.zeros(hue.shape, dtype=bool)
|
|
70
|
+
for low, high in request["hue"]:
|
|
71
|
+
in_hue |= (hue >= low) & (hue <= high)
|
|
72
|
+
match = in_hue & (sat >= request["minSaturation"]) & (val >= request["minValue"])
|
|
73
|
+
if request["version"] == 2:
|
|
74
|
+
match &= (sat <= request["maxSaturation"]) & (val <= request["maxValue"])
|
|
75
|
+
return match
|
|
76
|
+
|
|
77
|
+
|
|
55
78
|
def detection_color_fractions(jpeg, boxes, request):
|
|
56
79
|
"""Fraction of each [x, y, width, height] box whose pixels match the request."""
|
|
57
80
|
import numpy as np
|
|
@@ -61,11 +84,7 @@ def detection_color_fractions(jpeg, boxes, request):
|
|
|
61
84
|
raise ValueError("colour fractions need a bounded original JPEG")
|
|
62
85
|
hsv = np.asarray(image.convert("HSV")).astype(np.int16)
|
|
63
86
|
height, width = hsv.shape[0], hsv.shape[1]
|
|
64
|
-
|
|
65
|
-
in_hue = np.zeros(hue.shape, dtype=bool)
|
|
66
|
-
for low, high in request["hue"]:
|
|
67
|
-
in_hue |= (hue >= low) & (hue <= high)
|
|
68
|
-
match = in_hue & (sat >= request["minSaturation"]) & (val >= request["minValue"])
|
|
87
|
+
match = color_pixel_mask(hsv, request)
|
|
69
88
|
fractions = []
|
|
70
89
|
for x, y, w, h in boxes:
|
|
71
90
|
x0, x1 = int(max(0, x)), int(min(width, x + w))
|
|
@@ -79,7 +98,7 @@ def build_color_response(request, indices, fractions, image_sha256, frame_size):
|
|
|
79
98
|
if len(indices) != len(fractions) or any(
|
|
80
99
|
isinstance(f, bool) or not isinstance(f, float) or not 0 <= f <= 1 for f in fractions):
|
|
81
100
|
raise ValueError("colour fractions differ from the requested person boxes")
|
|
82
|
-
return {"version":
|
|
101
|
+
return {"version": request["version"], "imageSha256": image_sha256,
|
|
83
102
|
"frameSize": {"width": frame_size[0], "height": frame_size[1]},
|
|
84
103
|
"request": request,
|
|
85
104
|
"people": [{"detectionIndex": i, "fraction": f} for i, f in zip(indices, fractions)]}
|
|
@@ -276,7 +276,7 @@ def parse_detection_pose(raw: bytes):
|
|
|
276
276
|
|
|
277
277
|
|
|
278
278
|
def parse_detection_colors(raw: bytes):
|
|
279
|
-
"""`detection_colors`:
|
|
279
|
+
"""`detection_colors`: v1 floors or v2 bounded colour share of each confident person box."""
|
|
280
280
|
body = json.loads(raw.decode("utf-8"))
|
|
281
281
|
if "detection_colors" not in body:
|
|
282
282
|
return None
|
|
@@ -206,7 +206,19 @@ log "Building all edge workspaces (tsc, dependency order)…"
|
|
|
206
206
|
log "Staging edge-sdk dist…"
|
|
207
207
|
mkdir -p "$PAYLOAD/lib/edge-sdk"
|
|
208
208
|
cp -R "$PKG_ROOT/dist" "$PAYLOAD/lib/edge-sdk/dist"
|
|
209
|
-
|
|
209
|
+
# Frozen experimental phone code/models remain repository evidence. Released
|
|
210
|
+
# phone sensing uses the normal RF-DETR/pose service; omit the obsolete helper.
|
|
211
|
+
copy_retained_runtime() {
|
|
212
|
+
local source="$1" destination="$2" item
|
|
213
|
+
mkdir -p "$destination"
|
|
214
|
+
for item in "$source"/* "$source"/.[!.]* "$source"/..?*; do
|
|
215
|
+
[ -e "$item" ] || [ -L "$item" ] || continue
|
|
216
|
+
[ "${item##*/}" != 'phone-embedding' ] || continue
|
|
217
|
+
cp -R "$item" "$destination/"
|
|
218
|
+
done
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
copy_retained_runtime "$PKG_ROOT/retained" "$PAYLOAD/lib/edge-sdk/retained"
|
|
210
222
|
cp "$PKG_ROOT/package.json" "$PAYLOAD/lib/edge-sdk/package.json"
|
|
211
223
|
|
|
212
224
|
# ─── 3. Lay down the runtime node_modules subset (NO heavy native stack) ──────
|
|
@@ -242,7 +254,7 @@ for p in edge-core edge-sensing edge-ads edge-federated edge-cloud \
|
|
|
242
254
|
rm -rf "$dest"
|
|
243
255
|
mkdir -p "$dest"
|
|
244
256
|
[ -d "$src/dist" ] && cp -R "$src/dist" "$dest/dist"
|
|
245
|
-
[ "$p" != "edge-sdk" ] ||
|
|
257
|
+
[ "$p" != "edge-sdk" ] || copy_retained_runtime "$src/retained" "$dest/retained"
|
|
246
258
|
cp "$src/package.json" "$dest/package.json"
|
|
247
259
|
done
|
|
248
260
|
|
|
@@ -93,6 +93,16 @@ if (Test-Path $Stage) { Remove-Item -Recurse -Force $Stage }
|
|
|
93
93
|
if (Test-Path $Scratch) { Remove-Item -Recurse -Force $Scratch }
|
|
94
94
|
New-Item -ItemType Directory -Force -Path "$Payload\bin","$Payload\lib","$Scratch" | Out-Null
|
|
95
95
|
|
|
96
|
+
# The frozen experimental phone helper remains repository evidence. Released
|
|
97
|
+
# phone sensing uses the normal RF-DETR/pose service; omit the obsolete helper.
|
|
98
|
+
function Copy-RetainedRuntime([string]$Source, [string]$Destination) {
|
|
99
|
+
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
|
100
|
+
foreach ($item in (Get-ChildItem -LiteralPath $Source -Force)) {
|
|
101
|
+
if ($item.Name -eq 'phone-embedding') { continue }
|
|
102
|
+
Copy-Item -LiteralPath $item.FullName -Destination $Destination -Recurse -Force
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
# ─── 1. Build ALL edge workspaces (tsc, dependency order) ──────────────────────
|
|
97
107
|
# edge-sdk's tsc imports edge-core, edge-platform-rtsp/linux/windows, edge-sensing,
|
|
98
108
|
# edge-ads, edge-federated AND edge-cloud — every workspace's dist must exist before
|
|
@@ -107,7 +117,7 @@ Push-Location $WorkspaceRoot; npm run build; if ($LASTEXITCODE -ne 0) { Die "edg
|
|
|
107
117
|
Log "Staging edge-sdk dist…"
|
|
108
118
|
New-Item -ItemType Directory -Force -Path "$Payload\lib\edge-sdk" | Out-Null
|
|
109
119
|
Copy-Item -Recurse -Force "$PkgRoot\dist" "$Payload\lib\edge-sdk\dist"
|
|
110
|
-
Copy-
|
|
120
|
+
Copy-RetainedRuntime -Source "$PkgRoot\retained" -Destination "$Payload\lib\edge-sdk\retained"
|
|
111
121
|
Copy-Item -Force "$PkgRoot\package.json" "$Payload\lib\edge-sdk\package.json"
|
|
112
122
|
|
|
113
123
|
# ─── 3. Runtime node_modules subset (NO heavy native stack) ────────────────────
|
|
@@ -144,7 +154,7 @@ foreach ($p in @("edge-core","edge-sensing","edge-ads","edge-federated","edge-cl
|
|
|
144
154
|
if (Test-Path $dest) { Remove-Item -Recurse -Force $dest }
|
|
145
155
|
New-Item -ItemType Directory -Force -Path $dest | Out-Null
|
|
146
156
|
if (Test-Path "$src\dist") { Copy-Item -Recurse -Force "$src\dist" "$dest\dist" }
|
|
147
|
-
if ($p -eq 'edge-sdk') { Copy-
|
|
157
|
+
if ($p -eq 'edge-sdk') { Copy-RetainedRuntime -Source "$src\retained" -Destination "$dest\retained" }
|
|
148
158
|
Copy-Item -Force "$src\package.json" "$dest\package.json"
|
|
149
159
|
}
|
|
150
160
|
|