CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
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 and the system SQLite. 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; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). 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> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
112 lines
3.8 KiB
C#
112 lines
3.8 KiB
C#
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Motion;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Motion;
|
|
|
|
public sealed class MotionBlurTests
|
|
{
|
|
private const int Size = 128;
|
|
|
|
private readonly TestContext _context;
|
|
|
|
public MotionBlurTests(TestContext context) => _context = context;
|
|
|
|
[Theory]
|
|
[Case(180.0, 90.0, 0.4330127018922193)]
|
|
[Case(180.0, 0.0, 0.5)]
|
|
[Case(360.0, 0.0, 1.0)]
|
|
[Case(180.0, 180.0, 0.0)]
|
|
[Case(180.0, 270.0, 0.0)]
|
|
[Case(90.0, 54.0, 0.2)]
|
|
public void BlurFractionComposesShutterAngles(double target, double real, double expected) =>
|
|
Assert.Approximately(expected, ShutterAngle.BlurFraction(target, real), 1e-12);
|
|
|
|
[Test]
|
|
public void RealShutterAngleFromExposure()
|
|
{
|
|
Assert.Approximately(180, ShutterAngle.FromExposure(1, 2), 1e-12);
|
|
Assert.Approximately(3.6, ShutterAngle.FromExposure(1 / 250.0, 0.4), 1e-12);
|
|
}
|
|
|
|
[Test]
|
|
public void ZeroVectorsLeaveTheImageIdentical()
|
|
{
|
|
using var source = Texture();
|
|
using var motion = new MotionField(Size, Size, 2);
|
|
using var output = new ImageBuffer(Size, Size);
|
|
new MotionBlurRenderer().Render(source, motion, 0.5, output);
|
|
Assert.True(source.Data.SequenceEqual(output.Data));
|
|
}
|
|
|
|
[Test]
|
|
public void PointBlursIntoASegmentWithItsEnergy()
|
|
{
|
|
using var source = new ImageBuffer(Size, Size, 1);
|
|
source[0, 64, 64] = 1f;
|
|
using var motion = new MotionField(Size, Size, 4);
|
|
motion.Fill(20, 0);
|
|
using var output = new ImageBuffer(Size, Size, 1);
|
|
new MotionBlurRenderer().Render(source, motion, 0.5, output);
|
|
|
|
double total = 0;
|
|
var columns = new HashSet<int>();
|
|
for (var y = 0; y < Size; y++)
|
|
{
|
|
for (var x = 0; x < Size; x++)
|
|
{
|
|
var value = output[0, x, y];
|
|
total += value;
|
|
if (value <= 1e-6f) continue;
|
|
Assert.Equal(64, y);
|
|
columns.Add(x);
|
|
}
|
|
}
|
|
_context.Log($"point energy after blur {total:F6}, segment columns {columns.Min()}..{columns.Max()}");
|
|
Assert.Approximately(1, total, 1e-4);
|
|
Assert.InRange(columns.Min(), 58, 60);
|
|
Assert.InRange(columns.Max(), 68, 70);
|
|
}
|
|
|
|
[Test]
|
|
public void EnergyIsPreservedOnTexture()
|
|
{
|
|
using var source = Texture();
|
|
using var motion = new MotionField(Size, Size, 2);
|
|
for (var j = 0; j < motion.Rows; j++)
|
|
for (var i = 0; i < motion.Columns; i++)
|
|
{
|
|
// A smooth swirl: magnitude up to ~6 px.
|
|
var k = j * motion.Columns + i;
|
|
motion.U[k] = (float)(6 * double.Sin(j * 0.1));
|
|
motion.V[k] = (float)(4 * double.Cos(i * 0.08));
|
|
}
|
|
using var output = new ImageBuffer(Size, Size);
|
|
new MotionBlurRenderer().Render(source, motion, 1.0, output);
|
|
for (var c = 0; c < 3; c++)
|
|
{
|
|
var before = Mean(source.Plane(c), 16);
|
|
var after = Mean(output.Plane(c), 16);
|
|
_context.Log($"channel {c}: mean {before:F6} → {after:F6} ({(after - before) / before:P3})");
|
|
Assert.Approximately(before, after, 2e-3 * before);
|
|
}
|
|
Assert.False(source.Data.SequenceEqual(output.Data));
|
|
}
|
|
|
|
private static double Mean(ReadOnlySpan<float> plane, int margin)
|
|
{
|
|
double sum = 0;
|
|
var n = 0;
|
|
for (var y = margin; y < Size - margin; y++)
|
|
for (var x = margin; x < Size - margin; x++)
|
|
{
|
|
sum += plane[y * Size + x];
|
|
n++;
|
|
}
|
|
return sum / n;
|
|
}
|
|
|
|
private static ImageBuffer Texture() =>
|
|
SyntheticImages.ToRgb(SyntheticImages.Crop(SyntheticImages.Natural(Size, seed: 31), Size, 0, 0, Size, Size), Size, Size);
|
|
}
|