55 lines
3.8 KiB
C#

namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface ILocation
{ // ...
string TestStatic_GetLeftPadded(int locationDigits, string value) =>
GetLeftPadded(locationDigits, value);
static string GetLeftPadded(int locationDigits, string value) =>
value.Length == locationDigits ? value : value.Length > locationDigits ? value[..locationDigits] : value.PadLeft(locationDigits, '0');
string TestStatic_GetLeftPadded(int locationDigits, int value) =>
GetLeftPadded(locationDigits, value);
static string GetLeftPadded(int locationDigits, int value) =>
GetLeftPadded(locationDigits, value.ToString());
Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
static Models.Location? GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
location is null ? null : new(location.Confidence, height, location, locationDigits, locationFactor, width, zCount);
Models.Location? TestStatic_GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
GetLocation(factor, location, locationDigits, locationFactor, height, width, zCount);
static Models.Location? GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
location is null ? null : new(location.Confidence, factor, height, location, locationDigits, locationFactor, width, zCount);
int?[] TestStatic_GetInts(List<Models.Location> locations) =>
GetInts(locations);
static int?[] GetInts(List<Models.Location> locations) =>
(from l in locations where l.NormalizedPixelPercentage is not null select l.NormalizedPixelPercentage).ToArray();
int TestStatic_GetNormalizedPixelPercentage(Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution) =>
GetNormalizedPixelPercentage(location, locationDigits, locationFactor, outputResolution);
static int GetNormalizedPixelPercentage(Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution) =>
Location.GetNormalizedPixelPercentage(location.Bottom, outputResolution.Height, location.Left, locationDigits, locationFactor, location.Right, location.Top, outputResolution.Width, zCount: 1);
int TestStatic_GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width) =>
GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width);
static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width) =>
Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount: 1);
Models.Location TestStatic_GetTrimBound(double detectionConfidence, System.Drawing.Rectangle rectangle, int width, int height, int facesCount) =>
TrimBound(detectionConfidence, rectangle, width, height, facesCount);
static Models.Location TrimBound(double detectionConfidence, System.Drawing.Rectangle rectangle, int width, int height, int facesCount) =>
new(Math.Min(rectangle.Bottom, height),
detectionConfidence,
height,
Math.Max(rectangle.Left, 0),
Stateless.ILocation.Digits,
Stateless.ILocation.Factor,
Math.Min(rectangle.Right, width),
Math.Max(rectangle.Top, 0),
width,
facesCount);
}