Small changes
This commit is contained in:
parent
e532c3ef1e
commit
99198cc378
@ -173,14 +173,15 @@ public class D2_FaceParts
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSeasonABDirectory(string d2ResultsFullGroupDirectory, MappingFromItem mappingFromItem)
|
||||
private string GetSeasonABDirectory(string d2ResultsFullGroupDirectory, MappingFromItem mappingFromItem, bool any)
|
||||
{
|
||||
string result;
|
||||
string minimumDateYear = mappingFromItem.MinimumDateTime.ToString("yyyy");
|
||||
DateTime dateTime = mappingFromItem.DateTimeOriginal is null ? mappingFromItem.MinimumDateTime : mappingFromItem.DateTimeOriginal.Value;
|
||||
(int _, string seasonName) = Shared.Models.Stateless.Methods.IProperty.GetSeasonAB(dateTime.DayOfYear);
|
||||
(int season, string seasonName) = Shared.Models.Stateless.Methods.IProperty.GetSeasonAB(dateTime.DayOfYear);
|
||||
string year = mappingFromItem.DateTimeOriginal is null ? $"{minimumDateYear[1..]}{minimumDateYear[0]}" : mappingFromItem.DateTimeOriginal.Value.ToString("yyyy");
|
||||
result = Path.Combine(d2ResultsFullGroupDirectory, $"[{_PropertyConfiguration.ResultContent}]", $"{year} {seasonName}");
|
||||
string directory = Path.Combine(d2ResultsFullGroupDirectory, $"[{_PropertyConfiguration.ResultContent}]", $"{year}.{season} {seasonName}");
|
||||
result = any ? Path.Combine(directory, "---") : Path.Combine(directory, "Complete");
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
return result;
|
||||
@ -220,8 +221,9 @@ public class D2_FaceParts
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
Pen pen;
|
||||
Brush brush;
|
||||
int pointSize;
|
||||
bool any = false;
|
||||
FaceFile faceFile;
|
||||
bool? isDefaultName;
|
||||
List<long> personKeys = [];
|
||||
@ -231,15 +233,16 @@ public class D2_FaceParts
|
||||
string? maker = IMetadata.GetMaker(exifDirectory);
|
||||
string? model = IMetadata.GetModel(exifDirectory);
|
||||
MetadataExtractor.GeoLocation? geoLocation = IMetadata.GeoLocation(exifDirectory);
|
||||
string directory = GetSeasonABDirectory(d2ResultsFullGroupDirectory, mappingFromItem);
|
||||
using Image image = Image.FromFile(mappingFromItem.ResizedFileHolder.FullName);
|
||||
using Graphics graphics = Graphics.FromImage(image);
|
||||
foreach (Shared.Models.Face face in faces)
|
||||
{
|
||||
if (face.Location is null || face.FaceEncoding is null || face.FaceParts is null || face.FaceParts.Count == 0)
|
||||
continue;
|
||||
if (!any && face.Mapping?.MappingFromPerson is null)
|
||||
any = true;
|
||||
mappingFromPerson = face.Mapping?.MappingFromPerson;
|
||||
pen = mappingFromPerson is null ? Pens.Red : Pens.GreenYellow;
|
||||
brush = mappingFromPerson is null ? Brushes.Red : Brushes.GreenYellow;
|
||||
isDefaultName = mappingFromPerson is null ? null : Shared.Models.Stateless.Methods.IPerson.IsDefaultName(mappingFromPerson);
|
||||
if (mappingFromPerson is not null && isDefaultName is not null && !isDefaultName.Value)
|
||||
personKeys.Add(mappingFromPerson.PersonKey);
|
||||
@ -259,17 +262,18 @@ public class D2_FaceParts
|
||||
foreach ((FacePart facePart, FacePoint[] facePoints) in face.FaceParts)
|
||||
{
|
||||
foreach (FacePoint facePoint in facePoints)
|
||||
graphics.DrawEllipse(pen, facePoint.X - pointSize, facePoint.Y - pointSize, pointSize * 2, pointSize * 2);
|
||||
graphics.FillEllipse(brush, facePoint.X - pointSize, facePoint.Y - pointSize, pointSize * 2, pointSize * 2);
|
||||
if (facePart == FacePart.Chin)
|
||||
continue;
|
||||
if (facePoints.Length < 3)
|
||||
continue;
|
||||
x = (int)(from l in facePoints select l.X).Average();
|
||||
y = (int)(from l in facePoints select l.Y).Average();
|
||||
graphics.DrawEllipse(Pens.Purple, x - pointSize, y - pointSize, pointSize * 2, pointSize * 2);
|
||||
graphics.FillEllipse(Brushes.Purple, x - pointSize, y - pointSize, pointSize * 2, pointSize * 2);
|
||||
}
|
||||
}
|
||||
_ = graphics.Save();
|
||||
string directory = GetSeasonABDirectory(d2ResultsFullGroupDirectory, mappingFromItem, any);
|
||||
SaveImage(mappingFromItem, directory, image, faceFiles);
|
||||
}
|
||||
|
||||
@ -306,7 +310,7 @@ public class D2_FaceParts
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
Pen pen;
|
||||
Brush brush;
|
||||
int pointSize;
|
||||
FaceFile faceFile;
|
||||
MappingFromPerson? mappingFromPerson;
|
||||
@ -321,7 +325,7 @@ public class D2_FaceParts
|
||||
continue;
|
||||
using Image image = Image.FromFile(mappingFromItem.ResizedFileHolder.FullName);
|
||||
mappingFromPerson = face.Mapping?.MappingFromPerson;
|
||||
pen = mappingFromPerson is null ? Pens.Red : Pens.GreenYellow;
|
||||
brush = mappingFromPerson is null ? Brushes.Red : Brushes.GreenYellow;
|
||||
faceFile = new(face.Mapping?.MappingFromLocation?.AreaPermyriad,
|
||||
face.Mapping?.MappingFromLocation?.ConfidencePercent,
|
||||
geoLocation?.ToDmsString(),
|
||||
@ -338,14 +342,14 @@ public class D2_FaceParts
|
||||
foreach ((FacePart facePart, FacePoint[] facePoints) in face.FaceParts)
|
||||
{
|
||||
foreach (FacePoint facePoint in facePoints)
|
||||
graphics.DrawEllipse(pen, facePoint.X - pointSize, facePoint.Y - pointSize, pointSize * 2, pointSize * 2);
|
||||
graphics.FillEllipse(brush, facePoint.X - pointSize, facePoint.Y - pointSize, pointSize * 2, pointSize * 2);
|
||||
if (facePart == FacePart.Chin)
|
||||
continue;
|
||||
if (facePoints.Length < 3)
|
||||
continue;
|
||||
x = (int)(from l in facePoints select l.X).Average();
|
||||
y = (int)(from l in facePoints select l.Y).Average();
|
||||
graphics.DrawEllipse(Pens.Purple, x - pointSize, y - pointSize, pointSize * 2, pointSize * 2);
|
||||
graphics.FillEllipse(Brushes.Purple, x - pointSize, y - pointSize, pointSize * 2, pointSize * 2);
|
||||
}
|
||||
_ = graphics.Save();
|
||||
SaveImage(fileName, image, faceFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user