Sorting without ... improvements
This commit is contained in:
@ -385,7 +385,7 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void BeforeSaveResizedImagesByPersonKeyFormatted(string[] jLinks, string a2PeopleSingletonDirectory)
|
||||
public static void BeforeSaveFilteredOriginalImagesFromJLinks(string[] jLinks, string a2PeopleSingletonDirectory)
|
||||
{
|
||||
string[] files;
|
||||
string checkDirectory;
|
||||
|
@ -163,8 +163,11 @@ public partial class E_Distance
|
||||
(Face, double?)[] results;
|
||||
List<(Face Face, double? Length)> collection = GetValues(mappingFromItem, filteredFaces, modelsFaceEncoding, normalizedRectangle);
|
||||
results = (from l in collection orderby l.Length select l).Take(1).ToArray();
|
||||
(Face _, double? length) = results.First();
|
||||
_Debug.Add(length);
|
||||
if (results.Any())
|
||||
{
|
||||
(Face _, double? length) = results.First();
|
||||
_Debug.Add(length);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -240,30 +243,33 @@ public partial class E_Distance
|
||||
private static List<Face> FilterByIntersect(Face[] faces, int normalizedRectangle)
|
||||
{
|
||||
List<Face> results = new();
|
||||
results.AddRange(faces);
|
||||
// double? percent;
|
||||
// System.Drawing.Rectangle checkRectangle;
|
||||
// System.Drawing.Rectangle sourceRectangle;
|
||||
// System.Drawing.Rectangle intersectRectangle;
|
||||
// string npp = normalizedRectangle.ToString();
|
||||
// foreach (Face face in faces)
|
||||
// {
|
||||
// if (face.Location is null || face.OutputResolution is null)
|
||||
// continue;
|
||||
// sourceRectangle = new(npp, npp, npp, npp);
|
||||
// checkRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||
// intersectRectangle = System.Drawing.Rectangle.Intersect(sourceRectangle, checkRectangle);
|
||||
// if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||
// continue;
|
||||
// percent = (double)intersectRectangle.Width * intersectRectangle.Height / (checkRectangle.Width * checkRectangle.Height);
|
||||
// if (percent < 0.000001)
|
||||
// continue;
|
||||
// results.Add(face);
|
||||
// }
|
||||
bool useOldWay;
|
||||
double? percent;
|
||||
System.Drawing.Rectangle checkRectangle;
|
||||
System.Drawing.Rectangle sourceRectangle;
|
||||
System.Drawing.Rectangle intersectRectangle;
|
||||
foreach (Face face in faces)
|
||||
{
|
||||
if (face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
checkRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
useOldWay = i == 1;
|
||||
sourceRectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(checkRectangle, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, normalizedRectangle, face.OutputResolution, useOldWay);
|
||||
intersectRectangle = System.Drawing.Rectangle.Intersect(sourceRectangle, checkRectangle);
|
||||
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||
continue;
|
||||
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (checkRectangle.Width * checkRectangle.Height);
|
||||
if (percent < 0.000001)
|
||||
continue;
|
||||
results.Add(face);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void LookForMatchFacesAndPossiblyRename(string facesFileNameExtension, string? eDistanceContentDirectory, MappingFromItem mappingFromItem, List<Face> faces, List<(string MappedFaceFile, int normalizedRectangle)> collection)
|
||||
public void LookForMatchFacesAndPossiblyRename(string facesFileNameExtension, string? eDistanceContentDirectory, MappingFromItem mappingFromItem, List<Face> faces, List<(string MappedFaceFile, int NormalizedRectangle, IReadOnlyList<MetadataExtractor.Directory>? Directories)> collection)
|
||||
{
|
||||
string? json;
|
||||
string[] matches;
|
||||
@ -274,15 +280,19 @@ public partial class E_Distance
|
||||
Face[] filteredFaces = (from l in faces where l.FaceEncoding is not null && l.Location is not null && l.OutputResolution is not null select l).ToArray();
|
||||
if (filteredFaces.Length != faces.Count)
|
||||
checkFaces.Clear();
|
||||
foreach ((string mappedFaceFile, int normalizedRectangle) in collection)
|
||||
foreach ((string mappedFaceFile, int normalizedRectangle, IReadOnlyList<MetadataExtractor.Directory>? directories) in collection)
|
||||
{
|
||||
if (!filteredFaces.Any())
|
||||
break;
|
||||
if (_Renamed.Contains(mappedFaceFile))
|
||||
continue;
|
||||
mappedFaceFileName = Path.GetFileName(mappedFaceFile);
|
||||
if (_DuplicateMappedFaceFiles.Contains(mappedFaceFileName))
|
||||
continue;
|
||||
checkFaces.Clear();
|
||||
json = Metadata.Models.Stateless.IMetadata.GetFaceEncoding(mappedFaceFile);
|
||||
if (directories is null)
|
||||
throw new NullReferenceException(nameof(directories));
|
||||
json = Metadata.Models.Stateless.IMetadata.GetFaceEncoding(directories);
|
||||
if (json is null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(eDistanceContentDirectory) && _DistanceMoveUnableToMatch)
|
||||
|
Reference in New Issue
Block a user