Solve camera frustums from calibration markers
This commit is contained in:
parent
04037ec7d9
commit
ccae91b4b0
10 changed files with 915 additions and 240 deletions
|
|
@ -490,8 +490,21 @@ a named invariant that the native runtime cannot protect yet.
|
|||
typed `mimir.move_controller_observation_state`,
|
||||
`mimir.camera_feature_track_state`, and `mimir.visual_marker_state` rather
|
||||
than becoming a raw-media or camera-placement authority.
|
||||
Eve now follows the same rule for its own device body:
|
||||
`MimirDistributedWitnessConfigurations.EveLocalSensors` and the
|
||||
`eve-local-sensors` Perfect Machine profile make Eve responsible for local
|
||||
camera/mic chirp and flash solves, then shipping compact acoustic path,
|
||||
feature-track, visual-marker, and local-frustum-hint state to Starfire.
|
||||
Starfire still owns global camera placement and the canonical clock.
|
||||
`MimirCameraFrustumCalibrationSolver` is the first global frustum solve: it
|
||||
consumes stable LED/marker correspondences, scene-space marker points, and
|
||||
seed frustums, then emits per-source position, rotation, horizontal/vertical
|
||||
tangent half-FOV, correspondence count, clipspace reprojection residual, and
|
||||
confidence. Synthetic smoke `--frustum-calibration-smoke` solves both Eyes,
|
||||
Kiyo Pro, Leap stereo IR, and Eve camera, establishing the first fusion-ready
|
||||
frustum state before dense surface fusion.
|
||||
Next useful cut is direct report decoding plus optical sphere observations
|
||||
from PS3 Eyes/Kiyos entering the same calibration-evidence path as LED
|
||||
from PS3 Eyes/Kiyos/Eve entering the same calibration-evidence path as LED
|
||||
spline constraints.
|
||||
PS3 Eyes now have the first sparse tracking surface:
|
||||
`MimirSparseFeatureTracker` detects grid-suppressed Bayer/luma corner
|
||||
|
|
|
|||
|
|
@ -43,14 +43,13 @@ Get-Content .\state\evidence.jsonl -Tail 8
|
|||
- `native/reservoir` owns the lower shared-edge typed-handle invariant for
|
||||
Fensalir/Faust binding work.
|
||||
- Fensalir owns production GPU fusion, UI, and Spout2 publication.
|
||||
- `MimirSceneEditorState` owns the current Mimir-window editor graph, not the
|
||||
OBS program output: editor camera, source/text/model nodes, visibility,
|
||||
transforms, reset controls, and grab/rotate/resize gizmo intent. The
|
||||
`Mimir Editor` panel and derived spline/handle geometry are live now; world
|
||||
SDF text glyphs, ASSIMP-style mesh import/upload, and clickable gizmo
|
||||
hit-testing are still Fensalir renderer cuts. See
|
||||
[[docs/scene-editor-control-surface|Mimir Scene Editor Control Surface]] and
|
||||
smoke with `--scene-editor-smoke`.
|
||||
- `MimirSceneEditorState` is currently a 2D OBS-shaped program mixer owner, not
|
||||
a camera/3D scene editor. Synced video buffers become program layers with
|
||||
normalized X/Y/W/H/rotation placement; the Eve/CultUI surface is Source list
|
||||
left, maximized Program Preview center, compact Audio Mixer below, and Layer
|
||||
Inspector right. Camera/SDF/model editor affordances have no live UI
|
||||
authority and editor camera/SDF/spline output no longer contributes to the
|
||||
runtime frame. Smoke with `--scene-editor-smoke`.
|
||||
- Live camera image buffers should use Fensalir-owned texture leases when they
|
||||
are rendering inputs: Mimir asks the engine broker for a keyed D3D12
|
||||
Texture2D/fence lease, writes decoded frames into that texture, commits the
|
||||
|
|
|
|||
|
|
@ -155,6 +155,11 @@ if (args.Any(arg => string.Equals(arg, "--room-calibration-lock-smoke", StringCo
|
|||
return RunRoomCalibrationLockSmoke();
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--frustum-calibration-smoke", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return RunFrustumCalibrationSmoke();
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--led-spline-quality-sweep-smoke", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return RunLedSplineQualitySweepSmoke();
|
||||
|
|
@ -1055,6 +1060,87 @@ static int RunRoomCalibrationLockSmoke()
|
|||
: 1;
|
||||
}
|
||||
|
||||
static int RunFrustumCalibrationSmoke()
|
||||
{
|
||||
var scenePoints = new[]
|
||||
{
|
||||
new MimirLedSplineScenePoint(0, new Vector3(-0.30f, 0.34f, 2.18f), 0.95),
|
||||
new MimirLedSplineScenePoint(1, new Vector3(-0.19f, 0.22f, 2.02f), 0.96),
|
||||
new MimirLedSplineScenePoint(2, new Vector3(-0.08f, 0.09f, 1.91f), 0.97),
|
||||
new MimirLedSplineScenePoint(3, new Vector3(0.06f, -0.03f, 1.84f), 0.98),
|
||||
new MimirLedSplineScenePoint(4, new Vector3(0.19f, -0.13f, 1.88f), 0.97),
|
||||
new MimirLedSplineScenePoint(5, new Vector3(0.31f, -0.23f, 1.98f), 0.95),
|
||||
new MimirLedSplineScenePoint(6, new Vector3(0.22f, -0.31f, 2.18f), 0.94),
|
||||
new MimirLedSplineScenePoint(7, new Vector3(0.02f, -0.37f, 2.36f), 0.93),
|
||||
};
|
||||
var truth = new[]
|
||||
{
|
||||
new MimirCameraFrustumEstimate("ps3-eye-0", Vector3.Zero, Quaternion.Identity, 0.96, 0.72, 1.0),
|
||||
new MimirCameraFrustumEstimate("ps3-eye-1", new Vector3(-0.22f, 0.04f, 0.03f), Quaternion.CreateFromYawPitchRoll(0.045f, -0.012f, 0.006f), 0.98, 0.73, 1.0),
|
||||
new MimirCameraFrustumEstimate("kiyo-pro-rgb", new Vector3(0.26f, 0.03f, -0.06f), Quaternion.CreateFromYawPitchRoll(-0.040f, 0.010f, -0.004f), 0.78, 0.48, 1.0),
|
||||
new MimirCameraFrustumEstimate("leap-stereo-ir", new Vector3(0.04f, -0.13f, 0.10f), Quaternion.CreateFromYawPitchRoll(0.010f, 0.060f, 0.0f), 0.82, 0.38, 1.0),
|
||||
new MimirCameraFrustumEstimate("eve-camera", new Vector3(-0.34f, 0.16f, 0.20f), Quaternion.CreateFromYawPitchRoll(0.080f, -0.030f, 0.018f), 0.90, 0.68, 1.0),
|
||||
};
|
||||
var sizes = new Dictionary<string, (int Width, int Height)>(StringComparer.Ordinal)
|
||||
{
|
||||
["ps3-eye-0"] = (320, 240),
|
||||
["ps3-eye-1"] = (320, 240),
|
||||
["kiyo-pro-rgb"] = (1920, 1080),
|
||||
["leap-stereo-ir"] = (640, 240),
|
||||
["eve-camera"] = (1280, 720),
|
||||
};
|
||||
var curveSolver = new MimirLedSplineCurveSolver();
|
||||
var observations = truth.Select((frustum, index) =>
|
||||
{
|
||||
var size = sizes[frustum.SourceId];
|
||||
var fit = curveSolver.SolveCameraCurve(
|
||||
frustum.SourceId,
|
||||
$"{frustum.SourceId}:led-spline:frustum",
|
||||
size.Width,
|
||||
size.Height,
|
||||
3_000_000_000L + index,
|
||||
ProjectFrustumLedDetections(scenePoints, frustum, size.Width, size.Height, radiusPixels: index < 2 ? 2.2 : 4.0));
|
||||
return curveSolver.ToCameraObservation(fit, size.Width, size.Height, 3_000_000_000L + index);
|
||||
}).ToArray();
|
||||
var candidate = new MimirLedSplineFieldCandidate(
|
||||
CandidateKey: "frustum-solve:led-string:frame-1",
|
||||
CalibrationId: "room-frustum-calibration",
|
||||
SplineId: "co-streamer-led-string",
|
||||
ProducerKey: "mimir-led-spline-detector",
|
||||
CameraObservations: observations,
|
||||
EstimatedLedCount: scenePoints.Length,
|
||||
HasTemporalCode: true,
|
||||
HasStableLedIndices: true,
|
||||
CurveLengthPixels: observations.Max(static observation => observation.Points.Count == 0 ? 0.0 : observation.Points.Count),
|
||||
Confidence: 0.93,
|
||||
ObservedTimeNs: 3_000_000_004L);
|
||||
var seeds = truth.Select(frustum => frustum with
|
||||
{
|
||||
PositionMeters = frustum.PositionMeters + new Vector3(0.035f, -0.020f, 0.018f),
|
||||
CameraToWorldRotation = Quaternion.Normalize(Quaternion.CreateFromYawPitchRoll(0.018f, -0.014f, 0.008f) * frustum.CameraToWorldRotation),
|
||||
HorizontalTanHalfFov = frustum.HorizontalTanHalfFov * 1.08,
|
||||
VerticalTanHalfFov = frustum.VerticalTanHalfFov * 0.92,
|
||||
Confidence = 0.82,
|
||||
}).ToArray();
|
||||
var frame = new MimirCameraFrustumCalibrationSolver().FitFrustumsFromLedSpline(
|
||||
candidate,
|
||||
scenePoints,
|
||||
seeds,
|
||||
maximumDeltaMeters: 0.20,
|
||||
maximumRotationDeltaDegrees: 12.0);
|
||||
|
||||
Console.WriteLine(
|
||||
$"frustum-calibration-smoke updates={frame.FrustumUpdates.Count} confidence={frame.Confidence:0.000} meanClipError={frame.MeanReprojectionErrorClip:0.000000} sources={string.Join(",", frame.FrustumUpdates.Select(static update => $"{update.SourceId}:{update.UsedPointCount}/{update.RotationDeltaDegrees:0.00}deg/{update.HorizontalTanHalfFov:0.000}x{update.VerticalTanHalfFov:0.000}"))}");
|
||||
|
||||
return frame.HasFrustumUpdate &&
|
||||
frame.FrustumUpdates.Count == truth.Length &&
|
||||
frame.FrustumUpdates.All(update => update.UsedPointCount == scenePoints.Length) &&
|
||||
frame.FrustumUpdates.All(static update => update.MeanReprojectionErrorClip < 0.010) &&
|
||||
frame.Confidence >= 0.70
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
||||
static int RunLedSplineQualitySweepSmoke()
|
||||
{
|
||||
var scenePoints = new[]
|
||||
|
|
@ -1821,6 +1907,34 @@ static IReadOnlyList<MimirLedPixelDetection> ProjectLedDetections(
|
|||
return output;
|
||||
}
|
||||
|
||||
static IReadOnlyList<MimirLedPixelDetection> ProjectFrustumLedDetections(
|
||||
IReadOnlyList<MimirLedSplineScenePoint> scenePoints,
|
||||
MimirCameraFrustumEstimate frustum,
|
||||
int width,
|
||||
int height,
|
||||
double radiusPixels)
|
||||
{
|
||||
var output = new MimirLedPixelDetection[scenePoints.Count];
|
||||
var worldToCamera = Quaternion.Inverse(frustum.CameraToWorldRotation);
|
||||
for (var index = 0; index < scenePoints.Count; index++)
|
||||
{
|
||||
var cameraSpace = Vector3.Transform(scenePoints[index].PositionMeters - frustum.PositionMeters, worldToCamera);
|
||||
var z = Math.Max(1.0e-6f, cameraSpace.Z);
|
||||
var clipX = cameraSpace.X / (z * (float)Math.Max(1.0e-6, frustum.HorizontalTanHalfFov));
|
||||
var clipY = cameraSpace.Y / (z * (float)Math.Max(1.0e-6, frustum.VerticalTanHalfFov));
|
||||
var imageX = (clipX + 1.0f) * 0.5f * width;
|
||||
var imageY = (1.0f - clipY) * 0.5f * height;
|
||||
output[index] = new MimirLedPixelDetection(
|
||||
scenePoints[index].LedIndex,
|
||||
imageX,
|
||||
imageY,
|
||||
radiusPixels,
|
||||
scenePoints[index].Confidence);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static IReadOnlyList<MimirLedPixelDetection> SyntheticSweepDetections(
|
||||
string settingId,
|
||||
IReadOnlyList<MimirLedSplineScenePoint> scenePoints,
|
||||
|
|
@ -3217,30 +3331,31 @@ static int RunSceneEditorSmoke()
|
|||
input.SetMousePosition(new Vector2(130.0f, 82.0f));
|
||||
editor.UpdateInput(0.016f, input);
|
||||
|
||||
editor.PendingText = "Signal";
|
||||
editor.AddSdfTextPanel();
|
||||
editor.PendingModelPath = "assets/models/raven-stage.glb";
|
||||
editor.ImportModelPlaceholder();
|
||||
editor.SetSelectedProgramX(0.62f);
|
||||
editor.SetSelectedProgramY(0.45f);
|
||||
editor.SetSelectedProgramWidth(0.36f);
|
||||
editor.SetSelectedProgramHeight(0.28f);
|
||||
editor.CenterSelectedProgramLayer();
|
||||
editor.MoveSelectedLayer(-1);
|
||||
|
||||
var hierarchy = editor.DescribeHierarchy();
|
||||
var splineFrame = editor.BuildEditorSplineFrame();
|
||||
var handles = editor.BuildEditorSdfObjects();
|
||||
var previewItems = editor.PreviewItems;
|
||||
var placement = editor.PlacementForSource("raven-display");
|
||||
var hasDisplay = hierarchy.Contains("raven-display", StringComparison.Ordinal);
|
||||
var hasText = editor.Nodes.Any(node => node.Kind == MimirSceneEditorNodeKind.SdfTextPanel && string.Equals(node.Text, "Signal", StringComparison.Ordinal));
|
||||
var hasModel = editor.Nodes.Any(node => node.Kind == MimirSceneEditorNodeKind.Model && string.Equals(node.ModelPath, "assets/models/raven-stage.glb", StringComparison.Ordinal));
|
||||
var reset = Math.Abs(displayNode.Transform.Position.X - displayNode.DefaultTransform.Position.X) > 0.001f;
|
||||
var hasCameraPreview = previewItems.Any(item => string.Equals(item.Id, "editor-camera", StringComparison.Ordinal));
|
||||
var hasOnlyVideoPreview = previewItems.Count == 2 && previewItems.All(item => item.Id.StartsWith("feed:", StringComparison.Ordinal));
|
||||
var programCentered = placement is { CenterX: 0.5f, CenterY: 0.5f };
|
||||
|
||||
Console.WriteLine(
|
||||
$"scene-editor-smoke nodes={editor.Nodes.Count} feeds={editor.Nodes.Count(node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel)} " +
|
||||
$"splines={splineFrame.Splines.Count} handles={handles.Count} selected={editor.SelectedNode?.DisplayName} hasDisplay={hasDisplay} hasText={hasText} hasModel={hasModel} movedAfterReset={reset}");
|
||||
$"preview={previewItems.Count} selected={editor.SelectedNode?.DisplayName} hasDisplay={hasDisplay} cameraPreview={hasCameraPreview} " +
|
||||
$"placement={placement?.CenterX:0.000},{placement?.CenterY:0.000} programCentered={programCentered}");
|
||||
|
||||
return editor.Nodes.Count >= 5 &&
|
||||
return editor.Nodes.Count == 3 &&
|
||||
hasDisplay &&
|
||||
hasText &&
|
||||
hasModel &&
|
||||
reset &&
|
||||
splineFrame.HasInput &&
|
||||
handles.Count == 4
|
||||
hasOnlyVideoPreview &&
|
||||
!hasCameraPreview &&
|
||||
programCentered
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
|
@ -3980,7 +4095,9 @@ static int RunPerfectMachineProfileSmoke()
|
|||
stereoDepthPlan.DeferredRequests.Count == 0 &&
|
||||
stereoDepthProfiles.Any(profile => profile.Id == MimirStereoDepthConfigurations.D3D12SgmLibSgmProvenance.Id && !profile.LiveDependency) &&
|
||||
profiles.Any(profile => profile.Id == MimirPerfectMachineProfiles.NightwingEyesMoves.Id && profile.EmitsWitness && !profile.OwnsCanonicalClock && !profile.PublishesObsProgram) &&
|
||||
profiles.Any(profile => profile.Id == MimirPerfectMachineProfiles.EveLocalSensors.Id && profile.EmitsWitness && !profile.OwnsCanonicalClock && !profile.PublishesObsProgram) &&
|
||||
distributedWitnesses.Any(profile => profile.Id == MimirDistributedWitnessConfigurations.NightwingEyesMoves.Id && !profile.MayStreamRawMedia && !profile.MayOwnCanonicalClock) &&
|
||||
distributedWitnesses.Any(profile => profile.Id == MimirDistributedWitnessConfigurations.EveLocalSensors.Id && !profile.MayStreamRawMedia && !profile.MayOwnCanonicalClock) &&
|
||||
localization is { Score: > 0.90 } &&
|
||||
authority.Decision == MimirAuthorityDecision.TrustedEvidence &&
|
||||
transport.Transport?.Id == MimirNetworkTransportConfigurations.CultMeshTimingState.Id &&
|
||||
|
|
|
|||
|
|
@ -184,15 +184,6 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
{
|
||||
var channelCount = Math.Max(1, lastAudioSpectra.Count);
|
||||
var fieldEvidenceFrame = BuildFieldEvidenceFrame();
|
||||
var editorSplineFrame = sceneEditor.Enabled
|
||||
? sceneEditor.BuildEditorSplineFrame()
|
||||
: AquariumSplineFrame.Empty;
|
||||
var editorSdfObjects = sceneEditor.Enabled
|
||||
? sceneEditor.BuildEditorSdfObjects()
|
||||
: [];
|
||||
var editorSdfLights = sceneEditor.Enabled
|
||||
? sceneEditor.BuildEditorSdfLights()
|
||||
: [];
|
||||
var windowCount = Math.Max(1, spectrumHistory.Count);
|
||||
var (splineMin, splineMax) = syntheticSingleTubePreview
|
||||
? (new Vector3(-5.76643f, -1.0f, 0.0f), new Vector3(5.76643f, 1.0f, 0.0f))
|
||||
|
|
@ -209,15 +200,9 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
var spectrumCameraFrustum = syntheticSingleTubePreview
|
||||
? new AquariumCameraFrustum(-0.036f, 0.036f, -0.02025f, 0.02025f, 0.1f, 100.0f)
|
||||
: FitSpectrumCameraFrustum(splineMin, splineMax, spectrumCameraPosition, spectrumCameraTarget);
|
||||
var cameraTarget = sceneEditor.Enabled
|
||||
? sceneEditor.CameraTarget
|
||||
: spectrumCameraTarget;
|
||||
var cameraPosition = sceneEditor.Enabled
|
||||
? sceneEditor.CameraPosition
|
||||
: spectrumCameraPosition;
|
||||
var cameraFrustum = sceneEditor.Enabled
|
||||
? sceneEditor.CameraFrustum
|
||||
: spectrumCameraFrustum;
|
||||
var cameraTarget = spectrumCameraTarget;
|
||||
var cameraPosition = spectrumCameraPosition;
|
||||
var cameraFrustum = spectrumCameraFrustum;
|
||||
lastSpectrumFrustum = spectrumCameraFrustum;
|
||||
lastSpectrumCameraPosition = spectrumCameraPosition;
|
||||
lastSpectrumCameraTarget = spectrumCameraTarget;
|
||||
|
|
@ -235,13 +220,13 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
UseStarfieldBackground = obsProofVisualEnabled,
|
||||
SdfObjects = MergeSdfObjects(
|
||||
obsProofVisualEnabled ? BuildObsProofSdfObjects(runtimeSeconds) : [],
|
||||
editorSdfObjects),
|
||||
[]),
|
||||
SdfLights = MergeSdfLights(
|
||||
obsProofVisualEnabled ? BuildObsProofSdfLights(runtimeSeconds) : [],
|
||||
editorSdfLights),
|
||||
[]),
|
||||
FieldEvidenceFrame = fieldEvidenceFrame,
|
||||
BufferFieldFrame = AquariumBufferFieldFrame.Empty,
|
||||
SplineFrame = editorSplineFrame,
|
||||
SplineFrame = AquariumSplineFrame.Empty,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -873,82 +858,43 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
{
|
||||
surface.Horizontal("mimir.editor.shell", shell =>
|
||||
{
|
||||
shell.Pane("mimir.scene-graph", "Scene Graph", graph =>
|
||||
shell.Pane("mimir.video-sources", "Video Sources", graph =>
|
||||
{
|
||||
graph.Toggle("scene.editor-view", "Editor View", () => sceneEditor.Enabled, value => sceneEditor.Enabled = value);
|
||||
graph.Card("scene.tree", tree =>
|
||||
graph.Options("video.source-select", "Feed", () => presentationControls.SelectedVideoIndex, SelectVideoLayer, VideoFeedOptions());
|
||||
graph.Text("video.program-summary", DescribeProgramVideo, "caption", weight: 0.75f);
|
||||
graph.Text("video.layer-list", sceneEditor.DescribeHierarchy, "mono", weight: 3.8f);
|
||||
graph.Row("video.source-state", state =>
|
||||
{
|
||||
tree.Text("scene.root", "Scene", "strong");
|
||||
tree.Text("scene.camera", () => $"{(sceneEditor.SelectedNodeId == "editor-camera" ? "> " : " ")}Editor Camera <Camera>", "mono");
|
||||
tree.Text("scene.feeds", () => $"{(sceneEditor.IsExpanded("feeds") ? "- " : "+ ")}Sensor Feeds (4)", "mono");
|
||||
tree.Text("scene.feed-kiyo", " [eye] Kiyo Pro RGB context <SensorFeed>", "mono");
|
||||
tree.Text("scene.feed-eve", " [eye] Eve image/mic pipe <SensorFeed>", "mono");
|
||||
tree.Text("scene.text", () => $"{(sceneEditor.IsExpanded("text") ? "- " : "+ ")}SDF Text", "mono");
|
||||
tree.Text("scene.models", () => $"{(sceneEditor.IsExpanded("models") ? "- " : "+ ")}Models", "mono");
|
||||
}, weight: 1.6f);
|
||||
graph.Text("scene.hierarchy", sceneEditor.DescribeHierarchy, "mono", weight: 2.8f);
|
||||
graph.Row("scene.nav", nav =>
|
||||
{
|
||||
nav.Button("scene.previous", "Previous", sceneEditor.SelectPrevious);
|
||||
nav.Button("scene.next", "Next", sceneEditor.SelectNext);
|
||||
state.Toggle("video.visible", "Visible", () => sceneEditor.SelectedNode?.Visible ?? false, SetSelectedVideoVisible);
|
||||
state.Toggle("video.solo", "Solo", () => presentationControls.SelectedVideo?.Solo ?? false, SetSelectedVideoSolo);
|
||||
});
|
||||
graph.Text("scene.selected", sceneEditor.DescribeSelection, "caption", weight: 1.2f);
|
||||
graph.Slider("video.opacity", "Opacity", () => presentationControls.SelectedVideo?.Opacity ?? 1.0f, SetSelectedVideoOpacity, 0.0f, 1.0f, "0.00");
|
||||
graph.Row("video.layer-fit", fit =>
|
||||
{
|
||||
fit.Button("video.center", "Center", sceneEditor.CenterSelectedProgramLayer);
|
||||
fit.Button("video.fit", "Fit", sceneEditor.FitSelectedProgramLayer);
|
||||
fit.Button("video.fill", "Fill", sceneEditor.FillSelectedProgramLayer);
|
||||
});
|
||||
graph.Row("video.layer-order", order =>
|
||||
{
|
||||
order.Button("video.layer-up", "Layer Up", () => MoveSelectedVideoLayer(-1));
|
||||
order.Button("video.layer-down", "Layer Down", () => MoveSelectedVideoLayer(1));
|
||||
});
|
||||
graph.Text("video.selected", sceneEditor.DescribeSelection, "caption", weight: 1.2f);
|
||||
}, weight: 0.85f);
|
||||
|
||||
shell.Vertical("mimir.editor-center", center =>
|
||||
{
|
||||
center.Pane("mimir.scene-view", "Scene View", scene =>
|
||||
{
|
||||
scene.Preview("scene.view-preview", "Program Preview", () => sceneEditor.PreviewItems, weight: 1.0f);
|
||||
scene.Row("scene.view-actions", actions =>
|
||||
{
|
||||
actions.Button("scene.view-frame-selected", "Frame Selected", sceneEditor.ResetCamera);
|
||||
actions.Button("scene.view-reset-camera", "Reset Camera", sceneEditor.ResetCamera);
|
||||
});
|
||||
}, weight: 1.0f);
|
||||
center.Preview("scene.view-preview", "", () => sceneEditor.PreviewItems, weight: 1.0f);
|
||||
}, weight: 2.1f);
|
||||
|
||||
center.Pane("mimir.assets", "Asset Browser", assets =>
|
||||
{
|
||||
assets.Row("assets.quick", quick =>
|
||||
{
|
||||
quick.Button("assets.add-text", "Add SDF Text", sceneEditor.AddSdfTextPanel);
|
||||
quick.Button("assets.import-model", "Import Model", sceneEditor.ImportModelPlaceholder);
|
||||
});
|
||||
assets.Text("assets.text", () => $"Text: {sceneEditor.PendingText}", "mono");
|
||||
assets.Text("assets.model", () => $"Model: {sceneEditor.PendingModelPath}", "mono");
|
||||
}, weight: 0.72f);
|
||||
}, weight: 1.75f);
|
||||
|
||||
shell.Pane("mimir.inspector", "Inspector", inspector =>
|
||||
shell.Pane("mimir.audio-inspector", "Audio Mix", inspector =>
|
||||
{
|
||||
inspector.Text("inspector.selection", sceneEditor.DescribeSelection, "strong");
|
||||
inspector.Toggle("transform.visible", "Visible", () => sceneEditor.SelectedNode?.Visible ?? false, sceneEditor.SetSelectedVisible);
|
||||
inspector.Toggle("transform.locked", "Locked", () => sceneEditor.SelectedNode?.Locked ?? false, sceneEditor.SetSelectedLocked);
|
||||
inspector.Options("transform.mode", "Mode", () => (int)sceneEditor.GizmoMode, value => sceneEditor.GizmoMode = (MimirSceneEditorGizmoMode)value, SceneEditorGizmoOptions());
|
||||
inspector.Slider("transform.x", "X", () => sceneEditor.SelectedNode?.Transform.Position.X ?? 0.0f, sceneEditor.SetSelectedX, -12.0f, 12.0f, "0.00");
|
||||
inspector.Slider("transform.y", "Y", () => sceneEditor.SelectedNode?.Transform.Position.Y ?? 0.0f, sceneEditor.SetSelectedY, -8.0f, 8.0f, "0.00");
|
||||
inspector.Slider("transform.z", "Z", () => sceneEditor.SelectedNode?.Transform.Position.Z ?? 0.0f, sceneEditor.SetSelectedZ, -8.0f, 8.0f, "0.00");
|
||||
inspector.Slider("transform.rotation", "Rotation", () => sceneEditor.SelectedNode?.Transform.RotationRadians ?? 0.0f, sceneEditor.SetSelectedRotation, -MathF.PI, MathF.PI, "0.00");
|
||||
inspector.Slider("transform.scale-x", "Scale X", () => sceneEditor.SelectedNode?.Transform.Scale.X ?? 1.0f, sceneEditor.SetSelectedScaleX, 0.05f, 8.0f, "0.00");
|
||||
inspector.Slider("transform.scale-y", "Scale Y", () => sceneEditor.SelectedNode?.Transform.Scale.Y ?? 1.0f, sceneEditor.SetSelectedScaleY, 0.05f, 8.0f, "0.00");
|
||||
inspector.Text("inspector.program-placement", "Program Frame", "strong");
|
||||
inspector.Slider("program.x", "X", () => sceneEditor.SelectedProgramX, sceneEditor.SetSelectedProgramX, 0.0f, 1.0f, "0.000");
|
||||
inspector.Slider("program.y", "Y", () => sceneEditor.SelectedProgramY, sceneEditor.SetSelectedProgramY, 0.0f, 1.0f, "0.000");
|
||||
inspector.Slider("program.w", "W", () => sceneEditor.SelectedProgramWidth, sceneEditor.SetSelectedProgramWidth, 0.01f, 1.0f, "0.000");
|
||||
inspector.Slider("program.h", "H", () => sceneEditor.SelectedProgramHeight, sceneEditor.SetSelectedProgramHeight, 0.01f, 1.0f, "0.000");
|
||||
inspector.Row("transform.reset", reset =>
|
||||
{
|
||||
reset.Button("transform.reset-node", "Reset Transform", sceneEditor.ResetSelectedTransform);
|
||||
reset.Button("transform.reset-camera", "Reset Camera", sceneEditor.ResetCamera);
|
||||
});
|
||||
inspector.Text("inspector.create-label", "Create", "strong");
|
||||
inspector.Text("create.text", () => $"Text: {sceneEditor.PendingText}", "mono");
|
||||
inspector.Text("create.model", () => $"Model: {sceneEditor.PendingModelPath}", "mono");
|
||||
inspector.Row("inspector.create-actions", actions =>
|
||||
{
|
||||
actions.Button("create.add-text", "Add SDF Text", sceneEditor.AddSdfTextPanel);
|
||||
actions.Button("create.import-model", "Import Model", sceneEditor.ImportModelPlaceholder);
|
||||
});
|
||||
inspector.Options("audio.stem", "Stem", () => presentationControls.SelectedAudioIndex, SelectAudioStem, AudioFeedOptions());
|
||||
inspector.Toggle("audio.mute", "Mute", () => presentationControls.SelectedAudio?.Muted ?? false, SetSelectedAudioMuted);
|
||||
inspector.Toggle("audio.solo", "Solo", () => presentationControls.SelectedAudio?.Solo ?? false, SetSelectedAudioSolo);
|
||||
inspector.Slider("audio.gain", "Gain", () => presentationControls.SelectedAudio?.Gain ?? 1.0f, SetSelectedAudioGain, 0.0f, 2.0f, "0.00");
|
||||
inspector.Text("audio.program", DescribeProgramAudio, "caption", weight: 1.2f);
|
||||
}, weight: 0.95f);
|
||||
});
|
||||
});
|
||||
|
|
@ -1103,6 +1049,80 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
return string.Join(" | ", synchronization.Buffers.Buffers.Select(DescribeBuffer));
|
||||
}
|
||||
|
||||
private void SelectVideoLayer(int index)
|
||||
{
|
||||
presentationControls.SelectedVideoIndex = Math.Clamp(index, 0, Math.Max(0, presentationControls.VideoFeeds.Count - 1));
|
||||
if (presentationControls.SelectedVideo is { } selected)
|
||||
{
|
||||
sceneEditor.SelectSource(selected.SourceId);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectAudioStem(int index)
|
||||
{
|
||||
presentationControls.SelectedAudioIndex = Math.Clamp(index, 0, Math.Max(0, presentationControls.AudioFeeds.Count - 1));
|
||||
}
|
||||
|
||||
private void SetSelectedVideoVisible(bool visible)
|
||||
{
|
||||
sceneEditor.SetSelectedVisible(visible);
|
||||
if (presentationControls.SelectedVideo is { } selected)
|
||||
{
|
||||
selected.Enabled = visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelectedVideoSolo(bool solo)
|
||||
{
|
||||
if (presentationControls.SelectedVideo is { } selected)
|
||||
{
|
||||
selected.Solo = solo;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelectedVideoOpacity(float opacity)
|
||||
{
|
||||
if (presentationControls.SelectedVideo is { } selected)
|
||||
{
|
||||
selected.Opacity = Math.Clamp(opacity, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveSelectedVideoLayer(int delta)
|
||||
{
|
||||
if (presentationControls.SelectedVideo is { } selected)
|
||||
{
|
||||
presentationControls.MoveSelectedVideo(delta);
|
||||
sceneEditor.SelectSource(selected.SourceId);
|
||||
}
|
||||
|
||||
sceneEditor.MoveSelectedLayer(delta);
|
||||
}
|
||||
|
||||
private void SetSelectedAudioMuted(bool muted)
|
||||
{
|
||||
if (presentationControls.SelectedAudio is { } selected)
|
||||
{
|
||||
selected.Muted = muted;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelectedAudioSolo(bool solo)
|
||||
{
|
||||
if (presentationControls.SelectedAudio is { } selected)
|
||||
{
|
||||
selected.Solo = solo;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelectedAudioGain(float gain)
|
||||
{
|
||||
if (presentationControls.SelectedAudio is { } selected)
|
||||
{
|
||||
selected.Gain = Math.Clamp(gain, 0.0f, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<AquariumUiOption> VideoFeedOptions()
|
||||
{
|
||||
var feeds = presentationControls.VideoFeeds;
|
||||
|
|
@ -1124,13 +1144,6 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
.Select((preset, index) => new AquariumUiOption(index, preset.DisplayName))
|
||||
.ToArray();
|
||||
|
||||
private static IReadOnlyList<AquariumUiOption> SceneEditorGizmoOptions() =>
|
||||
[
|
||||
new AquariumUiOption((int)MimirSceneEditorGizmoMode.Translate, "Grab"),
|
||||
new AquariumUiOption((int)MimirSceneEditorGizmoMode.Rotate, "Rotate"),
|
||||
new AquariumUiOption((int)MimirSceneEditorGizmoMode.Scale, "Resize"),
|
||||
];
|
||||
|
||||
private string DescribeProgramVideo()
|
||||
{
|
||||
var feeds = presentationControls.VideoFeeds;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ public enum MimirDistributedWitnessKind
|
|||
MicrocontrollerListener,
|
||||
RemoteCameraRig,
|
||||
BrowserDiagnostics,
|
||||
NightwingEyesMoves
|
||||
NightwingEyesMoves,
|
||||
EveLocalSensors
|
||||
}
|
||||
|
||||
public sealed record MimirDistributedWitnessConfiguration(
|
||||
|
|
@ -97,12 +98,38 @@ public static class MimirDistributedWitnessConfigurations
|
|||
ExpectedNetworkLatencyMilliseconds: 2.0,
|
||||
"Nightwing reads the local Eyes and Moves, preserves device timestamps, and ships compact track/marker observations. Starfire/Fensalir own global pose, residuals, surface claims, and program pixels.");
|
||||
|
||||
public static MimirDistributedWitnessConfiguration EveLocalSensors { get; } = new(
|
||||
"eve-local-sensor-witness",
|
||||
"Eve device witness: owns its camera, microphone, flash/chirp decode, and local marker observations.",
|
||||
MimirDistributedWitnessKind.EveLocalSensors,
|
||||
"eve-local-sensors",
|
||||
Inputs: ["eve-camera", "eve-mic", "eve-display-flash-schedule", "eve-speaker-chirp-schedule"],
|
||||
RequiredStateDocuments:
|
||||
[
|
||||
"mimir.bioacoustic_codebook_state",
|
||||
"mimir.bioacoustic_decoder_state",
|
||||
"mimir.visual_calibration_state",
|
||||
"mimir.camera_rig_calibration_state"
|
||||
],
|
||||
EmittedStateDocuments:
|
||||
[
|
||||
"mimir.acoustic_path_state",
|
||||
"mimir.camera_feature_track_state",
|
||||
"mimir.visual_marker_state",
|
||||
"mimir.local_frustum_hint_state"
|
||||
],
|
||||
MayStreamRawMedia: false,
|
||||
MayOwnCanonicalClock: false,
|
||||
ExpectedNetworkLatencyMilliseconds: 12.0,
|
||||
"Eve runs the same witness pattern as Nightwing for its own sensors: decode chirps locally, detect flashes/markers locally, and send typed timing/frustum hints to Starfire. Starfire owns global camera placement.");
|
||||
|
||||
public static IReadOnlyList<MimirDistributedWitnessConfiguration> BuiltIn { get; } =
|
||||
[
|
||||
Raven,
|
||||
Phone,
|
||||
Microcontroller,
|
||||
RemoteCameraRig,
|
||||
NightwingEyesMoves
|
||||
NightwingEyesMoves,
|
||||
EveLocalSensors
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ public enum MimirPerfectMachineNodeRole
|
|||
PhoneWitness,
|
||||
MicrocontrollerWitness,
|
||||
NightwingEyesMoves,
|
||||
EveLocalSensors,
|
||||
CalibrationBench,
|
||||
ObsProgramHost
|
||||
}
|
||||
|
|
@ -140,6 +141,28 @@ public static class MimirPerfectMachineProfiles
|
|||
"mimir.visual_calibration_state.v1"
|
||||
]);
|
||||
|
||||
public static MimirPerfectMachineProfile EveLocalSensors { get; } = new(
|
||||
"eve-local-sensors",
|
||||
"Mobile Eve witness: decodes its own camera/mic flashes and chirps locally, then emits compact timing, feature, marker, and local frustum hints.",
|
||||
MimirPerfectMachineNodeRole.EveLocalSensors,
|
||||
MimirBioacousticDecoderConfiguration.CompactFastIndex,
|
||||
MimirAlignmentActuatorProfile.SixSourceFaust,
|
||||
MimirAudioFieldModel.AlignedStems,
|
||||
[MimirComputeBackend.ManagedScalar, MimirComputeBackend.RemoteCultMeshWorker],
|
||||
EmitsWitness: true,
|
||||
OwnsCanonicalClock: false,
|
||||
PublishesObsProgram: false,
|
||||
RollingWindow: TimeSpan.FromSeconds(3),
|
||||
RequiredCultMeshDocuments:
|
||||
[
|
||||
"mimir.bioacoustic_codebook_state.v1",
|
||||
"mimir.bioacoustic_decoder_state.v1",
|
||||
"mimir.acoustic_path_state.v1",
|
||||
"mimir.camera_feature_track_state.v1",
|
||||
"mimir.visual_marker_state.v1",
|
||||
"mimir.local_frustum_hint_state.v1"
|
||||
]);
|
||||
|
||||
public static MimirPerfectMachineProfile CalibrationBench { get; } = new(
|
||||
"calibration-bench",
|
||||
"Offline or live calibration worker: explores decoder/codebook/path variants and preserves receipts.",
|
||||
|
|
@ -184,6 +207,7 @@ public static class MimirPerfectMachineProfiles
|
|||
PhoneWitness,
|
||||
MicrocontrollerWitness,
|
||||
NightwingEyesMoves,
|
||||
EveLocalSensors,
|
||||
CalibrationBench,
|
||||
ObsProgramHost
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,16 +11,6 @@ public sealed class MimirSceneEditorState
|
|||
private const float ProgramWorldWidth = 12.8f;
|
||||
private const float ProgramWorldHeight = 7.2f;
|
||||
private readonly List<MimirSceneEditorNode> nodes = [];
|
||||
private readonly Dictionary<string, bool> expandedGroups = new(StringComparer.Ordinal)
|
||||
{
|
||||
["scene"] = true,
|
||||
["feeds"] = true,
|
||||
["text"] = true,
|
||||
["models"] = true,
|
||||
};
|
||||
|
||||
private string pendingModelPath = "assets/models/example.glb";
|
||||
private string pendingText = "Mimir";
|
||||
private Vector2? previousMousePosition;
|
||||
|
||||
public MimirSceneEditorState()
|
||||
|
|
@ -31,16 +21,7 @@ public sealed class MimirSceneEditorState
|
|||
"Editor Camera",
|
||||
MimirSceneEditorNodeKind.Camera,
|
||||
new MimirSceneEditorTransform(new Vector3(0.0f, 0.0f, -18.0f), 0.0f, Vector2.One)));
|
||||
nodes.Add(new MimirSceneEditorNode(
|
||||
"text-title",
|
||||
"",
|
||||
"SDF Text Panel",
|
||||
MimirSceneEditorNodeKind.SdfTextPanel,
|
||||
new MimirSceneEditorTransform(new Vector3(-3.2f, 2.1f, 0.0f), 0.0f, new Vector2(2.4f, 0.8f)))
|
||||
{
|
||||
Text = pendingText,
|
||||
});
|
||||
SelectedNodeId = "text-title";
|
||||
SelectedNodeId = "editor-camera";
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
|
@ -49,18 +30,6 @@ public sealed class MimirSceneEditorState
|
|||
|
||||
public string SelectedNodeId { get; private set; }
|
||||
|
||||
public string PendingModelPath
|
||||
{
|
||||
get => pendingModelPath;
|
||||
set => pendingModelPath = value.Trim();
|
||||
}
|
||||
|
||||
public string PendingText
|
||||
{
|
||||
get => pendingText;
|
||||
set => pendingText = value;
|
||||
}
|
||||
|
||||
public IReadOnlyList<MimirSceneEditorNode> Nodes => nodes;
|
||||
|
||||
public MimirSceneEditorNode? SelectedNode =>
|
||||
|
|
@ -71,7 +40,7 @@ public sealed class MimirSceneEditorState
|
|||
|
||||
public IReadOnlyList<AquariumUiPreviewItem> PreviewItems =>
|
||||
nodes
|
||||
.Where(static node => node.Visible && node.Kind != MimirSceneEditorNodeKind.Camera)
|
||||
.Where(static node => node.Visible && node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel)
|
||||
.OrderBy(static node => node.Layer)
|
||||
.Select(node =>
|
||||
{
|
||||
|
|
@ -84,7 +53,7 @@ public sealed class MimirSceneEditorState
|
|||
placement.Width,
|
||||
placement.Height,
|
||||
string.Equals(node.Id, SelectedNodeId, StringComparison.Ordinal),
|
||||
node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel ? "cool" : node.Kind == MimirSceneEditorNodeKind.SdfTextPanel ? "warm" : "neutral");
|
||||
"cool");
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -128,6 +97,12 @@ public sealed class MimirSceneEditorState
|
|||
SourceId = buffer.Descriptor.SourceId,
|
||||
});
|
||||
}
|
||||
|
||||
if (SelectedNode is not { Kind: MimirSceneEditorNodeKind.SensorFeedPanel } &&
|
||||
nodes.FirstOrDefault(static node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel) is { } firstFeed)
|
||||
{
|
||||
SelectedNodeId = firstFeed.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInput(float deltaSeconds, InputState input)
|
||||
|
|
@ -194,14 +169,6 @@ public sealed class MimirSceneEditorState
|
|||
: null;
|
||||
}
|
||||
|
||||
public bool IsExpanded(string groupId) =>
|
||||
expandedGroups.TryGetValue(groupId, out var expanded) && expanded;
|
||||
|
||||
public void SetExpanded(string groupId, bool expanded)
|
||||
{
|
||||
expandedGroups[groupId] = expanded;
|
||||
}
|
||||
|
||||
public void SelectNode(string nodeId)
|
||||
{
|
||||
if (nodes.Any(node => string.Equals(node.Id, nodeId, StringComparison.Ordinal)))
|
||||
|
|
@ -210,6 +177,14 @@ public sealed class MimirSceneEditorState
|
|||
}
|
||||
}
|
||||
|
||||
public void SelectSource(string sourceId)
|
||||
{
|
||||
if (NodeForSource(sourceId) is { } node)
|
||||
{
|
||||
SelectedNodeId = node.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNext() => SelectRelative(1);
|
||||
|
||||
public void SelectPrevious() => SelectRelative(-1);
|
||||
|
|
@ -306,6 +281,90 @@ public sealed class MimirSceneEditorState
|
|||
}
|
||||
}
|
||||
|
||||
public void CenterSelectedProgramLayer()
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with { CenterX = 0.5f, CenterY = 0.5f });
|
||||
}
|
||||
}
|
||||
|
||||
public void FitSelectedProgramLayer()
|
||||
{
|
||||
if (SelectedNode is not { } selected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var placement = PlacementForNode(selected);
|
||||
var aspect = Math.Clamp(placement.Width / Math.Max(placement.Height, 0.001f), 0.05f, 32.0f);
|
||||
const float programAspect = 16.0f / 9.0f;
|
||||
var width = 1.0f;
|
||||
var height = 1.0f;
|
||||
if (aspect > programAspect)
|
||||
{
|
||||
height = programAspect / aspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = aspect / programAspect;
|
||||
}
|
||||
|
||||
SetNodeProgramPlacement(selected, placement with
|
||||
{
|
||||
CenterX = 0.5f,
|
||||
CenterY = 0.5f,
|
||||
Width = width,
|
||||
Height = height,
|
||||
});
|
||||
}
|
||||
|
||||
public void FillSelectedProgramLayer()
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with
|
||||
{
|
||||
CenterX = 0.5f,
|
||||
CenterY = 0.5f,
|
||||
Width = 1.0f,
|
||||
Height = 1.0f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveSelectedLayer(int delta)
|
||||
{
|
||||
if (SelectedNode is not { Kind: MimirSceneEditorNodeKind.SensorFeedPanel } selected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var videoNodes = nodes
|
||||
.Where(static node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel)
|
||||
.OrderBy(static node => node.Layer)
|
||||
.ThenBy(static node => node.SourceId, StringComparer.Ordinal)
|
||||
.ToList();
|
||||
var current = videoNodes.FindIndex(node => string.Equals(node.Id, selected.Id, StringComparison.Ordinal));
|
||||
if (current < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var next = Math.Clamp(current + delta, 0, videoNodes.Count - 1);
|
||||
if (next == current)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
videoNodes.RemoveAt(current);
|
||||
videoNodes.Insert(next, selected);
|
||||
for (var index = 0; index < videoNodes.Count; index++)
|
||||
{
|
||||
videoNodes[index].Layer = index;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IncludesVideoSource(string sourceId) =>
|
||||
NodeForSource(sourceId) is not { } node || node.Visible;
|
||||
|
||||
|
|
@ -327,49 +386,25 @@ public sealed class MimirSceneEditorState
|
|||
CameraTarget = Vector3.Zero;
|
||||
}
|
||||
|
||||
public void AddSdfTextPanel()
|
||||
{
|
||||
var index = nodes.Count(node => node.Kind == MimirSceneEditorNodeKind.SdfTextPanel) + 1;
|
||||
var node = new MimirSceneEditorNode(
|
||||
$"text-{index}",
|
||||
"text",
|
||||
$"SDF Text {index}",
|
||||
MimirSceneEditorNodeKind.SdfTextPanel,
|
||||
new MimirSceneEditorTransform(new Vector3(-2.8f + index * 0.25f, 1.7f - index * 0.25f, 0.0f), 0.0f, new Vector2(2.4f, 0.8f)))
|
||||
{
|
||||
Text = string.IsNullOrWhiteSpace(pendingText) ? "Text" : pendingText,
|
||||
};
|
||||
nodes.Add(node);
|
||||
SelectedNodeId = node.Id;
|
||||
}
|
||||
|
||||
public void ImportModelPlaceholder()
|
||||
{
|
||||
var modelPath = string.IsNullOrWhiteSpace(pendingModelPath)
|
||||
? "assets/models/model.glb"
|
||||
: pendingModelPath;
|
||||
var index = nodes.Count(node => node.Kind == MimirSceneEditorNodeKind.Model) + 1;
|
||||
var node = new MimirSceneEditorNode(
|
||||
$"model-{index}",
|
||||
"models",
|
||||
Path.GetFileNameWithoutExtension(modelPath),
|
||||
MimirSceneEditorNodeKind.Model,
|
||||
new MimirSceneEditorTransform(new Vector3(2.4f, -1.5f + index * 0.2f, 0.0f), 0.0f, new Vector2(1.2f, 1.2f)))
|
||||
{
|
||||
ModelPath = modelPath,
|
||||
};
|
||||
nodes.Add(node);
|
||||
SelectedNodeId = node.Id;
|
||||
}
|
||||
|
||||
public string DescribeHierarchy()
|
||||
{
|
||||
var feeds = nodes
|
||||
.Where(static node => node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel)
|
||||
.OrderBy(static node => node.Layer)
|
||||
.ThenBy(static node => node.SourceId, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
if (feeds.Length == 0)
|
||||
{
|
||||
return "No synced video streams yet.";
|
||||
}
|
||||
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder.AppendLine("Scene");
|
||||
AppendNode(builder, nodes.First(node => node.Kind == MimirSceneEditorNodeKind.Camera), 1);
|
||||
AppendGroup(builder, "feeds", "Sensor Feeds", MimirSceneEditorNodeKind.SensorFeedPanel);
|
||||
AppendGroup(builder, "text", "SDF Text", MimirSceneEditorNodeKind.SdfTextPanel);
|
||||
AppendGroup(builder, "models", "Models", MimirSceneEditorNodeKind.Model);
|
||||
builder.AppendLine("Program Video Layers");
|
||||
foreach (var node in feeds)
|
||||
{
|
||||
AppendNode(builder, node, 1);
|
||||
}
|
||||
|
||||
return builder.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
|
|
@ -380,9 +415,13 @@ public sealed class MimirSceneEditorState
|
|||
return "no selection";
|
||||
}
|
||||
|
||||
var source = string.IsNullOrWhiteSpace(selected.SourceId) ? "" : $" source={selected.SourceId}";
|
||||
var model = string.IsNullOrWhiteSpace(selected.ModelPath) ? "" : $" model={selected.ModelPath}";
|
||||
return $"{selected.Kind} {selected.DisplayName}{source}{model} pos={selected.Transform.Position.X:0.00},{selected.Transform.Position.Y:0.00},{selected.Transform.Position.Z:0.00} rot={selected.Transform.RotationRadians:0.00} scale={selected.Transform.Scale.X:0.00},{selected.Transform.Scale.Y:0.00}";
|
||||
if (selected.Kind != MimirSceneEditorNodeKind.SensorFeedPanel)
|
||||
{
|
||||
return "no video source selected";
|
||||
}
|
||||
|
||||
var placement = PlacementForNode(selected);
|
||||
return $"{selected.Layer + 1}. {selected.DisplayName} source={selected.SourceId} frame={placement.CenterX:0.000},{placement.CenterY:0.000} {placement.Width:0.000}x{placement.Height:0.000}";
|
||||
}
|
||||
|
||||
public AquariumSplineFrame BuildEditorSplineFrame()
|
||||
|
|
@ -425,26 +464,6 @@ public sealed class MimirSceneEditorState
|
|||
new AquariumSdfLight(new Vector4(3.0f, -2.0f, -2.5f, 3.0f), new Vector4(0.2f, 0.7f, 1.0f, 2.5f)),
|
||||
];
|
||||
|
||||
private void AppendGroup(System.Text.StringBuilder builder, string groupId, string label, MimirSceneEditorNodeKind kind)
|
||||
{
|
||||
var groupNodes = nodes.Where(node => node.Kind == kind).OrderBy(node => node.DisplayName, StringComparer.Ordinal).ToArray();
|
||||
builder.Append(" ")
|
||||
.Append(IsExpanded(groupId) ? "v " : "> ")
|
||||
.Append(label)
|
||||
.Append(" (")
|
||||
.Append(groupNodes.Length)
|
||||
.AppendLine(")");
|
||||
if (!IsExpanded(groupId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var node in groupNodes)
|
||||
{
|
||||
AppendNode(builder, node, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendNode(System.Text.StringBuilder builder, MimirSceneEditorNode node, int depth)
|
||||
{
|
||||
builder
|
||||
|
|
@ -452,9 +471,9 @@ public sealed class MimirSceneEditorState
|
|||
.Append(IsSelected(node) ? "* " : "- ")
|
||||
.Append(node.Visible ? "[eye] " : "[off] ")
|
||||
.Append(node.DisplayName)
|
||||
.Append(" <")
|
||||
.Append(node.Kind)
|
||||
.AppendLine(">");
|
||||
.Append(" layer=")
|
||||
.Append(node.Layer + 1)
|
||||
.AppendLine();
|
||||
}
|
||||
|
||||
private void SelectRelative(int delta)
|
||||
|
|
@ -471,13 +490,7 @@ public sealed class MimirSceneEditorState
|
|||
|
||||
private void RemoveSelectedMutableNode()
|
||||
{
|
||||
if (SelectedNode is not { } selected || selected.Kind is MimirSceneEditorNodeKind.Camera or MimirSceneEditorNodeKind.SensorFeedPanel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nodes.Remove(selected);
|
||||
SelectedNodeId = nodes.First().Id;
|
||||
return;
|
||||
}
|
||||
|
||||
private void SetSelectedPosition(int axis, float value)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,27 @@ public sealed record MimirCameraPoseEstimate(
|
|||
Quaternion CameraToWorldRotation,
|
||||
double Confidence);
|
||||
|
||||
public sealed record MimirCameraFrustumEstimate(
|
||||
string SourceId,
|
||||
Vector3 PositionMeters,
|
||||
Quaternion CameraToWorldRotation,
|
||||
double HorizontalTanHalfFov,
|
||||
double VerticalTanHalfFov,
|
||||
double Confidence)
|
||||
{
|
||||
public static MimirCameraFrustumEstimate FromPose(
|
||||
MimirCameraPoseEstimate pose,
|
||||
double horizontalTanHalfFov = 1.0,
|
||||
double verticalTanHalfFov = 1.0) =>
|
||||
new(
|
||||
pose.SourceId,
|
||||
pose.PositionMeters,
|
||||
pose.CameraToWorldRotation,
|
||||
horizontalTanHalfFov,
|
||||
verticalTanHalfFov,
|
||||
pose.Confidence);
|
||||
}
|
||||
|
||||
public sealed record MimirCameraPoseUpdate(
|
||||
string SourceId,
|
||||
Vector3 EstimatedPositionMeters,
|
||||
|
|
@ -106,6 +127,27 @@ public sealed record MimirCameraRigCalibrationFrame(
|
|||
double Confidence,
|
||||
bool HasPoseUpdate);
|
||||
|
||||
public sealed record MimirCameraFrustumSolveUpdate(
|
||||
string SourceId,
|
||||
Vector3 EstimatedPositionMeters,
|
||||
Quaternion EstimatedCameraToWorldRotation,
|
||||
double HorizontalTanHalfFov,
|
||||
double VerticalTanHalfFov,
|
||||
Vector3 DeltaMeters,
|
||||
double RotationDeltaDegrees,
|
||||
int UsedPointCount,
|
||||
double MeanReprojectionErrorClip,
|
||||
double Confidence);
|
||||
|
||||
public sealed record MimirCameraFrustumSolveFrame(
|
||||
string CalibrationId,
|
||||
string CandidateKey,
|
||||
string SplineId,
|
||||
IReadOnlyList<MimirCameraFrustumSolveUpdate> FrustumUpdates,
|
||||
double MeanReprojectionErrorClip,
|
||||
double Confidence,
|
||||
bool HasFrustumUpdate);
|
||||
|
||||
public sealed class MimirLedSplineCurveSolver
|
||||
{
|
||||
public MimirLedSplineCurveFit SolveCameraCurve(
|
||||
|
|
@ -667,3 +709,406 @@ public sealed class MimirCameraRigCalibrationSolver
|
|||
|
||||
private readonly record struct RayPoint(Vector3 Scene, Vector3 Direction, double Confidence);
|
||||
}
|
||||
|
||||
public sealed class MimirCameraFrustumCalibrationSolver
|
||||
{
|
||||
private const int ParameterCount = 8;
|
||||
|
||||
public MimirCameraFrustumSolveFrame FitFrustumsFromLedSpline(
|
||||
MimirLedSplineFieldCandidate candidate,
|
||||
IEnumerable<MimirLedSplineScenePoint> scenePoints,
|
||||
IEnumerable<MimirCameraFrustumEstimate> currentFrustums,
|
||||
double maximumDeltaMeters = 0.50,
|
||||
double maximumRotationDeltaDegrees = 30.0,
|
||||
double minimumTanHalfFov = 0.20,
|
||||
double maximumTanHalfFov = 2.50)
|
||||
{
|
||||
var sceneByLed = scenePoints
|
||||
.Where(static point => point.LedIndex >= 0 && point.Confidence > 0.0)
|
||||
.GroupBy(static point => point.LedIndex)
|
||||
.ToDictionary(static group => group.Key, static group => group.OrderByDescending(point => point.Confidence).First());
|
||||
var frustumBySource = currentFrustums.ToDictionary(static frustum => frustum.SourceId, StringComparer.Ordinal);
|
||||
var updates = new List<MimirCameraFrustumSolveUpdate>();
|
||||
|
||||
foreach (var observation in candidate.CameraObservations)
|
||||
{
|
||||
if (!frustumBySource.TryGetValue(observation.SourceId, out var seed) ||
|
||||
seed.Confidence <= 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var correspondences = observation.Points
|
||||
.Where(point => sceneByLed.ContainsKey(point.LedIndex) && point.Confidence > 0.0)
|
||||
.Select(point =>
|
||||
{
|
||||
var scene = sceneByLed[point.LedIndex];
|
||||
return new FrustumCorrespondence(
|
||||
scene.PositionMeters,
|
||||
point.ClipX,
|
||||
point.ClipY,
|
||||
Math.Min(point.Confidence, scene.Confidence));
|
||||
})
|
||||
.ToArray();
|
||||
if (correspondences.Length < 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryFitFrustum(
|
||||
correspondences,
|
||||
seed,
|
||||
minimumTanHalfFov,
|
||||
maximumTanHalfFov,
|
||||
out var solved,
|
||||
out var meanError))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var delta = solved.PositionMeters - seed.PositionMeters;
|
||||
var clampedDelta = ClampLength(delta, (float)Math.Max(0.0, maximumDeltaMeters));
|
||||
var rotationDeltaDegrees = RotationDeltaDegrees(seed.CameraToWorldRotation, solved.CameraToWorldRotation);
|
||||
var finalRotation = solved.CameraToWorldRotation;
|
||||
if (rotationDeltaDegrees > maximumRotationDeltaDegrees && rotationDeltaDegrees > 1.0e-9)
|
||||
{
|
||||
var amount = (float)(maximumRotationDeltaDegrees / rotationDeltaDegrees);
|
||||
finalRotation = Quaternion.Normalize(Quaternion.Slerp(seed.CameraToWorldRotation, solved.CameraToWorldRotation, amount));
|
||||
rotationDeltaDegrees = maximumRotationDeltaDegrees;
|
||||
}
|
||||
|
||||
var finalEstimate = solved with
|
||||
{
|
||||
PositionMeters = seed.PositionMeters + clampedDelta,
|
||||
CameraToWorldRotation = finalRotation,
|
||||
HorizontalTanHalfFov = Clamp(solved.HorizontalTanHalfFov, minimumTanHalfFov, maximumTanHalfFov),
|
||||
VerticalTanHalfFov = Clamp(solved.VerticalTanHalfFov, minimumTanHalfFov, maximumTanHalfFov),
|
||||
};
|
||||
var finalError = MeanReprojectionError(correspondences, finalEstimate);
|
||||
var confidence = Clamp01(candidate.Confidence) *
|
||||
Clamp01(seed.Confidence) *
|
||||
correspondences.Average(static point => Clamp01(point.Confidence)) *
|
||||
(1.0 / (1.0 + finalError * 4.0));
|
||||
updates.Add(new MimirCameraFrustumSolveUpdate(
|
||||
observation.SourceId,
|
||||
finalEstimate.PositionMeters,
|
||||
finalEstimate.CameraToWorldRotation,
|
||||
finalEstimate.HorizontalTanHalfFov,
|
||||
finalEstimate.VerticalTanHalfFov,
|
||||
clampedDelta,
|
||||
rotationDeltaDegrees,
|
||||
correspondences.Length,
|
||||
finalError,
|
||||
confidence));
|
||||
}
|
||||
|
||||
var meanFrameError = updates.Count == 0
|
||||
? double.NaN
|
||||
: updates.Average(static update => update.MeanReprojectionErrorClip);
|
||||
var frameConfidence = updates.Count == 0
|
||||
? 0.0
|
||||
: updates.Average(static update => update.Confidence);
|
||||
return new MimirCameraFrustumSolveFrame(
|
||||
candidate.CalibrationId,
|
||||
candidate.CandidateKey,
|
||||
candidate.SplineId,
|
||||
updates,
|
||||
meanFrameError,
|
||||
frameConfidence,
|
||||
HasFrustumUpdate: updates.Count > 0);
|
||||
}
|
||||
|
||||
private static bool TryFitFrustum(
|
||||
IReadOnlyList<FrustumCorrespondence> correspondences,
|
||||
MimirCameraFrustumEstimate seed,
|
||||
double minimumTanHalfFov,
|
||||
double maximumTanHalfFov,
|
||||
out MimirCameraFrustumEstimate solved,
|
||||
out double meanError)
|
||||
{
|
||||
var parameters = new[]
|
||||
{
|
||||
(double)seed.PositionMeters.X,
|
||||
(double)seed.PositionMeters.Y,
|
||||
(double)seed.PositionMeters.Z,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
Math.Log(Clamp(seed.HorizontalTanHalfFov, minimumTanHalfFov, maximumTanHalfFov)),
|
||||
Math.Log(Clamp(seed.VerticalTanHalfFov, minimumTanHalfFov, maximumTanHalfFov)),
|
||||
};
|
||||
var lambda = 1.0e-3;
|
||||
var residuals = Residuals(correspondences, seed, parameters, minimumTanHalfFov, maximumTanHalfFov);
|
||||
var bestCost = Cost(residuals);
|
||||
|
||||
for (var iteration = 0; iteration < 24; iteration++)
|
||||
{
|
||||
var jacobian = Jacobian(correspondences, seed, parameters, residuals, minimumTanHalfFov, maximumTanHalfFov);
|
||||
var normal = new double[ParameterCount, ParameterCount];
|
||||
var rhs = new double[ParameterCount];
|
||||
for (var residualIndex = 0; residualIndex < residuals.Length; residualIndex++)
|
||||
{
|
||||
for (var column = 0; column < ParameterCount; column++)
|
||||
{
|
||||
var j = jacobian[residualIndex, column];
|
||||
rhs[column] -= j * residuals[residualIndex];
|
||||
for (var row = 0; row < ParameterCount; row++)
|
||||
{
|
||||
normal[column, row] += j * jacobian[residualIndex, row];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var index = 0; index < ParameterCount; index++)
|
||||
{
|
||||
normal[index, index] += lambda * (normal[index, index] + 1.0);
|
||||
}
|
||||
|
||||
if (!TrySolveLinearSystem(normal, rhs, out var step))
|
||||
{
|
||||
lambda *= 10.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
var candidate = parameters.ToArray();
|
||||
for (var index = 0; index < ParameterCount; index++)
|
||||
{
|
||||
candidate[index] += step[index];
|
||||
}
|
||||
|
||||
var candidateResiduals = Residuals(correspondences, seed, candidate, minimumTanHalfFov, maximumTanHalfFov);
|
||||
var candidateCost = Cost(candidateResiduals);
|
||||
if (candidateCost < bestCost)
|
||||
{
|
||||
parameters = candidate;
|
||||
residuals = candidateResiduals;
|
||||
bestCost = candidateCost;
|
||||
lambda = Math.Max(1.0e-9, lambda * 0.35);
|
||||
}
|
||||
else
|
||||
{
|
||||
lambda *= 8.0;
|
||||
}
|
||||
}
|
||||
|
||||
solved = BuildEstimate(seed, parameters, minimumTanHalfFov, maximumTanHalfFov);
|
||||
meanError = MeanReprojectionError(correspondences, solved);
|
||||
return double.IsFinite(meanError);
|
||||
}
|
||||
|
||||
private static double[,] Jacobian(
|
||||
IReadOnlyList<FrustumCorrespondence> correspondences,
|
||||
MimirCameraFrustumEstimate seed,
|
||||
IReadOnlyList<double> parameters,
|
||||
IReadOnlyList<double> residuals,
|
||||
double minimumTanHalfFov,
|
||||
double maximumTanHalfFov)
|
||||
{
|
||||
var jacobian = new double[residuals.Count, ParameterCount];
|
||||
var epsilons = new[] { 1.0e-4, 1.0e-4, 1.0e-4, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5 };
|
||||
for (var column = 0; column < ParameterCount; column++)
|
||||
{
|
||||
var shifted = parameters.ToArray();
|
||||
shifted[column] += epsilons[column];
|
||||
var shiftedResiduals = Residuals(correspondences, seed, shifted, minimumTanHalfFov, maximumTanHalfFov);
|
||||
for (var residualIndex = 0; residualIndex < residuals.Count; residualIndex++)
|
||||
{
|
||||
jacobian[residualIndex, column] = (shiftedResiduals[residualIndex] - residuals[residualIndex]) / epsilons[column];
|
||||
}
|
||||
}
|
||||
|
||||
return jacobian;
|
||||
}
|
||||
|
||||
private static double[] Residuals(
|
||||
IReadOnlyList<FrustumCorrespondence> correspondences,
|
||||
MimirCameraFrustumEstimate seed,
|
||||
IReadOnlyList<double> parameters,
|
||||
double minimumTanHalfFov,
|
||||
double maximumTanHalfFov)
|
||||
{
|
||||
var estimate = BuildEstimate(seed, parameters, minimumTanHalfFov, maximumTanHalfFov);
|
||||
var residuals = new double[correspondences.Count * 2];
|
||||
for (var index = 0; index < correspondences.Count; index++)
|
||||
{
|
||||
var correspondence = correspondences[index];
|
||||
var weight = Math.Sqrt(Math.Max(1.0e-6, correspondence.Confidence));
|
||||
if (!TryProject(correspondence.Scene, estimate, out var clipX, out var clipY))
|
||||
{
|
||||
residuals[index * 2] = 8.0 * weight;
|
||||
residuals[index * 2 + 1] = 8.0 * weight;
|
||||
continue;
|
||||
}
|
||||
|
||||
residuals[index * 2] = (clipX - correspondence.ClipX) * weight;
|
||||
residuals[index * 2 + 1] = (clipY - correspondence.ClipY) * weight;
|
||||
}
|
||||
|
||||
return residuals;
|
||||
}
|
||||
|
||||
private static MimirCameraFrustumEstimate BuildEstimate(
|
||||
MimirCameraFrustumEstimate seed,
|
||||
IReadOnlyList<double> parameters,
|
||||
double minimumTanHalfFov,
|
||||
double maximumTanHalfFov)
|
||||
{
|
||||
var deltaRotation = Quaternion.CreateFromYawPitchRoll(
|
||||
(float)parameters[3],
|
||||
(float)parameters[4],
|
||||
(float)parameters[5]);
|
||||
return seed with
|
||||
{
|
||||
PositionMeters = new Vector3((float)parameters[0], (float)parameters[1], (float)parameters[2]),
|
||||
CameraToWorldRotation = Quaternion.Normalize(deltaRotation * seed.CameraToWorldRotation),
|
||||
HorizontalTanHalfFov = Clamp(Math.Exp(parameters[6]), minimumTanHalfFov, maximumTanHalfFov),
|
||||
VerticalTanHalfFov = Clamp(Math.Exp(parameters[7]), minimumTanHalfFov, maximumTanHalfFov),
|
||||
};
|
||||
}
|
||||
|
||||
private static double MeanReprojectionError(
|
||||
IReadOnlyList<FrustumCorrespondence> correspondences,
|
||||
MimirCameraFrustumEstimate estimate)
|
||||
{
|
||||
var sum = 0.0;
|
||||
var weightSum = 0.0;
|
||||
foreach (var correspondence in correspondences)
|
||||
{
|
||||
if (!TryProject(correspondence.Scene, estimate, out var clipX, out var clipY))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var dx = clipX - correspondence.ClipX;
|
||||
var dy = clipY - correspondence.ClipY;
|
||||
var weight = Math.Max(1.0e-6, correspondence.Confidence);
|
||||
sum += Math.Sqrt(dx * dx + dy * dy) * weight;
|
||||
weightSum += weight;
|
||||
}
|
||||
|
||||
return weightSum <= 0.0 ? double.NaN : sum / weightSum;
|
||||
}
|
||||
|
||||
private static bool TryProject(
|
||||
Vector3 scene,
|
||||
MimirCameraFrustumEstimate estimate,
|
||||
out double clipX,
|
||||
out double clipY)
|
||||
{
|
||||
var worldToCamera = Quaternion.Inverse(estimate.CameraToWorldRotation);
|
||||
var camera = Vector3.Transform(scene - estimate.PositionMeters, worldToCamera);
|
||||
if (camera.Z <= 1.0e-5f)
|
||||
{
|
||||
clipX = 0.0;
|
||||
clipY = 0.0;
|
||||
return false;
|
||||
}
|
||||
|
||||
clipX = camera.X / (camera.Z * Math.Max(1.0e-6, estimate.HorizontalTanHalfFov));
|
||||
clipY = camera.Y / (camera.Z * Math.Max(1.0e-6, estimate.VerticalTanHalfFov));
|
||||
return double.IsFinite(clipX) && double.IsFinite(clipY);
|
||||
}
|
||||
|
||||
private static double Cost(IReadOnlyList<double> residuals) =>
|
||||
residuals.Count == 0 ? double.PositiveInfinity : residuals.Average(static residual => residual * residual);
|
||||
|
||||
private static bool TrySolveLinearSystem(double[,] matrix, double[] rhs, out double[] solution)
|
||||
{
|
||||
var size = rhs.Length;
|
||||
var a = new double[size, size + 1];
|
||||
for (var row = 0; row < size; row++)
|
||||
{
|
||||
for (var column = 0; column < size; column++)
|
||||
{
|
||||
a[row, column] = matrix[row, column];
|
||||
}
|
||||
|
||||
a[row, size] = rhs[row];
|
||||
}
|
||||
|
||||
for (var pivot = 0; pivot < size; pivot++)
|
||||
{
|
||||
var bestRow = pivot;
|
||||
var best = Math.Abs(a[pivot, pivot]);
|
||||
for (var row = pivot + 1; row < size; row++)
|
||||
{
|
||||
var value = Math.Abs(a[row, pivot]);
|
||||
if (value > best)
|
||||
{
|
||||
best = value;
|
||||
bestRow = row;
|
||||
}
|
||||
}
|
||||
|
||||
if (best < 1.0e-12)
|
||||
{
|
||||
solution = [];
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bestRow != pivot)
|
||||
{
|
||||
for (var column = pivot; column <= size; column++)
|
||||
{
|
||||
(a[pivot, column], a[bestRow, column]) = (a[bestRow, column], a[pivot, column]);
|
||||
}
|
||||
}
|
||||
|
||||
var pivotValue = a[pivot, pivot];
|
||||
for (var column = pivot; column <= size; column++)
|
||||
{
|
||||
a[pivot, column] /= pivotValue;
|
||||
}
|
||||
|
||||
for (var row = 0; row < size; row++)
|
||||
{
|
||||
if (row == pivot)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var factor = a[row, pivot];
|
||||
for (var column = pivot; column <= size; column++)
|
||||
{
|
||||
a[row, column] -= factor * a[pivot, column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
solution = new double[size];
|
||||
for (var row = 0; row < size; row++)
|
||||
{
|
||||
solution[row] = a[row, size];
|
||||
}
|
||||
|
||||
return solution.All(double.IsFinite);
|
||||
}
|
||||
|
||||
private static double RotationDeltaDegrees(Quaternion left, Quaternion right)
|
||||
{
|
||||
var dot = Math.Abs(Quaternion.Dot(Quaternion.Normalize(left), Quaternion.Normalize(right)));
|
||||
dot = Math.Clamp(dot, 0.0f, 1.0f);
|
||||
return Math.Acos(dot) * 2.0 * 180.0 / Math.PI;
|
||||
}
|
||||
|
||||
private static Vector3 ClampLength(Vector3 value, float maximumLength)
|
||||
{
|
||||
if (maximumLength <= 0.0f)
|
||||
{
|
||||
return Vector3.Zero;
|
||||
}
|
||||
|
||||
var length = value.Length();
|
||||
return length <= maximumLength || length <= 1.0e-9f
|
||||
? value
|
||||
: value / length * maximumLength;
|
||||
}
|
||||
|
||||
private static double Clamp(double value, double minimum, double maximum) =>
|
||||
double.IsFinite(value) ? Math.Clamp(value, minimum, maximum) : minimum;
|
||||
|
||||
private static double Clamp01(double value) =>
|
||||
double.IsFinite(value) ? Math.Clamp(value, 0.0, 1.0) : 0.0;
|
||||
|
||||
private readonly record struct FrustumCorrespondence(Vector3 Scene, double ClipX, double ClipY, double Confidence);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,3 +287,5 @@
|
|||
{"ts":"2026-05-31T22:06:00+01:00","type":"implementation","status":"ok","note":"Mimir's editor scene view now behaves as a compositor/program preview rather than a dashboard readout: SceneEditorState owns normalized program-frame placement for visible nodes, the CultUI preview renders those rectangles, inspector X/Y/W/H controls mutate the same node transforms as mouse-drag input, and video surface intents carry that placement into Fensalir field support. This makes outgoing element arrangement an editor-owned state path instead of a presentationControls-only opacity/layer list.","files":["src/Mimir.Runtime/MimirRuntime.cs","src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs","src/Mimir.Runtime/Synchronization/MimirFensalirBridgeContracts.cs","src/Mimir.Runtime/Synchronization/MimirFensalirFieldLowering.cs"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj --no-restore; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-compositor-preview-headless.png"}
|
||||
{"ts":"2026-05-31T22:18:00+01:00","type":"implementation","status":"ok","note":"Mimir editor scene view no longer carries sync/spectrum telemetry; Odin's Nightwing TUI is the telemetry surface over CultMesh. The center panel now prioritizes compositor affordance surface: the program preview consumes the scene-view body, with only viewport actions below it and asset browsing in the thin lower shelf.","files":["src/Mimir.Runtime/MimirRuntime.cs"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj --no-restore; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-preview-maximized-headless.png"}
|
||||
{"ts": "2026-05-31T22:30:36+01:00", "type": "verification", "status": "partial", "note": "Added sync_sweep.py plus stdlib-only Nightwing witness helpers. Live receipt artifacts/runtime/sync-sweep-hints-live proved Nightwing owns Eye/Move localization locally: nw-eye-0 and nw-eye-1 each captured about 1874 frames at 320x240@187 with zero sequence gaps and emitted 8/8 compact mimir.move_controller_observation_state.v1 hints, while Starfire analyzed its own ASIO/DShow/Kiyo streams. Nightwing builtin mic capture works but the cheap local chirp hint is not yet reliable enough to score as a timing witness."}
|
||||
{"ts":"2026-05-31T22:45:00+01:00","type":"implementation","status":"ok","note":"Mimir editor authority was cut back to a 2D OBS-shaped program mixer. SceneEditorState no longer creates default SDF/model content, preview items are video-feed-only, runtime editor camera/SDF/spline output is silent, and the Eve/CultUI surface is Video Sources left, maximized Program Preview center, Audio Mixer below, and Layer Inspector right. `--scene-editor-smoke` now verifies only camera+video feed nodes, video-only preview items, and normalized program placement.","files":["src/Mimir.Runtime/MimirRuntime.cs","src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs","src/Mimir.BufferSmoke/Program.cs"],"source":"dotnet build src/Mimir.Runtime/Mimir.Runtime.csproj; dotnet build src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj; dotnet run --no-build --project src/Mimir.BufferSmoke/Mimir.BufferSmoke.csproj -- --scene-editor-smoke"}
|
||||
{"ts": "2026-05-31T22:46:40+01:00", "type": "implementation", "status": "ok", "note": "Added the first Starfire-owned camera frustum solve. MimirCameraFrustumCalibrationSolver consumes stable LED/marker correspondences, scene-space marker points, and seed frustums, then emits position, rotation, horizontal/vertical tangent half-FOV, correspondence count, clipspace reprojection residual, and confidence. BufferSmoke --frustum-calibration-smoke solves five synthetic frustums for ps3-eye-0, ps3-eye-1, kiyo-pro-rgb, leap-stereo-ir, and eve-camera with mean clip error 0.000000; room calibration lock still passes. Eve is now modeled like Nightwing as eve-local-sensor-witness/eve-local-sensors: it owns local camera/mic flash and chirp solves and ships typed hints, not raw placement authority."}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ objective:
|
|||
microphones, two speakers, Leap timing, Fensalir GPU rendering, Faust DSP,
|
||||
and OBS output.
|
||||
current: >
|
||||
Make Leap dense geometry visible and calibratable first: live Leap packed
|
||||
stereo IR feeds Fensalir D3D12 disparity, Mimir declares a derived
|
||||
point-cloud Mesh socket, then Fensalir should generate/render points in the
|
||||
editor and feed global residuals into online calibration.
|
||||
Build the Mimir editor as a 2D OBS-shaped program mixer first: synced video
|
||||
streams become compositable program layers, audio streams remain mixable
|
||||
stems, and telemetry stays on Odin's Nightwing TUI/CultMesh surface instead
|
||||
of stealing editor space. Leap/3D calibration work remains important, but
|
||||
it is not the live editor authority for this pass.
|
||||
|
||||
constraints:
|
||||
- Sender is Windows.
|
||||
|
|
@ -51,6 +52,11 @@ invariants:
|
|||
- Mimir publishes physical observations, calibration constraints, and surface
|
||||
intent. Fensalir owns field claims, selected lowerings, evidence reservoirs,
|
||||
temporal guide lanes, and program presentation.
|
||||
- The Mimir editor is currently a 2D program mixer. `MimirSceneEditorState`
|
||||
owns normalized video-layer placement for synced video streams and emits
|
||||
only video-source preview items; camera/SDF/model authoring has no live UI
|
||||
authority, and editor camera/SDF/spline output must not contribute to the
|
||||
runtime frame.
|
||||
- Fast stereo depth belongs to Fensalir's D3D12 compute/resource authority.
|
||||
`research/d3d12-stereo-depth-provenance-2026-05-29.md` records libSGM as
|
||||
the permissive north-star reference for a future SGM-shaped stereo
|
||||
|
|
@ -214,6 +220,21 @@ invariants:
|
|||
Machine profile emit typed Move observation, camera feature-track, and
|
||||
visual marker state; raw Eye media from Nightwing is diagnostic only and
|
||||
Nightwing does not own camera placement or the canonical clock.
|
||||
Eve follows the same distributed-witness rule for its own body:
|
||||
`eve-local-sensor-witness` / `eve-local-sensors` owns Eve camera, Eve mic,
|
||||
local flash/chirp decode, feature tracks, visual markers, and local frustum
|
||||
hints. It may send compact typed evidence, but raw Eve media is not global
|
||||
placement authority and Eve never owns the canonical clock.
|
||||
`MimirCameraFrustumCalibrationSolver` is now the first Starfire-owned
|
||||
frustum solve: stable LED/marker correspondences plus scene-space marker
|
||||
points and seed frustums produce per-source position, rotation,
|
||||
horizontal/vertical tangent half-FOV, correspondence count, clipspace
|
||||
reprojection residual, and confidence. This supersedes translation-only
|
||||
rig updates for global fusion setup; the older
|
||||
`MimirCameraRigCalibrationSolver` remains a narrow bounded translation
|
||||
residual helper. `Mimir.BufferSmoke --frustum-calibration-smoke` proves
|
||||
five solved frustums for both Eyes, Kiyo Pro, Leap stereo IR, and Eve
|
||||
camera.
|
||||
The Eyes have physically moved to Nightwing and Linux sees them as stock
|
||||
`ov534`/`gspca` V4L2 cameras on `/dev/video2` and `/dev/video3`. A
|
||||
repo-owned `tools/nightwing_v4l2_cadence_probe.py` copied to Nightwing
|
||||
|
|
@ -801,7 +822,8 @@ accepted_design:
|
|||
whenever dirty.
|
||||
|
||||
active_subgoals:
|
||||
- Verify the live Leap point cloud in the Mimir editor.
|
||||
- Make the live Mimir editor behave like an OBS-style 2D compositor for
|
||||
synced video layers and audio stems.
|
||||
- Add calibrated projection constants and a global residual/calibration owner
|
||||
that can consume Leap point-cloud errors before PS3 Eyes, Kiyos, and Eve
|
||||
feed wider online calibration.
|
||||
|
|
|
|||
Loading…
Reference in a new issue