feat(cctv): enrich identified cameras with datasheet FOV + specs

When a CCTV source pack (or a seed) names its hardware `model`, resolve it
against a camera-model spec table: the coverage frustum then uses the
manufacturer's horizontal FOV instead of the pose estimate, and the HUD meta
line gains the model's resolution, night-vision, and PTZ specs. Cameras with
no identified model are unchanged — unknown never implies anything, matching
the layer's existing honesty about RAW PRIOR poses.

Spec records are vendored verbatim from the CCTV Camera Database
(https://github.com/ch-bas/cctv-camera-database, CC0-1.0), an open dataset of
12,000+ camera models transcribed from manufacturer datasheets. This lands a
small starter table plus the join + parsing helpers; source packs that publish
their hardware can grow it. Records describe camera products (optics,
resolution, night vision) only — no endpoints or access data.

- src/layers/cctv/modelSpecs.js: spec table, case-insensitive/alias lookup,
  wide-end FOV parser, HUD summary formatter
- src/layers/cctv/modelSpecs.test.mjs: lookup/alias/unknown, FOV parsing
  across the real fov string shapes, summary rendering
- src/layers/cctv/catalog.js: apply enrichment in both catalog builders
- src/layers/cctv/presentation.js: label a datasheet FOV, append the spec
  summary, and pass fovSource + spec through the public camera state
This commit is contained in:
bassem chagra committed 2026-09-25 12:36:34 +02:00
1 parent b210ab0fe4
commit ccdf8f0dc2
4 files changed
+229 -1

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
// src/layers/cctv/modelSpecs.test.mjs
// Hardware-model spec enrichment: lookup semantics (case-insensitive, alias
// matching, unknown → null — never a guess), datasheet-FOV parsing across the
// real fov_deg string shapes, and the HUD spec-summary line.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import {
lookupModelSpec,
horizontalFovDeg,
specSummary,
} from './modelSpecs.js';
test('lookupModelSpec matches case-insensitively and trims', () => {
const spec = lookupModelSpec(' q6135-le ');
assert.ok(spec);
assert.equal(spec.brand, 'Axis');
assert.equal(lookupModelSpec('Q6135-LE'), spec);
});
test('lookupModelSpec matches aliases', () => {
const byAlias = lookupModelSpec('01959-004');
assert.ok(byAlias);
assert.equal(byAlias.model, 'Q6135-LE');
});
test('lookupModelSpec returns null for unknown or empty input — never guesses', () => {
assert.equal(lookupModelSpec('NOT-A-REAL-MODEL'), null);
assert.equal(lookupModelSpec(''), null);
assert.equal(lookupModelSpec(null), null);
assert.equal(lookupModelSpec(undefined), null);
});
test('horizontalFovDeg takes the wide end of a varifocal/PTZ range', () => {
// '58.3-2.4 horizontal' → 58.3 (wide), not 2.4 (tele).
assert.equal(horizontalFovDeg(lookupModelSpec('Q6135-LE')), 58.3);
});
test('horizontalFovDeg reads multi-variant and plain fov strings', () => {
// '108.8 horizontal (2.8mm) / 93.3 horizontal (4mm)' → first variant.
assert.equal(horizontalFovDeg(lookupModelSpec('DS-2CD2087G3-LI2UY')), 108.8);
// '110 horizontal, 60 vertical' → horizontal figure.
assert.equal(horizontalFovDeg(lookupModelSpec('F4105-LRE')), 110);
});
test('horizontalFovDeg returns null when no numeric FOV is stated', () => {
assert.equal(horizontalFovDeg({ fov_deg: '' }), null);
assert.equal(horizontalFovDeg({ fov_deg: 'wide dynamic range' }), null);
assert.equal(horizontalFovDeg({}), null);
assert.equal(horizontalFovDeg(null), null);
});
test('specSummary renders the HUD line and degrades by omission', () => {
assert.equal(
specSummary(lookupModelSpec('Q6135-LE')),
'Axis Q6135-LE · 1080p · IR 250m · PTZ',
);
// No night vision / no PTZ → those segments are simply absent.
assert.equal(
specSummary({ brand: 'Axis', model: 'X', resolution: { label: '4K' } }),
'Axis X · 4K',
);
assert.equal(specSummary(null), '');
});