FaceFile for D2
This commit is contained in:
@ -1,27 +1,11 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class FaceEncoding : Properties.IFaceEncoding
|
||||
public record FaceEncoding(double[] RawEncoding, int Size);
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = false)]
|
||||
[JsonSerializable(typeof(FaceEncoding))]
|
||||
public partial class FaceEncodingGenerationContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
protected double[] _RawEncoding;
|
||||
protected int _Size;
|
||||
public double[] RawEncoding => _RawEncoding;
|
||||
public int Size => _Size;
|
||||
|
||||
[JsonConstructor]
|
||||
public FaceEncoding(double[] rawEncoding, int size)
|
||||
{
|
||||
_RawEncoding = rawEncoding;
|
||||
_Size = size;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -4,11 +4,13 @@ namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record FaceFile(int? AreaPermyriad,
|
||||
int? ConfidencePercent,
|
||||
DateTime DateTime,
|
||||
string? DMS,
|
||||
DateTime DateTime,
|
||||
FaceEncoding? FaceEncoding,
|
||||
Dictionary<Stateless.FacePart, FacePoint[]>? FaceParts,
|
||||
Location? Location,
|
||||
string? Maker,
|
||||
MappingFromPerson? MappingFromPerson,
|
||||
string? Model,
|
||||
OutputResolution? OutputResolution);
|
||||
|
||||
@ -16,4 +18,16 @@ public record FaceFile(int? AreaPermyriad,
|
||||
[JsonSerializable(typeof(FaceFile))]
|
||||
public partial class FaceFileGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = false, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(FaceFile[]))]
|
||||
public partial class FaceFileCollectionGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(FaceFile[]))]
|
||||
public partial class FaceFileCollectionWriteIndentedGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -1,58 +1,35 @@
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class FacePoint : Properties.IFacePoint
|
||||
[method: JsonConstructor]
|
||||
public class FacePoint(int index, int x, int y) : Properties.IFacePoint
|
||||
{
|
||||
public int Index { get; } = index;
|
||||
public int X { get; } = x;
|
||||
public int Y { get; } = y;
|
||||
|
||||
protected int _Index;
|
||||
protected int _X;
|
||||
protected int _Y;
|
||||
public int Index => _Index;
|
||||
public int X => _X;
|
||||
public int Y => _Y;
|
||||
|
||||
private readonly Point _Point;
|
||||
|
||||
[JsonConstructor]
|
||||
public FacePoint(int index, int x, int y)
|
||||
{
|
||||
_Index = index;
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Point = new(x, y);
|
||||
}
|
||||
|
||||
public FacePoint(Point point, int index) :
|
||||
this(index, point.X, point.Y)
|
||||
{ }
|
||||
private readonly Point _Point = new(x, y);
|
||||
|
||||
public override bool Equals(object? obj) => obj is FacePoint point && Equals(point);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0070
|
||||
public override int GetHashCode()
|
||||
#pragma warning restore IDE0070
|
||||
{
|
||||
int hashCode = 1861411795;
|
||||
hashCode = hashCode * -1521134295 + _Point.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + _Index.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + _Point.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Index.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public bool Equals(FacePoint? facePoint)
|
||||
{
|
||||
return facePoint is not null
|
||||
&& _X == facePoint.X
|
||||
&& _Y == facePoint.Y
|
||||
&& _Index == facePoint.Index;
|
||||
&& X == facePoint.X
|
||||
&& Y == facePoint.Y
|
||||
&& Index == facePoint.Index;
|
||||
}
|
||||
|
||||
public static bool operator ==(FacePoint point1, FacePoint point2) => point1.Equals(point2);
|
||||
|
@ -79,10 +79,10 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
||||
#pragma warning restore IDE0070
|
||||
{
|
||||
int hashCode = -773114317;
|
||||
hashCode = hashCode * -1521134295 + Bottom.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Left.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Right.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Top.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Bottom.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Left.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Right.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Top.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class OutputResolution : Properties.IOutputResolution
|
||||
{
|
||||
|
||||
protected int _Height;
|
||||
protected int _Orientation;
|
||||
protected int _Width;
|
||||
public int Height => _Height;
|
||||
public int Orientation => _Orientation;
|
||||
public int Width => _Width;
|
||||
|
||||
[JsonConstructor]
|
||||
public OutputResolution(int height, int orientation, int width)
|
||||
{
|
||||
_Height = height;
|
||||
_Orientation = orientation;
|
||||
_Width = width;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
public record OutputResolution(int Height,
|
||||
int Orientation,
|
||||
int Width);
|
@ -1,9 +1,9 @@
|
||||
namespace View_by_Distance.Shared.Models.Properties;
|
||||
// namespace View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
public interface IFaceEncoding
|
||||
{
|
||||
// public interface IFaceEncoding
|
||||
// {
|
||||
|
||||
public double[] RawEncoding { get; }
|
||||
public int Size { get; }
|
||||
// public double[] RawEncoding { get; }
|
||||
// public int Size { get; }
|
||||
|
||||
}
|
||||
// }
|
@ -1,10 +1,10 @@
|
||||
namespace View_by_Distance.Shared.Models.Properties;
|
||||
// namespace View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
public interface IOutputResolution
|
||||
{
|
||||
// public interface IOutputResolution
|
||||
// {
|
||||
|
||||
public int Height { get; }
|
||||
public int Orientation { get; }
|
||||
public int Width { get; }
|
||||
// public int Height { get; }
|
||||
// public int Orientation { get; }
|
||||
// public int Width { get; }
|
||||
|
||||
}
|
||||
// }
|
@ -18,6 +18,11 @@ public interface IProperty
|
||||
static (int Season, string seasonName) GetSeason(int dayOfYear) =>
|
||||
Property.GetSeason(dayOfYear);
|
||||
|
||||
(int Season, string seasonName) TestStatic_GetSeasonAB(int dayOfYear) =>
|
||||
GetSeasonAB(dayOfYear);
|
||||
static (int Season, string seasonName) GetSeasonAB(int dayOfYear) =>
|
||||
Property.GetSeasonAB(dayOfYear);
|
||||
|
||||
string TestStatic_GetDiffRootDirectory(string diffPropertyDirectory) =>
|
||||
GetDiffRootDirectory(diffPropertyDirectory);
|
||||
static string GetDiffRootDirectory(string diffPropertyDirectory) =>
|
||||
|
@ -16,6 +16,22 @@ internal abstract class Property
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static (int Season, string seasonName) GetSeasonAB(int dayOfYear)
|
||||
{
|
||||
(int Season, string seasonName) result = dayOfYear switch
|
||||
{
|
||||
< 78 => new(0, "WinterA"),
|
||||
< 124 => new(1, "SpringA"),
|
||||
< 171 => new(1, "SpringB"),
|
||||
< 217 => new(2, "SummerA"),
|
||||
< 264 => new(2, "SummerB"),
|
||||
< 309 => new(3, "FallA"),
|
||||
< 354 => new(3, "FallB"),
|
||||
_ => new(4, "WinterB")
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static (bool?, string[]) IsWrongYear(string[] segments, string year)
|
||||
{
|
||||
bool? result;
|
||||
|
Reference in New Issue
Block a user