First Commit
This commit is contained in:
parent
bb40883c7d
commit
696158848f
18 changed files with 787 additions and 0 deletions
48
StitchATon/DTO/Generate.cs
Normal file
48
StitchATon/DTO/Generate.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using JetBrains.Annotations;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace StitchATon.DTO;
|
||||
|
||||
public class GenerateInput
|
||||
{
|
||||
public required string CanvasRect { get; [UsedImplicitly] init; }
|
||||
public required float[] CropOffset { get; [UsedImplicitly] init; }
|
||||
public required float[] CropSize { get; [UsedImplicitly] init; }
|
||||
public required float OutputScale { get; [UsedImplicitly] init; }
|
||||
|
||||
public Rect ParsedCanvasRect()
|
||||
{
|
||||
var corners = CanvasRect.Split( ":" );
|
||||
var c1 = ParseCanvasCoord( corners[0] );
|
||||
var c2 = ParseCanvasCoord( corners[1] );
|
||||
|
||||
return new Rect(
|
||||
int.Min( c1.X, c2.X ),
|
||||
int.Min( c1.Y, c2.Y ),
|
||||
int.Abs( c1.X - c2.X ) + 1, // Inclusive bbox
|
||||
int.Abs( c1.Y - c2.Y ) + 1 // Inclusive bbox
|
||||
);
|
||||
}
|
||||
|
||||
private Point ParseCanvasCoord(string labwareCoord)
|
||||
{
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
foreach( var c in labwareCoord )
|
||||
{
|
||||
if( 'A' <= c && c <= 'Z' )
|
||||
y = ( y * 26 ) + ( c - 'A' + 1);
|
||||
else
|
||||
x = ( x * 10 ) + ( c - '0' );
|
||||
}
|
||||
|
||||
y--;
|
||||
x--;
|
||||
|
||||
return new(x, y);
|
||||
}
|
||||
|
||||
public Point2f ParsedCropOffset() => new( CropOffset[0], CropOffset[1] );
|
||||
|
||||
public Point2f ParsedCropSize() => new( CropSize[0], CropSize[1] );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue