GetLocations update and
NameWithoutExtensionIsIdFormat
This commit is contained in:
@ -206,10 +206,10 @@ internal abstract class Location
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static Models.Location? GetLocation(Marker marker, Rectangle rectangle)
|
||||
private static Models.Location? GetLocation(DatabaseFile databaseFile, Marker marker, Rectangle rectangle)
|
||||
{
|
||||
Models.Location? result;
|
||||
bool verified = Check(rectangle.Bottom, rectangle.Height, rectangle.Left, rectangle.Right, rectangle.Top, rectangle.Width, zCount: 1, throwException: false);
|
||||
bool verified = Check(rectangle.Bottom, databaseFile.FileHeight, rectangle.Left, rectangle.Right, rectangle.Top, databaseFile.FileWidth, zCount: 1, throwException: false);
|
||||
if (!verified)
|
||||
result = null;
|
||||
else
|
||||
@ -224,45 +224,61 @@ internal abstract class Location
|
||||
if (rectangle is null)
|
||||
result = null;
|
||||
else
|
||||
result = GetLocation(marker, rectangle.Value);
|
||||
result = GetLocation(databaseFile, marker, rectangle.Value);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<Models.Location> GetLocations(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces)
|
||||
{
|
||||
List<Models.Location> results = new();
|
||||
double percent;
|
||||
bool any;
|
||||
bool matches;
|
||||
Rectangle dlibRectangle;
|
||||
Rectangle? prismRectangle;
|
||||
Models.Location? location;
|
||||
Rectangle intersectRectangle;
|
||||
Models.OutputResolution? outputResolution = null;
|
||||
foreach (Models.Face face in faces)
|
||||
{
|
||||
if (face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
foreach (MappingFromPhotoPrism mappingFromPhotoPrism in mappingFromPhotoPrismCollection)
|
||||
results.Add(face.Location);
|
||||
outputResolution ??= face.OutputResolution;
|
||||
}
|
||||
int before = results.Count;
|
||||
foreach (MappingFromPhotoPrism mappingFromPhotoPrism in mappingFromPhotoPrismCollection)
|
||||
{
|
||||
if (outputResolution is null)
|
||||
break;
|
||||
matches = Matches(outputResolution, mappingFromPhotoPrism.DatabaseFile);
|
||||
if (!matches)
|
||||
break;
|
||||
foreach (Marker marker in mappingFromPhotoPrism.Markers)
|
||||
{
|
||||
dlibRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||
foreach (Marker marker in mappingFromPhotoPrism.Markers)
|
||||
any = false;
|
||||
prismRectangle = GetRectangle(outputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
|
||||
if (prismRectangle is null)
|
||||
break;
|
||||
location = GetLocation(mappingFromPhotoPrism.DatabaseFile, marker, prismRectangle.Value);
|
||||
if (location is null)
|
||||
break;
|
||||
foreach (Models.Face face in faces)
|
||||
{
|
||||
prismRectangle = GetRectangle(face.OutputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
|
||||
if (prismRectangle is null)
|
||||
{
|
||||
location = new(1, 0, 0, 1, 0);
|
||||
results.Add(location);
|
||||
continue;
|
||||
}
|
||||
location = GetLocation(marker, prismRectangle.Value);
|
||||
if (location is null)
|
||||
if (face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
dlibRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||
intersectRectangle = Rectangle.Intersect(dlibRectangle, prismRectangle.Value);
|
||||
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
||||
if (percent > 0.000001)
|
||||
if (intersectRectangle.Width == 0 && intersectRectangle.Height == 0)
|
||||
continue;
|
||||
results.Add(location);
|
||||
any = true;
|
||||
break;
|
||||
}
|
||||
if (!any)
|
||||
results.Add(location);
|
||||
}
|
||||
}
|
||||
if (before == results.Count)
|
||||
results.Clear();
|
||||
return results;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user