# camera2 -- LumiScanX LX20230105 via LumiScanPlugin. Real hardware; disabled until the unit is present.
#
# FORMAT: a feature list, not a script -- "<feature name> <value>" per line, no verbs. An entry this
# camera has not got, or cannot currently write, is SKIPPED, so only a value the camera rejects is an
# error; the connect log reports applied/skipped/failed counts and CameraManager treats any FAILED
# entry as the camera failing to open.
#
# HAND-WRITTEN, and deliberately not a Save... export. The previous version of this file was an
# export and it could not restore this camera at all -- see "Why the components are spelled out"
# below. The exporter has since been fixed to expand selector-indexed features, so a future export
# WILL round-trip; this file stays hand-written because it also records *why* each value is what it
# is, which no export can.
#
# ORDER MATTERS in two places, both marked below. Entries are applied top to bottom (the applier's
# dependency sort stands aside as soon as a feature name repeats, which it does here), and failures
# are retried afterwards -- but do not rely on the retry, it is a backstop, not the design.

# ---------------------------------------------------------------------------------------------
# FIRST, always. The plugin refuses RegionMode on a Rectified source while no calibration is loaded
# ("the Rectified source needs a calibration"), and CalibDistortionModel is not even readable until
# one has been parsed. It is also what makes CalibFocalLengthX/Y + CalibOpticalCenterX/Y readable, so
# VGR gets this unit's real intrinsics (fx=1634.99, fy=1635.83, cx=636.34, cy=503.23) instead of a
# hard-coded fallback.
CalibrationFile cameras/features/LX20230105_LCTX28060001_1000-3000mm_20231120_017.hdvcal

# ---------------------------------------------------------------------------------------------
# Components -- one RANGE and one INTENSITY, aligned pixel-for-pixel.
#
# Why they are spelled out: ComponentEnable is scoped by whatever ComponentSelector names, and
# RegionMode by the PAIR (SourceSelector, RegionSelector). Neither can be expressed as a single
# "name value" line, which is exactly why the exported version of this file lost the point cloud
# entirely -- Range's enable simply was not in it.
#
# The plugin's own defaults are Intensity-only, Raw/FullFrame -- so every line here is load-bearing.

# The point cloud. Without this the container carries no RANGE component and VgrCapture takes its
# combined-frame path, where there is nothing to build a cloud from.
ComponentSelector Range
ComponentEnable true

# The master switch above the four intensity cells below.
ComponentSelector Intensity
ComponentEnable true

# ORDER MATTERS (1): SourceSelector and RegionSelector both scope RegionMode, so BOTH must be pinned
# before it is written. The exported file had RegionMode above SourceSelector, so it switched on
# Raw/CenterView and then moved the selector to Rectified with nothing following it -- the file asked
# for a rectified centre view and silently got a raw one.
#
# Rectified/CenterView is the only intensity image whose geometry corresponds to the cloud: a Raw
# image is not undistorted, and Rectified/FullFrame is a stack of 13 views rather than one image. It
# costs nothing extra -- it falls out of the same pass that produces the cloud. The RANGE component
# is stamped with this cell's own (SourceID=1, RegionID=1), which is how VgrCapture now finds "the
# image that goes with the cloud" rather than taking whichever image came first.
SourceSelector Rectified
RegionSelector CenterView
RegionMode true

# ...and off with the default. Turned off AFTER the line above, never before: the plugin refuses a
# RegionMode=false that would leave no component enabled.
#
# Raw/FullFrame is the 1280x12480 sensor stack. VGR can now carry it alongside the centre view (it
# matches components on the cloud's ids), so switching this back to `true` is a legitimate way to get
# an exposure-check or calibration-capture image in the same container for ~5 ms. Left off here
# because nothing in this demo reads it and it adds ~16 MB to every container.
SourceSelector Raw
RegionSelector FullFrame
RegionMode false

# ---------------------------------------------------------------------------------------------
# Depth estimation.
#
# The interval the search runs in, in METRES -- Scan3dDistanceUnit declares Meter because that is
# what lumiscan's depth kernel natively produces, so nothing is rescaled per frame. The device API
# underneath is integer millimetres, so the effective resolution is 1 mm.
#
# Not a display clip and not a filter over a finished cloud: these go to estimateDepthGPU() as the
# range it searches for correspondences in, and their midpoint is the plane the centre view is
# undistorted onto. A point outside the range is written as (0,0,0) -- Scan3dInvalidDataValue -- by
# the GPU kernel itself, so nothing downstream re-filters it.
#
# NOTE, unresolved: this unit's calibration is named "..._1000-3000mm_...", while the range below is
# 0.15..0.30 m. Nothing enforces that -- hdvcal_print shows the file carries camera geometry only
# (focus, Kappa, Sx/Sy, Cx/Cy, poses) and no working-range field -- so the mismatch is not an error
# and will not be reported as one. It only means the search runs where this calibration was not
# characterised. If the cloud comes out empty, sparse or noisy, this pair and that filename are the
# first two things to compare. (Measured 2026-09-04 at these values: 43 of 8000 sampled pixels had a
# valid confidence.)
#
# Max before Min: the endpoints bound each other, so writing Min while Max still holds a lower value
# is rejected.
Scan3dDistanceUnit Meter
Scan3dDistanceMax 0.300000
Scan3dDistanceMin 0.150000
Scan3dConfidenceThreshold 0.700000
Scan3dPreProcessingFilter Blur
Scan3dPostProcessingFilter Median

# ORDER MATTERS (2): unwritable until CalibrationFile above has been parsed, because the legal
# entries ARE a property of that file. This one declares only Kappa per camera -- the division model
# -- so "Polynomial" is not on offer and asking for it logs a fallback warning. Stated explicitly so
# the log stays quiet about it.
CalibDistortionModel Division

# ---------------------------------------------------------------------------------------------
# 8-bit intensity. The device default is Mono12, whose 12 bits sit in the TOP of the 16-bit word --
# reading it as if right-aligned clamps the picture away.
PixelFormat Mono8

TriggerMode On
TriggerSource Software
TriggerActivation FallingEdge
TriggerDelay 0.000000
TriggerOut 1

# Microseconds. 11 ms, carried over from the previous export -- note it survived there only as
# STREAM.ExposureTime; the device-context read had failed when that export was taken, which is why
# the old 45000 in the pre-export file is not what this camera was actually running at.
ExposureTime 11000.0

# Which sensor DeviceTemperature reports. VGR reads it once per setup.
DeviceTemperatureSelector SensorBoardPos1
