CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow) and pe-check. BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
126 lines
5.1 KiB
C#
126 lines
5.1 KiB
C#
using Chronos.Core.Analysis;
|
|
using Chronos.Core.Analysis.Deep;
|
|
using Chronos.Core.Diagnostics.Synthetic;
|
|
using Chronos.Core.Imaging;
|
|
|
|
namespace Chronos.Core.Tests.Analysis.Deep;
|
|
|
|
/// <summary>
|
|
/// <see cref="IFrameSource"/> over a <see cref="SyntheticSequence"/>. With <paramref name="jitter"/> > 0 the sequence is
|
|
/// rendered <paramref name="jitter"/> pixels larger on every side and each frame is cropped at a seeded integer offset
|
|
/// in ±jitter, which shakes the camera by a known amount.
|
|
/// </summary>
|
|
internal sealed class SyntheticFrameSource(SyntheticSequence sequence, int jitter = 0, int seed = 11) : IFrameSource
|
|
{
|
|
private readonly (int X, int Y)[] _offsets = Offsets(sequence.Count, jitter, seed);
|
|
private int _loads;
|
|
|
|
public SyntheticSequence Sequence { get; } = sequence;
|
|
|
|
public int Width => Sequence.Options.Width - 2 * jitter;
|
|
public int Height => Sequence.Options.Height - 2 * jitter;
|
|
public int Count => Sequence.Count;
|
|
|
|
/// <summary>Total calls of <see cref="LoadAsync"/>.</summary>
|
|
public int Loads => Volatile.Read(ref _loads);
|
|
|
|
/// <summary>Frames that "fail to decode".</summary>
|
|
public HashSet<int> Undecodable { get; init; } = [];
|
|
|
|
/// <summary>Called on every load before decoding (may throw to simulate a crash, or cancel a token).</summary>
|
|
public Action<int>? OnLoad { get; set; }
|
|
|
|
/// <summary>Metadata without shutter time and aperture when true.</summary>
|
|
public bool StripExposure { get; init; }
|
|
|
|
public LightFrame Metadata(int index)
|
|
{
|
|
var frame = LightFrame.From(Sequence.Metadata[index], index) with { Width = Width, Height = Height };
|
|
return StripExposure ? frame with { ExposureTime = null, FNumber = null } : frame;
|
|
}
|
|
|
|
public ValueTask<ImageBuffer?> LoadAsync(int index, int maxLongEdge, CancellationToken cancellationToken)
|
|
{
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
Interlocked.Increment(ref _loads);
|
|
OnLoad?.Invoke(index);
|
|
if (Undecodable.Contains(index)) return ValueTask.FromResult<ImageBuffer?>(null);
|
|
using var full = Sequence.Render(index);
|
|
var (dx, dy) = _offsets[index];
|
|
var image = new ImageBuffer(Width, Height, 3, clear: false);
|
|
for (var c = 0; c < 3; c++)
|
|
{
|
|
for (var y = 0; y < Height; y++)
|
|
full.Row(c, y + jitter + dy).Slice(jitter + dx, Width).CopyTo(image.Row(c, y));
|
|
}
|
|
if (int.Max(Width, Height) <= maxLongEdge) return ValueTask.FromResult<ImageBuffer?>(image);
|
|
using (image) return ValueTask.FromResult<ImageBuffer?>(AnalysisImage.Downscale(image, maxLongEdge));
|
|
}
|
|
|
|
private static (int, int)[] Offsets(int count, int jitter, int seed)
|
|
{
|
|
var random = new Random(seed);
|
|
var offsets = new (int, int)[count];
|
|
for (var i = 0; i < count; i++) offsets[i] = jitter > 0 ? (random.Next(-jitter, jitter + 1), random.Next(-jitter, jitter + 1)) : (0, 0);
|
|
return offsets;
|
|
}
|
|
}
|
|
|
|
/// <summary>In-memory checkpoint that records what was persisted.</summary>
|
|
internal sealed class MemoryCheckpoint : IDeepAnalysisCheckpoint
|
|
{
|
|
private string? _fingerprint;
|
|
|
|
public List<DeepFrame> Frames { get; } = [];
|
|
|
|
public ValueTask<IReadOnlyList<DeepFrame>> LoadAsync(string fingerprint, CancellationToken cancellationToken)
|
|
{
|
|
if (_fingerprint != fingerprint) Frames.Clear();
|
|
_fingerprint = fingerprint;
|
|
return ValueTask.FromResult<IReadOnlyList<DeepFrame>>([.. Frames]);
|
|
}
|
|
|
|
public ValueTask AppendAsync(IReadOnlyList<DeepFrame> frames, CancellationToken cancellationToken)
|
|
{
|
|
Frames.AddRange(frames);
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
/// <summary>The synthetic scenes the deep-analysis and advisor tests share (small frames, fast).</summary>
|
|
internal static class DeepScenes
|
|
{
|
|
/// <summary>Options for the tests: small sources are analysed at native size, flow on every 5th pair, two workers.</summary>
|
|
public static DeepAnalysisOptions Options { get; } = new() { MinAnalysisLongEdge = 64, FlowEvery = 5, MaxDegreeOfParallelism = 2, RegionSampleFrames = 9 };
|
|
|
|
/// <summary>Night sky with stars over dark land and random flicker.</summary>
|
|
public static SyntheticSequence NightSky(int frames = 90, int jitter = 0) => SyntheticSequence.Create(new SyntheticSequenceOptions
|
|
{
|
|
Width = 160 + 2 * jitter,
|
|
Height = 112 + 2 * jitter,
|
|
FrameCount = frames,
|
|
IntervalSeconds = 20,
|
|
BaseExposureTime = 15,
|
|
BaseFNumber = 2.8,
|
|
BaseIso = 3200,
|
|
StarField = true,
|
|
StarCount = 160,
|
|
FlickerEv = 0.12,
|
|
Start = new DateTime(2024, 8, 12, 23, 0, 0),
|
|
});
|
|
|
|
/// <summary>Sunset: the scene darkens 6 EV while the camera opens up 1 EV every 40 frames.</summary>
|
|
public static SyntheticSequence HolyGrail(int frames = 240) => SyntheticSequence.Create(new SyntheticSequenceOptions
|
|
{
|
|
Width = 160,
|
|
Height = 112,
|
|
FrameCount = frames,
|
|
IntervalSeconds = 15,
|
|
BaseExposureTime = 1.0 / 250,
|
|
StartEv = 0.5,
|
|
EndEv = -5.5,
|
|
FlickerEv = 0.03,
|
|
ExposureSteps = [new(40, -1), new(80, -1), new(120, -1), new(160, -1), new(200, -1)],
|
|
});
|
|
}
|