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>
84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
using Chronos.Core.Motion;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Motion;
|
|
|
|
public sealed class PhaseCorrelatorTests
|
|
{
|
|
private const int Size = 256;
|
|
private const int Patch = 128;
|
|
|
|
private readonly TestContext _context;
|
|
|
|
public PhaseCorrelatorTests(TestContext context) => _context = context;
|
|
|
|
[Theory]
|
|
[Case("noise", 3.25, -1.6)]
|
|
[Case("noise", 0.5, 0.5)]
|
|
[Case("noise", -7.8, 2.1)]
|
|
[Case("noise", 0.0, 0.0)]
|
|
[Case("natural", 3.25, -1.6)]
|
|
[Case("natural", 0.5, 0.5)]
|
|
[Case("natural", -7.8, 2.1)]
|
|
[Case("natural", 12.3, -9.45)]
|
|
public void SubPixelErrorWithinTenthOfPixel(string texture, double dx, double dy)
|
|
{
|
|
var image = texture == "noise" ? SyntheticImages.Noise(Size, 0.8, seed: 7) : SyntheticImages.Natural(Size, seed: 7);
|
|
var shifted = SyntheticImages.Shift(image, Size, dx, dy);
|
|
var reference = SyntheticImages.Crop(image, Size, 64, 64, Patch, Patch);
|
|
var moving = SyntheticImages.Crop(shifted, Size, 64, 64, Patch, Patch);
|
|
|
|
var result = new PhaseCorrelator(Patch, Patch).Correlate(reference, moving);
|
|
var error = double.Hypot(result.Dx - dx, result.Dy - dy);
|
|
_context.Log($"{texture} ({dx}, {dy}) → ({result.Dx:F4}, {result.Dy:F4}) error {error:F4} px, confidence {result.Confidence:F3}, peak {result.Peak:F3}");
|
|
Assert.LessOrEqual(error, 0.10);
|
|
Assert.Greater(result.Confidence, 0.5);
|
|
}
|
|
|
|
[Test]
|
|
public void NonPowerOfTwoPatchesUseBluestein()
|
|
{
|
|
var image = SyntheticImages.Natural(Size, seed: 3);
|
|
var shifted = SyntheticImages.Shift(image, Size, -2.4, 1.3);
|
|
var reference = SyntheticImages.Crop(image, Size, 60, 70, 96, 80);
|
|
var moving = SyntheticImages.Crop(shifted, Size, 60, 70, 96, 80);
|
|
var result = new PhaseCorrelator(96, 80).Correlate(reference, moving);
|
|
Assert.Within(-2.4, 1.3, result.Dx, result.Dy, 0.10);
|
|
}
|
|
|
|
[Test]
|
|
public void PatchesAreReadFromLargerPlanes()
|
|
{
|
|
var image = SyntheticImages.Noise(Size, 1.0, seed: 9);
|
|
var shifted = SyntheticImages.Shift(image, Size, 1.75, -0.25);
|
|
var a = SyntheticImages.Crop(image, Size, 0, 0, Size, Size);
|
|
var b = SyntheticImages.Crop(shifted, Size, 0, 0, Size, Size);
|
|
var result = new PhaseCorrelator(64, 64).Correlate(a, b, Size, 100, 40);
|
|
Assert.Within(1.75, -0.25, result.Dx, result.Dy, 0.10);
|
|
}
|
|
|
|
[Test]
|
|
public void UnrelatedContentHasLowConfidence()
|
|
{
|
|
var a = SyntheticImages.Crop(SyntheticImages.Noise(Size, 0.8, seed: 1), Size, 0, 0, Patch, Patch);
|
|
var b = SyntheticImages.Crop(SyntheticImages.Noise(Size, 0.8, seed: 2), Size, 0, 0, Patch, Patch);
|
|
var result = new PhaseCorrelator(Patch, Patch).Correlate(a, b);
|
|
_context.Log($"confidence {result.Confidence:F3}, peak {result.Peak:F3}");
|
|
Assert.Less(result.Confidence, 0.4);
|
|
Assert.Less(result.Peak, 0.2);
|
|
}
|
|
|
|
[Test]
|
|
public void MaxShiftLimitsTheSearch()
|
|
{
|
|
var image = SyntheticImages.Noise(Size, 0.8, seed: 4);
|
|
var shifted = SyntheticImages.Shift(image, Size, 20, 0);
|
|
var a = SyntheticImages.Crop(image, Size, 64, 64, Patch, Patch);
|
|
var b = SyntheticImages.Crop(shifted, Size, 64, 64, Patch, Patch);
|
|
var free = new PhaseCorrelator(Patch, Patch).Correlate(a, b);
|
|
Assert.Within(20, 0, free.Dx, free.Dy, 0.10);
|
|
var limited = new PhaseCorrelator(Patch, Patch, new PhaseCorrelatorOptions { MaxShift = 8 }).Correlate(a, b);
|
|
Assert.LessOrEqual(double.Abs(limited.Dx), 8.5);
|
|
}
|
|
}
|