feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #26.
This commit is contained in:
1 parent
db389a54f2
commit
188b2c2e55
355 files changed
+10549
-1061
No files matched your search
@@ -449,10 +449,11 @@ internal sealed class AdvisorRules
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aspect 16:9 for landscape sources (the reason says how much height or width the crop keeps), 9:16 for portrait
|
||||
/// ones. When a confident horizon exists and the crop gives up
|
||||
/// height, the crop is placed so the horizon sits on the nearest third of the output frame (recommended only when the
|
||||
/// placement moves at least a fifth of the slack away from centred).
|
||||
/// Aspect 16:9 for landscape views (the reason says how much height or width the crop keeps), 9:16 for portrait
|
||||
/// ones, the view being the source turned by the camera's quarter turns (<see cref="SequenceContext.Rotate"/>). When a
|
||||
/// confident horizon exists, the view is not turned sideways and the crop gives up height, the crop is placed so the
|
||||
/// horizon sits on the nearest third of the output frame (recommended only when the placement moves at least a fifth
|
||||
/// of the slack away from centred).
|
||||
/// </summary>
|
||||
private void Camera()
|
||||
{
|
||||
@@ -462,19 +463,23 @@ internal sealed class AdvisorRules
|
||||
Missing(section, AdvisorParameters.Aspect, AdvisorKeys.MissingSourceSize);
|
||||
return;
|
||||
}
|
||||
if (_source.Height > _source.Width)
|
||||
var turns = FrameOrientation.TurnsOf(_context.Rotate);
|
||||
var (width, height) = turns % 2 == 1 ? (_source.Height, _source.Width) : _source;
|
||||
if (height > width)
|
||||
{
|
||||
Add(section, AdvisorParameters.Aspect, "9:16", 0.7, AdvisorKeys.AspectPortrait);
|
||||
return;
|
||||
}
|
||||
var ratio = (double)_source.Width / _source.Height / (16.0 / 9);
|
||||
var ratio = (double)width / height / (16.0 / 9);
|
||||
var kept = double.Min(1, ratio);
|
||||
if (double.Abs(ratio - 1) < 0.01) Add(section, AdvisorParameters.Aspect, "16:9", 0.9, AdvisorKeys.AspectNative);
|
||||
else if (ratio < 1) Add(section, AdvisorParameters.Aspect, "16:9", 0.7, AdvisorKeys.AspectLandscape, _source.Width, _source.Height, R(100 * ratio, 0));
|
||||
else Add(section, AdvisorParameters.Aspect, "16:9", 0.6, AdvisorKeys.AspectWide, _source.Width, _source.Height, R(100 / ratio, 0));
|
||||
else if (ratio < 1) Add(section, AdvisorParameters.Aspect, "16:9", 0.7, AdvisorKeys.AspectLandscape, width, height, R(100 * ratio, 0));
|
||||
else Add(section, AdvisorParameters.Aspect, "16:9", 0.6, AdvisorKeys.AspectWide, width, height, R(100 / ratio, 0));
|
||||
|
||||
if (kept >= 0.99 || _deep?.Regions is not { Method: RegionMethod.Horizon, Confidence: >= RegionConfidence, Horizon: { Length: > 0 } horizon }) return;
|
||||
var row = horizon.Average();
|
||||
if (kept >= 0.99 || turns % 2 == 1 || _deep?.Regions is not { Method: RegionMethod.Horizon, Confidence: >= RegionConfidence, Horizon: { Length: > 0 } horizon }) return;
|
||||
// The horizon's rows are the decoded frame's: placed in the view as shown (a half turn or a flip shows them upside
|
||||
// down, a straighten turns them about the centre and magnifies them by its cover zoom), as the preview draws them.
|
||||
var row = ViewRow(FrameOrientation.Of(_context.Rotate, false, _context.Flip, _context.Straighten, _source.Width, _source.Height), horizon);
|
||||
var slack = 1 - kept;
|
||||
var third = double.Abs(row - (slack / 2 + kept / 3)) <= double.Abs(row - (slack / 2 + 2 * kept / 3)) ? 1.0 / 3 : 2.0 / 3;
|
||||
var top = double.Clamp(row - third * kept, 0, slack);
|
||||
@@ -482,6 +487,24 @@ internal sealed class AdvisorRules
|
||||
if (double.Abs(offset) >= 0.2) Add(section, AdvisorParameters.OffsetY, offset, 0.5, AdvisorKeys.FramingHorizon, R(100 * row, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The mean row (0 top, 1 bottom) of the horizon in the view of <paramref name="orientation"/>: each sample of the decoded
|
||||
/// frame's horizon (one per column, evenly across the width) mapped through <see cref="FrameOrientation.FrameToView"/>.
|
||||
/// </summary>
|
||||
internal static double ViewRow(FrameOrientation orientation, IReadOnlyList<double> horizon)
|
||||
{
|
||||
if (orientation.IsIdentity) return horizon.Average();
|
||||
var (width, height) = (orientation.FrameWidth, orientation.FrameHeight);
|
||||
var sum = 0.0;
|
||||
for (var k = 0; k < horizon.Count; k++)
|
||||
{
|
||||
var x = horizon.Count == 1 ? (width - 1) / 2.0 : (double)k / (horizon.Count - 1) * (width - 1);
|
||||
var (_, y) = orientation.FrameToView.Apply(x, horizon[k] * height - 0.5);
|
||||
sum += (y + 0.5) / orientation.ViewHeight;
|
||||
}
|
||||
return sum / horizon.Count;
|
||||
}
|
||||
|
||||
/// <summary>Night content: a star field, or a sequence the deep analysis or GPS phases call night.</summary>
|
||||
private bool IsNightSky() => _deep is { } d && (d.Sky.StarField || d.Sky.Light == DayNight.Night);
|
||||
|
||||
|
||||
@@ -144,6 +144,28 @@ public sealed record SequenceContext
|
||||
/// <summary>Wanted video length ("fit to N seconds"), when the user set one.</summary>
|
||||
public double? TargetDurationSeconds { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The camera's quarter turns in degrees clockwise (<see cref="CameraSettings.Rotate"/>): the aspect and the horizon
|
||||
/// framing are advised on the view as shown, the source turned by them.
|
||||
/// </summary>
|
||||
public int Rotate { get; init; }
|
||||
|
||||
/// <summary>The camera's top and bottom swapped (<see cref="CameraSettings.Flip"/>), for the horizon framing.</summary>
|
||||
public bool Flip { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The camera's straighten in degrees (<see cref="CameraSettings.Straighten"/>): it turns the horizon about the view's
|
||||
/// centre and magnifies it by its cover zoom, for the horizon framing.
|
||||
/// </summary>
|
||||
public double Straighten { get; init; }
|
||||
|
||||
/// <summary>This context for the view of <paramref name="camera"/> (its <see cref="Rotate"/>, <see cref="Flip"/> and <see cref="Straighten"/>).</summary>
|
||||
public SequenceContext ForCamera(CameraSettings camera)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
return this with { Rotate = camera.Rotate, Flip = camera.Flip, Straighten = camera.Straighten };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Context from the archive's frame rows: count, dominant oriented size, preview-only count with the dominant oriented
|
||||
/// size of those frames' previews, median shutter time.
|
||||
|
||||
Reference in new issue
Block a user