Carry stereo depth SGM constants

This commit is contained in:
Meta Vens 2026-05-30 00:48:10 +01:00
commit d6823245c2
8 changed files with 47 additions and 6 deletions

View file

@ -2300,8 +2300,12 @@ static AquariumFieldEvidenceFrame BuildSyntheticStereoDepthFrame(MimirFensalirFi
ConfidenceResourceKey: "mimir:resource:stereo-depth:leap-confidence-r8",
Width: 640,
Height: 240,
MinDisparity: profile.MinDisparity,
DisparityLevels: profile.DisparityLevels,
AggregationPathCount: profile.AggregationPathCount,
CensusRadius: profile.CensusRadius,
SmoothnessPenaltySmall: profile.SmoothnessPenaltySmall,
SmoothnessPenaltyLarge: profile.SmoothnessPenaltyLarge,
MinDepthMeters: 0.20,
MaxDepthMeters: 4.0,
Confidence: 0.93,
@ -2353,7 +2357,7 @@ static int RunStereoDepthContractSmoke()
var confidence = frame.Resources.FirstOrDefault(resource => resource.ResourceKey == "mimir:resource:stereo-depth:leap-confidence-r8");
Console.WriteLine(
$"stereo-depth-contract profile={profile.Id} provenance={profile.Provenance} liveDependency={profile.LiveDependency} disparityLevels={profile.DisparityLevels} paths={profile.AggregationPathCount}");
$"stereo-depth-contract profile={profile.Id} provenance={profile.Provenance} liveDependency={profile.LiveDependency} minDisparity={profile.MinDisparity} disparityLevels={profile.DisparityLevels} paths={profile.AggregationPathCount} censusRadius={profile.CensusRadius} p1={profile.SmoothnessPenaltySmall:0.###} p2={profile.SmoothnessPenaltyLarge:0.###}");
Console.WriteLine(
$"stereo-depth-field resources={frame.Resources.Count} claims={frame.Claims.Count} planned={plan.Packets.Count} deferred={plan.DeferredRequests.Count} errors={validation.HasErrors}");
Console.WriteLine(
@ -2369,6 +2373,10 @@ static int RunStereoDepthContractSmoke()
frame.Resources.Count == 4 &&
frame.StereoDepthLowerings.Count == 1 &&
stereoLowering.ProfileKey == profile.Id &&
stereoLowering.MinDisparity == profile.MinDisparity &&
stereoLowering.CensusRadius == profile.CensusRadius &&
Math.Abs(stereoLowering.SmoothnessPenaltySmall - profile.SmoothnessPenaltySmall) < 0.001 &&
Math.Abs(stereoLowering.SmoothnessPenaltyLarge - profile.SmoothnessPenaltyLarge) < 0.001 &&
stereoLowering.LeftResourceKey == "mimir:resource:texture2d:leap-left-ir" &&
stereoLowering.RightResourceKey == "mimir:resource:texture2d:leap-right-ir" &&
stereoLowering.DisparityResourceKey == disparity.ResourceKey &&

View file

@ -768,8 +768,12 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
ConfidenceResourceKey: depthCandidate.ConfidenceResourceKey,
Width: Math.Max(1, depthCandidate.Width),
Height: Math.Max(1, depthCandidate.Height),
MinDisparity: Math.Max(0, depthCandidate.MinDisparity),
DisparityLevels: Math.Max(1, depthCandidate.DisparityLevels),
AggregationPathCount: Math.Max(1, depthCandidate.AggregationPathCount),
CensusRadius: Math.Max(1, depthCandidate.CensusRadius),
SmoothnessPenaltySmall: (float)depthCandidate.SmoothnessPenaltySmall,
SmoothnessPenaltyLarge: (float)depthCandidate.SmoothnessPenaltyLarge,
MinDepthMeters: (float)depthCandidate.MinDepthMeters,
MaxDepthMeters: (float)depthCandidate.MaxDepthMeters);

View file

@ -28,6 +28,10 @@ public sealed record MimirStereoDepthKernelProfile(
bool RequiresCalibration,
string[] RequiredInputResources,
string[] OutputResources,
int MinDisparity,
int CensusRadius,
double SmoothnessPenaltySmall,
double SmoothnessPenaltyLarge,
string[] NegativeChecks);
public sealed record MimirStereoDepthFieldCandidate(
@ -44,8 +48,12 @@ public sealed record MimirStereoDepthFieldCandidate(
string ConfidenceResourceKey,
int Width,
int Height,
int MinDisparity,
int DisparityLevels,
int AggregationPathCount,
int CensusRadius,
double SmoothnessPenaltySmall,
double SmoothnessPenaltyLarge,
double MinDepthMeters,
double MaxDepthMeters,
double Confidence,
@ -67,6 +75,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: true,
RequiredInputResources: ["left Texture2D", "right Texture2D", "stereo calibration"],
OutputResources: ["R16Float disparity SurfacePage", "R8_UNorm confidence Texture2D"],
MinDisparity: 0,
CensusRadius: 2,
SmoothnessPenaltySmall: 8.0,
SmoothnessPenaltyLarge: 96.0,
NegativeChecks:
[
"no CUDA runtime dependency",
@ -89,6 +101,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: true,
RequiredInputResources: ["left Texture2D", "right Texture2D", "model weights"],
OutputResources: ["learned disparity/depth reference"],
MinDisparity: 0,
CensusRadius: 0,
SmoothnessPenaltySmall: 0.0,
SmoothnessPenaltyLarge: 0.0,
NegativeChecks: ["does not own live geometry", "does not introduce model runtime before D3D12 SGM socket exists"]);
public static MimirStereoDepthKernelProfile DepthAnythingSmallReference { get; } = new(
@ -105,6 +121,10 @@ public static class MimirStereoDepthConfigurations
RequiresCalibration: false,
RequiredInputResources: ["single camera Texture2D", "model weights"],
OutputResources: ["relative depth reference"],
MinDisparity: 0,
CensusRadius: 0,
SmoothnessPenaltySmall: 0.0,
SmoothnessPenaltyLarge: 0.0,
NegativeChecks: ["does not own metric scene geometry", "does not bypass calibrated stereo"]);
public static IReadOnlyList<MimirStereoDepthKernelProfile> BuiltIn { get; } =