Removed old GetRectangle
RectangleIntersectMinimums AddUserSecrets
This commit is contained in:
@ -169,17 +169,19 @@ public class F_PhotoPrism
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteMatches(string fPhotoPrismContentDirectory, string mappingDefaultName, string personBirthdayFormat, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
||||
public static void WriteMatches(string fPhotoPrismContentDirectory, string mappingDefaultName, string personBirthdayFormat, float[] rectangleIntersectMinimums, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
||||
{
|
||||
string file;
|
||||
string text;
|
||||
double percent;
|
||||
int? normalizedRectangle;
|
||||
List<string> subjects = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
PersonContainer[]? personContainers;
|
||||
StringBuilder stringBuilder = new();
|
||||
System.Drawing.Rectangle dlibRectangle;
|
||||
System.Drawing.Rectangle? prismRectangle;
|
||||
System.Drawing.Rectangle intersectRectangle;
|
||||
float rectangleIntersectMinimum = rectangleIntersectMinimums.Min();
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)[] sortedCollection;
|
||||
List<(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)> collection = new();
|
||||
@ -201,14 +203,14 @@ public class F_PhotoPrism
|
||||
{
|
||||
foreach (Shared.Models.Marker marker in mappingFromPhotoPrism.Markers)
|
||||
{
|
||||
prismRectangle = ILocation.GetRectangle(face.OutputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
|
||||
prismRectangle = ILocation.GetRectangle(mappingFromPhotoPrism.DatabaseFile, marker, face.OutputResolution);
|
||||
if (prismRectangle is null)
|
||||
continue;
|
||||
intersectRectangle = System.Drawing.Rectangle.Intersect(dlibRectangle, prismRectangle.Value);
|
||||
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||
continue;
|
||||
double percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
||||
if (percent < 0.000001)
|
||||
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
||||
if (percent < rectangleIntersectMinimum)
|
||||
continue;
|
||||
collection.Add(new(mappingFromPhotoPrism, marker, percent));
|
||||
}
|
||||
@ -220,10 +222,10 @@ public class F_PhotoPrism
|
||||
}
|
||||
if (subjects.Any())
|
||||
{
|
||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-subject_alias_update.sql");
|
||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-{rectangleIntersectMinimum}-subject_alias_update.sql");
|
||||
text = string.Join(Environment.NewLine, subjects.Distinct());
|
||||
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-marker_name_update.sql");
|
||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-{rectangleIntersectMinimum}-marker_name_update.sql");
|
||||
text = stringBuilder.ToString();
|
||||
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user