Add LED spline calibration evidence path
This commit is contained in:
parent
b9b2e07f82
commit
28c5a30e32
8 changed files with 278 additions and 3 deletions
|
|
@ -375,6 +375,15 @@ a named invariant that the native runtime cannot protect yet.
|
|||
It also proves a synthetic multi-camera marker candidate using the same
|
||||
FieldEvidence authority: deterministic marker features plan as
|
||||
`DebugOverlay` packets while ambiguous raw camera features still defer.
|
||||
LED strip calibration now has the same typed evidence path:
|
||||
`MimirLedSplineFieldCandidate` stores ordered per-camera bright-curve samples,
|
||||
temporal-code/index stability flags, and shared calibration/spline identity.
|
||||
`BuildLedSplineCandidateFrame` lowers that curve as deterministic
|
||||
camera-sensor Feature evidence, and `--led-spline-calibration-smoke` proves
|
||||
Fensalir plans it as one `DebugOverlay` packet with no deferred request.
|
||||
This is calibration evidence only. Exact correspondence requires coded or
|
||||
otherwise stable LED identity; uncoded repeated lights remain curve
|
||||
constraints until the global residual solver resolves them.
|
||||
Phase 6 program-output receipts are also structurally complete: Fensalir
|
||||
publishes the final program surface through named shared D3D12 texture/fence
|
||||
resources, the OBS plugin consumes that surface with an explicit D3D12-to-
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ flowchart TD
|
|||
C["Leap stereo IR driver"] --> B
|
||||
B --> D["native reservoir handles"]
|
||||
D --> E["Fensalir GPU feature extraction"]
|
||||
E --> J["LED spline observations"]
|
||||
E --> F["cross-view matching + flow"]
|
||||
J --> K["global residual calibration owner"]
|
||||
K --> F
|
||||
F --> G["surface/material claims"]
|
||||
G --> H["brush/splat render budget"]
|
||||
H --> I["Spout2/program video"]
|
||||
|
|
@ -23,9 +26,16 @@ flowchart TD
|
|||
- Process capture is a bridge edge, not the local six-camera foundation.
|
||||
- Fensalir owns GPU extraction, fusion, material fitting, and render budgeting.
|
||||
- Runtime buffers own retention and stream health, not scene reconstruction.
|
||||
- LED strips are active calibration evidence. Cameras may publish ordered
|
||||
bright-curve observations, but only the global residual calibration owner may
|
||||
update camera intrinsics/extrinsics.
|
||||
- Stable LED index identity requires temporal/color/address coding or another
|
||||
correspondence source; uncoded identical lights are spline constraints, not
|
||||
metric depth authority.
|
||||
|
||||
## Next Cut
|
||||
|
||||
Implement one concrete direct capture driver, feed `MimirVideoFrameDescriptor`
|
||||
samples into `MimirVideoCaptureDriverSource`, and measure sustained cadence over
|
||||
the default five-second window.
|
||||
Replace provisional Leap projection constants with calibrated intrinsics and
|
||||
add the global residual owner that consumes Leap surface errors, LED spline
|
||||
observations, and later PS3 Eye/Kiyo/Eve feature tracks through one calibration
|
||||
commit path.
|
||||
|
|
|
|||
|
|
@ -602,6 +602,19 @@ monitor notes. Phase 5's synthetic marker proof now exists too: Mimir lowers a
|
|||
deterministic multi-camera marker candidate with calibration/marker identity and
|
||||
world-space support, and Fensalir plans it as `DebugOverlay` evidence while
|
||||
ambiguous raw camera features still defer.
|
||||
LED strips now have a typed calibration-evidence socket instead of being folded
|
||||
into fake depth. `MimirLedSplineFieldCandidate` carries ordered per-camera
|
||||
bright-curve samples, whether the LEDs were temporally coded, and whether the
|
||||
sample indices are stable. `BuildLedSplineCandidateFrame` lowers that shared
|
||||
curve as deterministic camera-sensor Feature evidence; Fensalir plans it as a
|
||||
`DebugOverlay` packet through the same FieldEvidence authority. Addressable or
|
||||
blink-coded strips can provide exact cross-camera LED identity. Plain identical
|
||||
white LEDs still provide a strong spline/epipolar constraint, but their point
|
||||
correspondence is ambiguous under occlusion, saturation, repeated spacing, and
|
||||
motion blur until temporal continuity, Leap/body anchors, or a future residual
|
||||
solver disambiguates it. Individual cameras do not write calibration state; the
|
||||
future global residual owner consumes these claims and is the only authority
|
||||
allowed to update camera intrinsics/extrinsics.
|
||||
|
||||
The current teardown/migration map is
|
||||
`docs/fensalir-rendering-rebuild-migration.md`, paired with Fensalir's
|
||||
|
|
|
|||
|
|
@ -140,6 +140,11 @@ if (args.Any(arg => string.Equals(arg, "--fensalir-camera-observation-smoke", St
|
|||
return RunFensalirCameraObservationSmoke();
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--led-spline-calibration-smoke", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return RunLedSplineCalibrationSmoke();
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--fensalir-texture-lease-smoke", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return RunFensalirTextureLeaseSmoke();
|
||||
|
|
@ -791,6 +796,86 @@ static int RunFensalirCameraObservationSmoke()
|
|||
: 1;
|
||||
}
|
||||
|
||||
static int RunLedSplineCalibrationSmoke()
|
||||
{
|
||||
var candidate = new MimirLedSplineFieldCandidate(
|
||||
CandidateKey: "co-streamer-led-strip-frame-42",
|
||||
CalibrationId: "room-camera-rig-online-calibration",
|
||||
SplineId: "co-streamer-neck-to-hand-led-strip",
|
||||
ProducerKey: "mimir-led-spline-detector",
|
||||
CameraObservations:
|
||||
[
|
||||
new MimirLedSplineCameraObservation(
|
||||
ObservationKey: "ps3-eye-0:led-spline:42",
|
||||
SourceId: "ps3-eye-0",
|
||||
Width: 320,
|
||||
Height: 240,
|
||||
ObservedTimeNs: 1_000_000_000L,
|
||||
Points:
|
||||
[
|
||||
new MimirLedSplineObservationPoint(0, 0.00, 110.0, 82.0, 2.5, 0.91),
|
||||
new MimirLedSplineObservationPoint(1, 0.25, 132.0, 98.0, 2.2, 0.94),
|
||||
new MimirLedSplineObservationPoint(2, 0.50, 148.0, 126.0, 2.4, 0.92),
|
||||
new MimirLedSplineObservationPoint(3, 0.75, 171.0, 152.0, 2.6, 0.90),
|
||||
new MimirLedSplineObservationPoint(4, 1.00, 204.0, 184.0, 2.7, 0.89),
|
||||
],
|
||||
Confidence: 0.91),
|
||||
new MimirLedSplineCameraObservation(
|
||||
ObservationKey: "kiyo-basic:led-spline:42",
|
||||
SourceId: "kiyo-basic",
|
||||
Width: 1920,
|
||||
Height: 1080,
|
||||
ObservedTimeNs: 1_000_000_004L,
|
||||
Points:
|
||||
[
|
||||
new MimirLedSplineObservationPoint(0, 0.00, 763.0, 356.0, 4.4, 0.88),
|
||||
new MimirLedSplineObservationPoint(1, 0.25, 840.0, 432.0, 4.1, 0.93),
|
||||
new MimirLedSplineObservationPoint(2, 0.50, 914.0, 552.0, 4.3, 0.94),
|
||||
new MimirLedSplineObservationPoint(3, 0.75, 1018.0, 673.0, 4.6, 0.90),
|
||||
new MimirLedSplineObservationPoint(4, 1.00, 1188.0, 816.0, 4.9, 0.86),
|
||||
],
|
||||
Confidence: 0.90),
|
||||
],
|
||||
EstimatedLedCount: 5,
|
||||
HasTemporalCode: true,
|
||||
HasStableLedIndices: true,
|
||||
CurveLengthPixels: 568.0,
|
||||
Confidence: 0.89,
|
||||
ObservedTimeNs: 1_000_000_004L);
|
||||
|
||||
var lowerer = new MimirFensalirFieldLowering();
|
||||
var frame = lowerer.BuildLedSplineCandidateFrame([candidate]);
|
||||
var validation = AquariumFieldEvidenceValidator.Validate(frame);
|
||||
var plan = AquariumFieldLoweringPlanner.Plan(frame);
|
||||
var claim = frame.Claims.SingleOrDefault();
|
||||
|
||||
Console.WriteLine(
|
||||
$"led-spline-calibration-smoke domains={frame.Domains.Count} claims={frame.Claims.Count} planned={plan.Packets.Count} deferred={plan.DeferredRequests.Count} points={candidate.CameraObservations.Sum(static observation => observation.Points.Count)} errors={validation.HasErrors}");
|
||||
|
||||
if (validation.HasErrors)
|
||||
{
|
||||
foreach (var issue in validation.Issues)
|
||||
{
|
||||
Console.Error.WriteLine($"led-spline-calibration-issue {issue.Severity} {issue.Key}: {issue.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return !validation.HasErrors &&
|
||||
MimirVisualFusionConfigurations.BuiltIn.Any(profile => profile.Model == MimirVisualFusionModel.LedSplineCalibration) &&
|
||||
frame.Domains.Count == 1 &&
|
||||
frame.Domains[0].Kind == AquariumFieldDomainKind.CameraSensor &&
|
||||
frame.Claims.Count == 1 &&
|
||||
claim.Encoding == AquariumFieldEncoding.Feature &&
|
||||
claim.Proposal.Kind == AquariumFieldProposalKind.DeterministicStructural &&
|
||||
claim.Proposal.RepresentedCandidateCount == 10 &&
|
||||
claim.PayloadHandle.Contains("indexed:coded", StringComparison.Ordinal) &&
|
||||
plan.Packets.Count == 1 &&
|
||||
plan.Packets[0].Backend == AquariumFieldBackendKind.DebugOverlay &&
|
||||
plan.DeferredRequests.Count == 0
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
||||
static int RunFensalirTextureLeaseSmoke()
|
||||
{
|
||||
var broker = new FakeFieldResourceBroker();
|
||||
|
|
|
|||
|
|
@ -161,6 +161,36 @@ public sealed record MimirVisualMarkerFieldCandidate(
|
|||
double Confidence,
|
||||
long ObservedTimeNs);
|
||||
|
||||
public readonly record struct MimirLedSplineObservationPoint(
|
||||
int LedIndex,
|
||||
double CurveT,
|
||||
double ImageX,
|
||||
double ImageY,
|
||||
double RadiusPixels,
|
||||
double Confidence);
|
||||
|
||||
public sealed record MimirLedSplineCameraObservation(
|
||||
string ObservationKey,
|
||||
string SourceId,
|
||||
int Width,
|
||||
int Height,
|
||||
long ObservedTimeNs,
|
||||
IReadOnlyList<MimirLedSplineObservationPoint> Points,
|
||||
double Confidence);
|
||||
|
||||
public sealed record MimirLedSplineFieldCandidate(
|
||||
string CandidateKey,
|
||||
string CalibrationId,
|
||||
string SplineId,
|
||||
string ProducerKey,
|
||||
IReadOnlyList<MimirLedSplineCameraObservation> CameraObservations,
|
||||
int EstimatedLedCount,
|
||||
bool HasTemporalCode,
|
||||
bool HasStableLedIndices,
|
||||
double CurveLengthPixels,
|
||||
double Confidence,
|
||||
long ObservedTimeNs);
|
||||
|
||||
public readonly record struct MimirSurfaceAxes(
|
||||
string X,
|
||||
string Y,
|
||||
|
|
|
|||
|
|
@ -180,6 +180,40 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
};
|
||||
}
|
||||
|
||||
public AquariumFieldEvidenceFrame BuildLedSplineCandidateFrame(
|
||||
IEnumerable<MimirLedSplineFieldCandidate> splineCandidates)
|
||||
{
|
||||
var domains = new List<AquariumFieldDomain>();
|
||||
var claims = new List<AquariumFieldClaim>();
|
||||
var candidates = new List<AquariumFieldCandidate>();
|
||||
var seenDomains = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
foreach (var splineCandidate in splineCandidates)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(splineCandidate.CandidateKey) ||
|
||||
splineCandidate.CameraObservations.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var domain = DomainForLedSplineCandidate(splineCandidate);
|
||||
AddDomain(domains, seenDomains, domain);
|
||||
|
||||
var claim = ClaimForLedSplineCandidate(splineCandidate, domain.DomainKey);
|
||||
claims.Add(claim);
|
||||
candidates.Add(CandidateForClaim(claim, AquariumFieldGuide.Valid(claim.Confidence)));
|
||||
}
|
||||
|
||||
return new AquariumFieldEvidenceFrame
|
||||
{
|
||||
Domains = domains,
|
||||
Claims = claims,
|
||||
Candidates = candidates,
|
||||
AccumulationWindowSeconds = (float)options.AccumulationWindowSeconds,
|
||||
PresentationDelaySeconds = (float)options.PresentationDelaySeconds
|
||||
};
|
||||
}
|
||||
|
||||
public AquariumFieldEvidenceFrame BuildLeapPackedStereoDepthCandidateFrame(
|
||||
IEnumerable<MimirRollingStreamWindow> windows,
|
||||
IEnumerable<AquariumFieldResourceDeclaration> inputResources)
|
||||
|
|
@ -566,6 +600,27 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
"Mimir.Runtime");
|
||||
}
|
||||
|
||||
private static AquariumFieldDomain DomainForLedSplineCandidate(MimirLedSplineFieldCandidate candidate)
|
||||
{
|
||||
var points = candidate.CameraObservations.SelectMany(static observation => observation.Points).ToArray();
|
||||
var maxWidth = Math.Max(1, candidate.CameraObservations.Max(static observation => observation.Width));
|
||||
var maxHeight = Math.Max(1, candidate.CameraObservations.Max(static observation => observation.Height));
|
||||
var minX = points.Length == 0 ? 0.0f : Math.Clamp((float)points.Min(static point => point.ImageX), 0.0f, maxWidth);
|
||||
var minY = points.Length == 0 ? 0.0f : Math.Clamp((float)points.Min(static point => point.ImageY), 0.0f, maxHeight);
|
||||
var maxX = points.Length == 0 ? maxWidth : Math.Clamp((float)points.Max(static point => point.ImageX), minX, maxWidth);
|
||||
var maxY = points.Length == 0 ? maxHeight : Math.Clamp((float)points.Max(static point => point.ImageY), minY, maxHeight);
|
||||
return new AquariumFieldDomain(
|
||||
DomainKeyForLedSplineCandidate(candidate),
|
||||
"",
|
||||
AquariumFieldDomainKind.CameraSensor,
|
||||
Matrix4x4.Identity,
|
||||
Matrix4x4.Identity,
|
||||
new Vector3(minX, minY, 0.0f),
|
||||
new Vector3(maxX, maxY, Math.Max(1, candidate.CameraObservations.Count)),
|
||||
Vector3.Zero,
|
||||
"Mimir.Runtime");
|
||||
}
|
||||
|
||||
private static AquariumFieldDomain DomainForStereoDepthCandidate(MimirStereoDepthFieldCandidate candidate)
|
||||
{
|
||||
var width = Math.Max(1, candidate.Width);
|
||||
|
|
@ -711,6 +766,34 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
Confidence: confidence);
|
||||
}
|
||||
|
||||
private AquariumFieldClaim ClaimForLedSplineCandidate(
|
||||
MimirLedSplineFieldCandidate splineCandidate,
|
||||
string domainKey)
|
||||
{
|
||||
var confidence = Clamp01((float)splineCandidate.Confidence);
|
||||
var represented = Math.Max(1, splineCandidate.CameraObservations.Sum(static observation => observation.Points.Count));
|
||||
var proposal = new AquariumFieldProposalPolicy(
|
||||
AquariumFieldProposalKind.DeterministicStructural,
|
||||
SourcePdf: 1.0f,
|
||||
TargetContribution: confidence,
|
||||
RepresentedCandidateCount: represented,
|
||||
Seed: StableSeed(splineCandidate.CandidateKey));
|
||||
var indexState = splineCandidate.HasStableLedIndices ? "indexed" : "unindexed";
|
||||
var codeState = splineCandidate.HasTemporalCode ? "coded" : "uncoded";
|
||||
|
||||
return new AquariumFieldClaim(
|
||||
ClaimKey: $"led-spline:{splineCandidate.CalibrationId}:{splineCandidate.SplineId}:{splineCandidate.CandidateKey}",
|
||||
DomainKey: domainKey,
|
||||
ProducerKey: splineCandidate.ProducerKey,
|
||||
Layer: AquariumFieldLayer.Form,
|
||||
Encoding: AquariumFieldEncoding.Feature,
|
||||
Support: SupportForLedSplineCandidate(splineCandidate),
|
||||
Proposal: proposal,
|
||||
PayloadHandle: $"{splineCandidate.CalibrationId}:{splineCandidate.SplineId}:{indexState}:{codeState}",
|
||||
ObservedTimeNs: splineCandidate.ObservedTimeNs,
|
||||
Confidence: confidence);
|
||||
}
|
||||
|
||||
private AquariumFieldClaim ClaimForStereoDepthCandidate(
|
||||
MimirStereoDepthFieldCandidate depthCandidate,
|
||||
string domainKey)
|
||||
|
|
@ -904,6 +987,27 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
TemporalUncertainty: 0.0f);
|
||||
}
|
||||
|
||||
private AquariumFieldSupport SupportForLedSplineCandidate(MimirLedSplineFieldCandidate splineCandidate)
|
||||
{
|
||||
var points = splineCandidate.CameraObservations.SelectMany(static observation => observation.Points).ToArray();
|
||||
var radiusPixels = points.Length == 0
|
||||
? 1.0f
|
||||
: Math.Max(1.0f, (float)points.Average(static point => Math.Max(point.RadiusPixels, 0.0)));
|
||||
var pointConfidence = points.Length == 0
|
||||
? 0.0f
|
||||
: (float)points.Average(static point => Math.Clamp(point.Confidence, 0.0, 1.0));
|
||||
var length = Math.Max(radiusPixels, (float)splineCandidate.CurveLengthPixels);
|
||||
var correspondencePenalty = splineCandidate.HasStableLedIndices ? 0.25f : 1.0f;
|
||||
return new AquariumFieldSupport(
|
||||
Center: new Vector3(length * 0.5f, 0.0f, Math.Max(1, splineCandidate.CameraObservations.Count)),
|
||||
Radius: new Vector3(length * 0.5f, radiusPixels, Math.Max(1.0f, splineCandidate.CameraObservations.Count * 0.5f)),
|
||||
LocalFrame: Matrix4x4.Identity,
|
||||
ConservativeRadius: Math.Max(radiusPixels, length * 0.5f),
|
||||
ProjectedError: correspondencePenalty * (1.0f - pointConfidence),
|
||||
Curvature: points.Length >= 3 ? 1.0f / Math.Max(1.0f, length) : 0.0f,
|
||||
TemporalUncertainty: splineCandidate.HasTemporalCode ? 0.0f : 1.0f / 187.0f);
|
||||
}
|
||||
|
||||
private AquariumFieldSupport SupportForStereoDepthCandidate(MimirStereoDepthFieldCandidate depthCandidate)
|
||||
{
|
||||
var width = Math.Max(1.0f, depthCandidate.Width);
|
||||
|
|
@ -1214,6 +1318,9 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
private static string DomainKeyForVisualMarkerCandidate(MimirVisualMarkerFieldCandidate candidate) =>
|
||||
$"mimir:visual-marker:{candidate.CalibrationId}:{candidate.MarkerId}:{candidate.CandidateKey}";
|
||||
|
||||
private static string DomainKeyForLedSplineCandidate(MimirLedSplineFieldCandidate candidate) =>
|
||||
$"mimir:led-spline:{candidate.CalibrationId}:{candidate.SplineId}:{candidate.CandidateKey}";
|
||||
|
||||
private static string DomainKeyForStereoDepthCandidate(MimirStereoDepthFieldCandidate candidate) =>
|
||||
DomainKeyForStereoDepthCandidate(candidate.CalibrationId, candidate.CameraPairId, candidate.CandidateKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public enum MimirVisualFusionModel
|
|||
TimestampedFramesOnly,
|
||||
SparseFeatureTracks,
|
||||
StereoSgmDepth,
|
||||
LedSplineCalibration,
|
||||
VisualConstrainedAudioField,
|
||||
TemporalGaussianClaims,
|
||||
FullHybridEvidenceField
|
||||
|
|
@ -68,6 +69,15 @@ public static class MimirVisualFusionConfigurations
|
|||
PublishesSpout: false,
|
||||
UsesAudioConstraints: false);
|
||||
|
||||
public static MimirVisualFusionConfiguration LedSplineCalibration { get; } = new(
|
||||
"led-spline-calibration",
|
||||
"Ordered bright LED curve observations become calibration evidence; global residual solving owns camera-pose updates.",
|
||||
MimirVisualFusionModel.LedSplineCalibration,
|
||||
CreateDefaultSensors(),
|
||||
RequiresFensalirD3D12: true,
|
||||
PublishesSpout: false,
|
||||
UsesAudioConstraints: false);
|
||||
|
||||
public static MimirVisualFusionConfiguration AudioConstrainedField { get; } = new(
|
||||
"audio-constrained-field",
|
||||
"Visual feature tracks constrain acoustic source hypotheses before Fensalir stabilizes field claims.",
|
||||
|
|
@ -91,6 +101,7 @@ public static class MimirVisualFusionConfigurations
|
|||
CadenceProof,
|
||||
TrackingFusion,
|
||||
StereoSgmDepth,
|
||||
LedSplineCalibration,
|
||||
AudioConstrainedField,
|
||||
FullHybridEvidence
|
||||
];
|
||||
|
|
|
|||
|
|
@ -102,6 +102,16 @@ invariants:
|
|||
Calibrated projection constants, full SGM, temporal/spatial reservoir reuse
|
||||
in a compilable shader, and global residual/calibration ownership remain
|
||||
open.
|
||||
- LED strips on performers are active visual calibration evidence, not fake
|
||||
depth. `MimirLedSplineFieldCandidate` carries per-camera ordered bright
|
||||
curve observations with optional temporal code / stable LED indices, and
|
||||
`MimirFensalirFieldLowering.BuildLedSplineCandidateFrame` lowers them as
|
||||
deterministic camera-sensor Feature claims that Fensalir plans as
|
||||
`DebugOverlay` calibration evidence. Exact cross-camera correspondence
|
||||
requires addressable/blink-coded LEDs or another identity source; uncoded
|
||||
identical LEDs remain useful curve constraints but cannot own camera pose.
|
||||
The future global residual/calibration owner consumes these claims and is
|
||||
the only writer of camera intrinsics/extrinsics.
|
||||
- Fensalir packet payload handles are not authority. Live payload references
|
||||
must resolve through declared typed GPU/native resources with shape,
|
||||
residency, shader access, validity, version, and handle metadata before
|
||||
|
|
|
|||
Loading…
Reference in a new issue