_Original
This commit is contained in:
		| @ -240,7 +240,16 @@ public partial class Form : System.Windows.Forms.Form | |||||||
|             { |             { | ||||||
|                 checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered; |                 checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered; | ||||||
|                 checkFile = Path.Combine(fileHolder.DirectoryName, $"{dateTime.Value:yyyy-MM-dd}.{dateTime.Value.Ticks}{checkFileExtension}"); |                 checkFile = Path.Combine(fileHolder.DirectoryName, $"{dateTime.Value:yyyy-MM-dd}.{dateTime.Value.Ticks}{checkFileExtension}"); | ||||||
|                 if (checkFile == fileHolder.FullName || File.Exists(checkFile)) |                 if (checkFile == fileHolder.FullName) | ||||||
|  |                     continue; | ||||||
|  |                 for (int i = 0; i < int.MaxValue; i++) | ||||||
|  |                 { | ||||||
|  |                     checkFile = Path.Combine(fileHolder.DirectoryName, $"{dateTime.Value:yyyy-MM-dd}.{dateTime.Value.Ticks + i}{checkFileExtension}"); | ||||||
|  |                     if (File.Exists(checkFile)) | ||||||
|  |                         continue; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 if (File.Exists(checkFile)) | ||||||
|                     continue; |                     continue; | ||||||
|                 File.Move(fileHolder.FullName, checkFile); |                 File.Move(fileHolder.FullName, checkFile); | ||||||
|                 File.WriteAllText($"{checkFile}.id", $"{id.Value}{Environment.NewLine}{fileHolder.Name}"); |                 File.WriteAllText($"{checkFile}.id", $"{id.Value}{Environment.NewLine}{fileHolder.Name}"); | ||||||
|  | |||||||
| @ -218,7 +218,7 @@ public class D_Face | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private List<Shared.Models.Face> GetFaces(Shared.Models.Property property, MappingFromItem mappingFromItem, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, List<Location>? locations) |     private List<Shared.Models.Face> GetFaces(Shared.Models.Methods.IResize resize, string outputResolution, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize, List<Location>? locations) | ||||||
|     { |     { | ||||||
|         if (_Log is null) |         if (_Log is null) | ||||||
|             throw new NullReferenceException(nameof(_Log)); |             throw new NullReferenceException(nameof(_Log)); | ||||||
| @ -237,6 +237,7 @@ public class D_Face | |||||||
|         } |         } | ||||||
|         if (unknownImage is not null) |         if (unknownImage is not null) | ||||||
|         { |         { | ||||||
|  |             (int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = resize.Get(outputResolution, outputResolutionToResize); | ||||||
|             List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection; |             List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection; | ||||||
|             FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters.Value, _Configuration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel); |             FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters.Value, _Configuration.NumberOfTimesToUpsample.Value, _Model, _ModelParameter, _PredictorModel); | ||||||
|             collection = faceRecognition.GetCollection(unknownImage, locations, includeFaceEncoding: true, includeFaceParts: true); |             collection = faceRecognition.GetCollection(unknownImage, locations, includeFaceEncoding: true, includeFaceParts: true); | ||||||
| @ -297,7 +298,7 @@ public class D_Face | |||||||
|  |  | ||||||
| #pragma warning restore CA1416 | #pragma warning restore CA1416 | ||||||
|  |  | ||||||
|     private static List<LocationContainer<MetadataExtractor.Directory>> GetCollection(int outputResolutionWidth, int outputResolutionHeight, List<LocationContainer<MetadataExtractor.Directory>> collection, List<Shared.Models.Face> faces) |     private static List<LocationContainer<MetadataExtractor.Directory>> GetCollection(Shared.Models.Methods.IResize resize, string outputResolution, List<LocationContainer<MetadataExtractor.Directory>> collection, Dictionary<string, int[]> outputResolutionToResize, List<Shared.Models.Face> faces) | ||||||
|     { |     { | ||||||
|         List<LocationContainer<MetadataExtractor.Directory>> results = new(); |         List<LocationContainer<MetadataExtractor.Directory>> results = new(); | ||||||
|         string? json; |         string? json; | ||||||
| @ -305,7 +306,8 @@ public class D_Face | |||||||
|         Location? location; |         Location? location; | ||||||
|         Rectangle? rectangle; |         Rectangle? rectangle; | ||||||
|         List<int> skip = new(); |         List<int> skip = new(); | ||||||
|         OutputResolution? outputResolution = null; |         OutputResolution? outputResolutionCheck = null; | ||||||
|  |         (int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation) = resize.Get(outputResolution, outputResolutionToResize); | ||||||
|         foreach (Shared.Models.Face face in faces) |         foreach (Shared.Models.Face face in faces) | ||||||
|         { |         { | ||||||
|             if (face.Location is null || face.OutputResolution is null) |             if (face.Location is null || face.OutputResolution is null) | ||||||
| @ -325,8 +327,8 @@ public class D_Face | |||||||
|                 json = Metadata.Models.Stateless.IMetadata.GetOutputResolution(locationContainer.Directories); |                 json = Metadata.Models.Stateless.IMetadata.GetOutputResolution(locationContainer.Directories); | ||||||
|                 if (json is not null) |                 if (json is not null) | ||||||
|                 { |                 { | ||||||
|                     outputResolution = JsonSerializer.Deserialize<OutputResolution>(json); |                     outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json); | ||||||
|                     if (outputResolution is not null && (outputResolution.Width != outputResolutionWidth || outputResolution.Height != outputResolutionHeight)) |                     if (outputResolutionCheck is not null && (outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight)) | ||||||
|                         continue; |                         continue; | ||||||
|                 } |                 } | ||||||
|                 (width, height) = Get(locationContainer.File); |                 (width, height) = Get(locationContainer.File); | ||||||
| @ -341,11 +343,11 @@ public class D_Face | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (results.Any()) |         if (results.Any()) | ||||||
|             outputResolution = null; |             outputResolutionCheck = null; | ||||||
|         return results; |         return results; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public List<Shared.Models.Face> GetFaces(string dResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Property property, MappingFromItem mappingFromItem, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, List<LocationContainer<MetadataExtractor.Directory>>? collection, List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection) |     public List<Shared.Models.Face> GetFaces(Shared.Models.Methods.IResize resize, string outputResolution, string dResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize, List<LocationContainer<MetadataExtractor.Directory>>? collection, List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection) | ||||||
|     { |     { | ||||||
|         List<Shared.Models.Face>? results; |         List<Shared.Models.Face>? results; | ||||||
|         if (string.IsNullOrEmpty(dResultsFullGroupDirectory)) |         if (string.IsNullOrEmpty(dResultsFullGroupDirectory)) | ||||||
| @ -388,18 +390,18 @@ public class D_Face | |||||||
|                 parseExceptions.Add(nameof(D_Face)); |                 parseExceptions.Add(nameof(D_Face)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         List<LocationContainer<MetadataExtractor.Directory>> containers; |         List<LocationContainer<MetadataExtractor.Directory>> locationContainers; | ||||||
|         if (results is null || collection is null) |         if (results is null || collection is null) | ||||||
|             containers = new(); |             locationContainers = new(); | ||||||
|         else |         else | ||||||
|             containers = GetCollection(outputResolutionWidth, outputResolutionHeight, collection, results); |             locationContainers = GetCollection(resize, outputResolution, collection, outputResolutionToResize, results); | ||||||
|         if (mappingFromPhotoPrismCollection is null || results is null) |         if (mappingFromPhotoPrismCollection is null || results is null) | ||||||
|             locations = (from l in containers where l is not null select l.Location).ToList(); |             locations = (from l in locationContainers where l is not null select l.Location).ToList(); | ||||||
|         else |         else | ||||||
|             locations = Shared.Models.Stateless.Methods.ILocation.GetLocations(mappingFromPhotoPrismCollection, results, containers); |             locations = Shared.Models.Stateless.Methods.ILocation.GetLocations(mappingFromPhotoPrismCollection, results, locationContainers); | ||||||
|         if (results is null || (locations is not null && locations.Any())) |         if (results is null || (locations is not null && locations.Any())) | ||||||
|         { |         { | ||||||
|             results = GetFaces(property, mappingFromItem, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, locations); |             results = GetFaces(resize, outputResolution, property, mappingFromItem, outputResolutionToResize, locations); | ||||||
|             if (!results.Any()) |             if (!results.Any()) | ||||||
|                 File.Move(mappingFromItem.ResizedFileHolder.FullName, $"{mappingFromItem.ResizedFileHolder.FullName}.err"); |                 File.Move(mappingFromItem.ResizedFileHolder.FullName, $"{mappingFromItem.ResizedFileHolder.FullName}.err"); | ||||||
|             else |             else | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ | |||||||
| using Phares.Shared; | using Phares.Shared; | ||||||
| using ShellProgressBar; | using ShellProgressBar; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
|  | using System.Drawing; | ||||||
| using System.Drawing.Imaging; | using System.Drawing.Imaging; | ||||||
| using System.Text.Json; | using System.Text.Json; | ||||||
| using View_by_Distance.Distance.Models; | using View_by_Distance.Distance.Models; | ||||||
| @ -62,7 +63,7 @@ public partial class DlibDotNet | |||||||
|         Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration); |         Models.Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration); | ||||||
|         _Log.Information(propertyConfiguration.RootDirectory); |         _Log.Information(propertyConfiguration.RootDirectory); | ||||||
|         Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false); |         Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false); | ||||||
|         Verify(configuration); |         OpenPossibleDuplicates(configuration); | ||||||
|         VerifyExtra(args, propertyConfiguration, configuration); |         VerifyExtra(args, propertyConfiguration, configuration); | ||||||
|         _Configuration = configuration; |         _Configuration = configuration; | ||||||
|         _Index = new(configuration); |         _Index = new(configuration); | ||||||
| @ -205,7 +206,7 @@ public partial class DlibDotNet | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void Verify(Models.Configuration configuration) |     private void OpenPossibleDuplicates(Models.Configuration configuration) | ||||||
|     { |     { | ||||||
|         if (!configuration.OutputResolutions.Any() || string.IsNullOrEmpty(configuration.OutputResolutions[0]) || !configuration.ValidResolutions.Contains(configuration.OutputResolutions[0])) |         if (!configuration.OutputResolutions.Any() || string.IsNullOrEmpty(configuration.OutputResolutions[0]) || !configuration.ValidResolutions.Contains(configuration.OutputResolutions[0])) | ||||||
|             throw new NullReferenceException($"{nameof(configuration.OutputResolutions)} must be _FileNameToCollection valid outputResolution!"); |             throw new NullReferenceException($"{nameof(configuration.OutputResolutions)} must be _FileNameToCollection valid outputResolution!"); | ||||||
| @ -289,13 +290,11 @@ public partial class DlibDotNet | |||||||
|     { |     { | ||||||
|         if (_Log is null) |         if (_Log is null) | ||||||
|             throw new NullReferenceException(nameof(_Log)); |             throw new NullReferenceException(nameof(_Log)); | ||||||
|         string original = "Original"; |  | ||||||
|         List<Shared.Models.Face> faces; |         List<Shared.Models.Face> faces; | ||||||
|         Shared.Models.Property property; |         Shared.Models.Property property; | ||||||
|         long ticks = DateTime.Now.Ticks; |         long ticks = DateTime.Now.Ticks; | ||||||
|         DateTime dateTime = DateTime.Now; |         DateTime dateTime = DateTime.Now; | ||||||
|         List<string> parseExceptions = new(); |         List<string> parseExceptions = new(); | ||||||
|         Dictionary<string, int[]> imageResizeKeyValuePairs; |  | ||||||
|         List<Tuple<string, DateTime>> subFileTuples = new(); |         List<Tuple<string, DateTime>> subFileTuples = new(); | ||||||
|         List<KeyValuePair<string, string>> metadataCollection; |         List<KeyValuePair<string, string>> metadataCollection; | ||||||
|         if (item.Property is not null && item.Property.Id is not null && !item.Any()) |         if (item.Property is not null && item.Property.Id is not null && !item.Any()) | ||||||
| @ -343,33 +342,21 @@ public partial class DlibDotNet | |||||||
|         (int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); |         (int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); | ||||||
|         if (_AppSettings.MaxDegreeOfParallelism < 2) |         if (_AppSettings.MaxDegreeOfParallelism < 2) | ||||||
|             ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection)); |             ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection)); | ||||||
|         imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, original, metadataCollection, item.Property, mappingFromItem); |         Dictionary<string, int[]> outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem); | ||||||
|         if (_AppSettings.MaxDegreeOfParallelism < 2) |         if (_AppSettings.MaxDegreeOfParallelism < 2) | ||||||
|             ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs)); |             ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs)); | ||||||
|         if (_Configuration.SaveResizedSubfiles) |         if (_Configuration.SaveResizedSubfiles) | ||||||
|         { |         { | ||||||
|             _Resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, original, imageResizeKeyValuePairs); |             _Resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize); | ||||||
|             if (_AppSettings.MaxDegreeOfParallelism < 2) |             if (_AppSettings.MaxDegreeOfParallelism < 2) | ||||||
|                 ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile)); |                 ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile)); | ||||||
|         } |         } | ||||||
|         else if (outputResolution == _Configuration.OutputResolutions[0] && false) |  | ||||||
|         { |  | ||||||
|             byte[] bytes = _Resize.GetResizedBytes(outputResolution, cResultsFullGroupDirectory, subFileTuples, item.Property, mappingFromItem, imageResizeKeyValuePairs); |  | ||||||
|             if (_AppSettings.MaxDegreeOfParallelism < 2) |  | ||||||
|                 ticks = LogDelta(ticks, nameof(C_Resize.GetResizedBytes)); |  | ||||||
|             string path = Path.Combine(resizedFileHolder.DirectoryName, resizedFileHolder.NameWithoutExtension); |  | ||||||
|             File.WriteAllBytes(path, bytes); |  | ||||||
|         } |  | ||||||
|         if (!mappingFromItem.ResizedFileHolder.Exists && !File.Exists(mappingFromItem.ResizedFileHolder.FullName)) |         if (!mappingFromItem.ResizedFileHolder.Exists && !File.Exists(mappingFromItem.ResizedFileHolder.FullName)) | ||||||
|             faces = new(); |             faces = new(); | ||||||
|         else if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution)) |         else if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution)) | ||||||
|             faces = new(); |             faces = new(); | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             int[] outputResolutionCollection = imageResizeKeyValuePairs[outputResolution]; |  | ||||||
|             int outputResolutionWidth = outputResolutionCollection[0]; |  | ||||||
|             int outputResolutionHeight = outputResolutionCollection[1]; |  | ||||||
|             int outputResolutionOrientation = outputResolutionCollection[2]; |  | ||||||
|             List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection; |             List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection; | ||||||
|             List<LocationContainer<MetadataExtractor.Directory>>? collection; |             List<LocationContainer<MetadataExtractor.Directory>>? collection; | ||||||
|             if (item.Property?.Id is null) |             if (item.Property?.Id is null) | ||||||
| @ -378,7 +365,7 @@ public partial class DlibDotNet | |||||||
|                 _ = idToMappedFaceFilesWithCollection.TryGetValue(item.Property.Id.Value, out collection); |                 _ = idToMappedFaceFilesWithCollection.TryGetValue(item.Property.Id.Value, out collection); | ||||||
|             if (!_FileNameToCollection.TryGetValue(mappingFromItem.RelativePath[1..], out mappingFromPhotoPrismCollection)) |             if (!_FileNameToCollection.TryGetValue(mappingFromItem.RelativePath[1..], out mappingFromPhotoPrismCollection)) | ||||||
|                 mappingFromPhotoPrismCollection = null; |                 mappingFromPhotoPrismCollection = null; | ||||||
|             faces = _Faces.GetFaces(dResultsFullGroupDirectory, subFileTuples, parseExceptions, property, mappingFromItem, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, collection, mappingFromPhotoPrismCollection); |             faces = _Faces.GetFaces(_Resize, outputResolution, dResultsFullGroupDirectory, subFileTuples, parseExceptions, property, mappingFromItem, outputResolutionToResize, collection, mappingFromPhotoPrismCollection); | ||||||
|             if (_AppSettings.MaxDegreeOfParallelism < 2) |             if (_AppSettings.MaxDegreeOfParallelism < 2) | ||||||
|                 ticks = LogDelta(ticks, nameof(D_Face.GetFaces)); |                 ticks = LogDelta(ticks, nameof(D_Face.GetFaces)); | ||||||
|             bool anyFacesSaved = _Faces.SaveFaces(dResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem, facesDirectory, faces); |             bool anyFacesSaved = _Faces.SaveFaces(dResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem, facesDirectory, faces); | ||||||
| @ -402,7 +389,7 @@ public partial class DlibDotNet | |||||||
|             imageFaceCollections[index] = faces; |             imageFaceCollections[index] = faces; | ||||||
|             propertyCollection[index] = property; |             propertyCollection[index] = property; | ||||||
|             metadataCollections[index] = metadataCollection; |             metadataCollections[index] = metadataCollection; | ||||||
|             resizeKeyValuePairs[index] = imageResizeKeyValuePairs; |             resizeKeyValuePairs[index] = outputResolutionToResize; | ||||||
|             propertyFileHolderCollection[index] = item.ImageFileHolder; |             propertyFileHolderCollection[index] = item.ImageFileHolder; | ||||||
|             sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l); |             sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l); | ||||||
|         } |         } | ||||||
| @ -991,35 +978,81 @@ public partial class DlibDotNet | |||||||
|             directories = new List<MetadataExtractor.Directory>(); |             directories = new List<MetadataExtractor.Directory>(); | ||||||
|         else |         else | ||||||
|             directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(file); |             directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(file); | ||||||
|  |         Rectangle? rectangle = Shared.Models.Stateless.Methods.ILocation.GetNormalizedRectangle(_Configuration.LocationDigits, normalizedRectangle.Value); | ||||||
|         lock (collection) |         lock (collection) | ||||||
|             collection.Add(new(fromDistanceContent, file, personKey, id.Value, normalizedRectangle.Value, directories, null, null)); |             collection.Add(new(fromDistanceContent, file, personKey, id.Value, normalizedRectangle.Value, directories, rectangle, null)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void Verify(List<LocationContainer<MetadataExtractor.Directory>> collection) |     private void OpenPossibleDuplicates(List<(long, int, string, double?)> duplicates) | ||||||
|     { |     { | ||||||
|         string key; |  | ||||||
|         int normalizedRectangle; |  | ||||||
|         string personKeyFormatted; |         string personKeyFormatted; | ||||||
|         Dictionary<string, int> distinct = new(); |         foreach ((long personKey, int id, string file, double? percent) in duplicates) | ||||||
|         List<(long, int, string)> duplicates = new(); |  | ||||||
|         foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in collection) |  | ||||||
|         { |         { | ||||||
|             key = string.Concat(locationContainer.PersonKey, locationContainer.Id); |             if (percent is null) | ||||||
|             if (distinct.TryGetValue(key, out normalizedRectangle)) |  | ||||||
|             { |  | ||||||
|                 if (normalizedRectangle == locationContainer.NormalizedRectangle) |  | ||||||
|                     continue; |  | ||||||
|                 duplicates.Add(new(locationContainer.PersonKey, locationContainer.Id, locationContainer.File)); |  | ||||||
|                 continue; |                 continue; | ||||||
|             } |  | ||||||
|             distinct.Add(key, locationContainer.NormalizedRectangle); |  | ||||||
|         } |  | ||||||
|         (); //Do they also intersect? |  | ||||||
|         foreach ((long personKey, int id, string file) in duplicates) |  | ||||||
|         { |  | ||||||
|             _ = Process.Start("explorer.exe", string.Concat("\"", Path.GetDirectoryName(file), "\"")); |             _ = Process.Start("explorer.exe", string.Concat("\"", Path.GetDirectoryName(file), "\"")); | ||||||
|             personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey); |             personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey); | ||||||
|         } |         } | ||||||
|  |         foreach ((long personKey, int id, string file, double? percent) in duplicates) | ||||||
|  |         { | ||||||
|  |             if (percent is not null && percent.Value == 0) | ||||||
|  |                 continue; | ||||||
|  |             _ = Process.Start("explorer.exe", string.Concat("\"", Path.GetDirectoryName(file), "\"")); | ||||||
|  |             personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey); | ||||||
|  |         } | ||||||
|  |         foreach ((long personKey, int id, string file, double? percent) in duplicates) | ||||||
|  |         { | ||||||
|  |             if (percent is not null && percent.Value > 0) | ||||||
|  |                 continue; | ||||||
|  |             _ = Process.Start("explorer.exe", string.Concat("\"", Path.GetDirectoryName(file), "\"")); | ||||||
|  |             personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personKey); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void LookForPossibleDuplicates(List<LocationContainer<MetadataExtractor.Directory>> collection) | ||||||
|  |     { | ||||||
|  |         string key; | ||||||
|  |         double? percent; | ||||||
|  |         Rectangle? rectangle; | ||||||
|  |         Rectangle intersectRectangle; | ||||||
|  |         (string File, int NormalizedRectangle) item; | ||||||
|  |         Dictionary<string, (string, int)> distinct = new(); | ||||||
|  |         List<(long, int, string, double?)> duplicates = new(); | ||||||
|  |         foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in collection) | ||||||
|  |         { | ||||||
|  |             key = string.Concat(locationContainer.PersonKey, locationContainer.Id); | ||||||
|  |             if (distinct.TryGetValue(key, out item)) | ||||||
|  |             { | ||||||
|  |                 if (item.NormalizedRectangle == locationContainer.NormalizedRectangle) | ||||||
|  |                     continue; | ||||||
|  |                 if (locationContainer.Rectangle is null) | ||||||
|  |                     percent = null; | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     rectangle = Shared.Models.Stateless.Methods.ILocation.GetNormalizedRectangle(_Configuration.LocationDigits, item.NormalizedRectangle); | ||||||
|  |                     if (locationContainer.Rectangle is null || rectangle is null) | ||||||
|  |                         percent = null; | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         intersectRectangle = Rectangle.Intersect(locationContainer.Rectangle.Value, rectangle.Value); | ||||||
|  |                         percent = intersectRectangle.Width * intersectRectangle.Height; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 if (!_Configuration.DeletePossibleDuplicates) | ||||||
|  |                     duplicates.Add(new(locationContainer.PersonKey, locationContainer.Id, locationContainer.File, percent)); | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     if (File.Exists(item.File)) | ||||||
|  |                         File.Delete(item.File); | ||||||
|  |                     if (File.Exists(locationContainer.File)) | ||||||
|  |                         File.Delete(locationContainer.File); | ||||||
|  |                 } | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             distinct.Add(key, new(locationContainer.File, locationContainer.NormalizedRectangle)); | ||||||
|  |         } | ||||||
|  |         if (duplicates.Any() && _IsEnvironment.Development) | ||||||
|  |             OpenPossibleDuplicates(duplicates); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private List<LocationContainer<MetadataExtractor.Directory>> GetCollection(long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) |     private List<LocationContainer<MetadataExtractor.Directory>> GetCollection(long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) | ||||||
| @ -1052,7 +1085,7 @@ public partial class DlibDotNet | |||||||
|                 ParallelFor(eDistanceContentDirectory, results, collection[i].PersonKey, collection[i].File); |                 ParallelFor(eDistanceContentDirectory, results, collection[i].PersonKey, collection[i].File); | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|         Verify(results); |         LookForPossibleDuplicates(results); | ||||||
|         return results; |         return results; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ public class Configuration | |||||||
|     [Display(Name = "Check D Face and Up Dates"), Required] public bool? CheckDFaceAndUpWriteDates { get; set; } |     [Display(Name = "Check D Face and Up Dates"), Required] public bool? CheckDFaceAndUpWriteDates { get; set; } | ||||||
|     [Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; } |     [Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; } | ||||||
|     [Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; } |     [Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; } | ||||||
|  |     [Display(Name = "Delete Possible Duplicates"), Required] public bool? DeletePossibleDuplicates { get; set; } | ||||||
|     [Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; } |     [Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; } | ||||||
|     [Display(Name = "Distance Move Unable to Match by 1 Tick"), Required] public bool? DistanceMoveUnableToMatch { get; set; } |     [Display(Name = "Distance Move Unable to Match by 1 Tick"), Required] public bool? DistanceMoveUnableToMatch { get; set; } | ||||||
|     [Display(Name = "Distance Pixel Distance Tolerance"), Required] public int? DistancePixelDistanceTolerance { get; set; } |     [Display(Name = "Distance Pixel Distance Tolerance"), Required] public int? DistancePixelDistanceTolerance { get; set; } | ||||||
| @ -99,6 +100,8 @@ public class Configuration | |||||||
|             throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults)); |             throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults)); | ||||||
|         if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null) |         if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null) | ||||||
|             throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection)); |             throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection)); | ||||||
|  |         if (configuration.DeletePossibleDuplicates is null) | ||||||
|  |             throw new NullReferenceException(nameof(configuration.DeletePossibleDuplicates)); | ||||||
|         if (configuration.DistanceFactor is null) |         if (configuration.DistanceFactor is null) | ||||||
|             throw new NullReferenceException(nameof(configuration.DistanceFactor)); |             throw new NullReferenceException(nameof(configuration.DistanceFactor)); | ||||||
|         if (configuration.DistanceMoveUnableToMatch is null) |         if (configuration.DistanceMoveUnableToMatch is null) | ||||||
| @ -215,6 +218,7 @@ public class Configuration | |||||||
|                      configuration.CheckDFaceAndUpWriteDates.Value, |                      configuration.CheckDFaceAndUpWriteDates.Value, | ||||||
|                      configuration.CheckJsonForDistanceResults.Value, |                      configuration.CheckJsonForDistanceResults.Value, | ||||||
|                      configuration.CrossDirectoryMaxItemsInDistanceCollection.Value, |                      configuration.CrossDirectoryMaxItemsInDistanceCollection.Value, | ||||||
|  |                      configuration.DeletePossibleDuplicates.Value, | ||||||
|                      configuration.DistanceFactor.Value, |                      configuration.DistanceFactor.Value, | ||||||
|                      configuration.DistanceMoveUnableToMatch.Value, |                      configuration.DistanceMoveUnableToMatch.Value, | ||||||
|                      configuration.DistancePixelDistanceTolerance.Value, |                      configuration.DistancePixelDistanceTolerance.Value, | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ public class Configuration | |||||||
|     public bool CheckDFaceAndUpWriteDates { init; get; } |     public bool CheckDFaceAndUpWriteDates { init; get; } | ||||||
|     public bool CheckJsonForDistanceResults { init; get; } |     public bool CheckJsonForDistanceResults { init; get; } | ||||||
|     public int CrossDirectoryMaxItemsInDistanceCollection { init; get; } |     public int CrossDirectoryMaxItemsInDistanceCollection { init; get; } | ||||||
|  |     public bool DeletePossibleDuplicates { get; internal set; } | ||||||
|     public int DistanceFactor { init; get; } |     public int DistanceFactor { init; get; } | ||||||
|     public bool DistanceMoveUnableToMatch { init; get; } |     public bool DistanceMoveUnableToMatch { init; get; } | ||||||
|     public int DistancePixelDistanceTolerance { init; get; } |     public int DistancePixelDistanceTolerance { init; get; } | ||||||
| @ -81,6 +82,7 @@ public class Configuration | |||||||
|                          bool checkDFaceAndUpWriteDates, |                          bool checkDFaceAndUpWriteDates, | ||||||
|                          bool checkJsonForDistanceResults, |                          bool checkJsonForDistanceResults, | ||||||
|                          int crossDirectoryMaxItemsInDistanceCollection, |                          int crossDirectoryMaxItemsInDistanceCollection, | ||||||
|  |                          bool deletePossibleDuplicates, | ||||||
|                          int distanceFactor, |                          int distanceFactor, | ||||||
|                          bool distanceMoveUnableToMatch, |                          bool distanceMoveUnableToMatch, | ||||||
|                          int distancePixelDistanceTolerance, |                          int distancePixelDistanceTolerance, | ||||||
| @ -149,6 +151,7 @@ public class Configuration | |||||||
|         CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates; |         CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates; | ||||||
|         CheckJsonForDistanceResults = checkJsonForDistanceResults; |         CheckJsonForDistanceResults = checkJsonForDistanceResults; | ||||||
|         CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection; |         CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection; | ||||||
|  |         DeletePossibleDuplicates = deletePossibleDuplicates; | ||||||
|         DistanceFactor = distanceFactor; |         DistanceFactor = distanceFactor; | ||||||
|         DistanceMoveUnableToMatch = distanceMoveUnableToMatch; |         DistanceMoveUnableToMatch = distanceMoveUnableToMatch; | ||||||
|         DistancePixelDistanceTolerance = distancePixelDistanceTolerance; |         DistancePixelDistanceTolerance = distancePixelDistanceTolerance; | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ | |||||||
|   }, |   }, | ||||||
|   "Windows": { |   "Windows": { | ||||||
|     "Configuration": { |     "Configuration": { | ||||||
|  |       "DeletePossibleDuplicates": false, | ||||||
|       "DistanceRenameToMatch": true, |       "DistanceRenameToMatch": true, | ||||||
|       "DistanceMoveUnableToMatch": true, |       "DistanceMoveUnableToMatch": true, | ||||||
|       "PersonCharacters": "!#]^_`~+", |       "PersonCharacters": "!#]^_`~+", | ||||||
| @ -32,13 +33,13 @@ | |||||||
|         "Julie" |         "Julie" | ||||||
|       ], |       ], | ||||||
|       "LoadOrCreateThenSaveDistanceResultsForOutputResolutions": [ |       "LoadOrCreateThenSaveDistanceResultsForOutputResolutions": [ | ||||||
|         "7680 x 4320" |         "Original" | ||||||
|       ], |       ], | ||||||
|       "LoadOrCreateThenSaveImageFacesResultsForOutputResolutions": [ |       "LoadOrCreateThenSaveImageFacesResultsForOutputResolutions": [ | ||||||
|         "7680 x 4320" |         "Original" | ||||||
|       ], |       ], | ||||||
|       "OutputResolutions": [ |       "OutputResolutions": [ | ||||||
|         "7680 x 4320" |         "Original" | ||||||
|       ], |       ], | ||||||
|       "PropertyContentCollectionFiles": [], |       "PropertyContentCollectionFiles": [], | ||||||
|       "RangeDaysDeltaTolerance": [ |       "RangeDaysDeltaTolerance": [ | ||||||
| @ -62,13 +63,13 @@ | |||||||
|         100 |         100 | ||||||
|       ], |       ], | ||||||
|       "SaveFaceDistancesForOutputResolutions": [ |       "SaveFaceDistancesForOutputResolutions": [ | ||||||
|         "7680 x 4320" |         "Original" | ||||||
|       ], |       ], | ||||||
|       "SaveFaceLandmarkForOutputResolutions": [], |       "SaveFaceLandmarkForOutputResolutions": [], | ||||||
|       "SaveFilteredOriginalImagesFromJLinksForOutputResolutions": [], |       "SaveFilteredOriginalImagesFromJLinksForOutputResolutions": [], | ||||||
|       "SaveMappedForOutputResolutions": [], |       "SaveMappedForOutputResolutions": [], | ||||||
|       "SaveRandomForOutputResolutions": [ |       "SaveRandomForOutputResolutions": [ | ||||||
|         "7680 x 4320" |         "Original" | ||||||
|       ], |       ], | ||||||
|       "SaveShortcutsForOutputResolutions": [], |       "SaveShortcutsForOutputResolutions": [], | ||||||
|       "IgnoreRelativePaths": [ |       "IgnoreRelativePaths": [ | ||||||
|  | |||||||
| @ -54,6 +54,7 @@ | |||||||
|       "CheckJsonForDistanceResults": false, |       "CheckJsonForDistanceResults": false, | ||||||
|       "CrossDirectoryMaxItemsInDistanceCollection": 7, |       "CrossDirectoryMaxItemsInDistanceCollection": 7, | ||||||
|       "DateGroup": "2022-12-30", |       "DateGroup": "2022-12-30", | ||||||
|  |       "DeletePossibleDuplicates": false, | ||||||
|       "DistanceFactor": 8, |       "DistanceFactor": 8, | ||||||
|       "DistanceMoveUnableToMatch": false, |       "DistanceMoveUnableToMatch": false, | ||||||
|       "DistancePixelDistanceTolerance": 1, |       "DistancePixelDistanceTolerance": 1, | ||||||
| @ -200,6 +201,7 @@ | |||||||
|         ".TIFF" |         ".TIFF" | ||||||
|       ], |       ], | ||||||
|       "ValidResolutions": [ |       "ValidResolutions": [ | ||||||
|  |         "Original", | ||||||
|         "176 x 176", |         "176 x 176", | ||||||
|         "256 x 256", |         "256 x 256", | ||||||
|         "353 x 353", |         "353 x 353", | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ namespace View_by_Distance.Resize.Models; | |||||||
| /// <summary> | /// <summary> | ||||||
| // Dictionary<string, int[]> | // Dictionary<string, int[]> | ||||||
| /// </summary> | /// </summary> | ||||||
| public class C_Resize | public class C_Resize : Shared.Models.Methods.IResize | ||||||
| { | { | ||||||
|  |  | ||||||
|     public List<string> AngleBracketCollection { get; } |     public List<string> AngleBracketCollection { get; } | ||||||
| @ -22,6 +22,7 @@ public class C_Resize | |||||||
|     protected readonly string _FileNameExtension; |     protected readonly string _FileNameExtension; | ||||||
|     public string FileNameExtension => _FileNameExtension; |     public string FileNameExtension => _FileNameExtension; | ||||||
|  |  | ||||||
|  |     private readonly string _Original; | ||||||
|     private readonly int _TempResolutionWidth; |     private readonly int _TempResolutionWidth; | ||||||
|     private readonly int _TempResolutionHeight; |     private readonly int _TempResolutionHeight; | ||||||
|     private readonly string[] _ValidResolutions; |     private readonly string[] _ValidResolutions; | ||||||
| @ -39,6 +40,7 @@ public class C_Resize | |||||||
|  |  | ||||||
|     public C_Resize(bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) |     public C_Resize(bool forceResizeLastWriteTimeToCreationTime, bool overrideForResizeImages, bool propertiesChangedForResize, string[] validResolutions, ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) | ||||||
|     { |     { | ||||||
|  |         _Original = "Original"; | ||||||
|         _TempResolutionWidth = 3; |         _TempResolutionWidth = 3; | ||||||
|         _TempResolutionHeight = 4; |         _TempResolutionHeight = 4; | ||||||
|         _OutputResolutionWidthIndex = 0; |         _OutputResolutionWidthIndex = 0; | ||||||
| @ -175,9 +177,8 @@ public class C_Resize | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private byte[] SaveResizedSubfile3(MappingFromItem mappingFromItem, int[] resize, bool returnAndDoNotWrite, byte[] bytes) |     private void SaveResizedSubfile3(MappingFromItem mappingFromItem, int[] resize, byte[] bytes) | ||||||
|     { |     { | ||||||
|         byte[] results; |  | ||||||
|         Bitmap bitmap; |         Bitmap bitmap; | ||||||
|         int outputResolutionWidth = resize[_OutputResolutionWidthIndex]; |         int outputResolutionWidth = resize[_OutputResolutionWidthIndex]; | ||||||
|         using Bitmap temp = new(mappingFromItem.ImageFileHolder.FullName, useIcm: false); |         using Bitmap temp = new(mappingFromItem.ImageFileHolder.FullName, useIcm: false); | ||||||
| @ -215,21 +216,13 @@ public class C_Resize | |||||||
|             default: |             default: | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|         if (returnAndDoNotWrite) |         CopyPropertyItems(bytes, propertyItems, bitmap); | ||||||
|             results = GetBitmapData(bitmap); |         bitmap.Save(mappingFromItem.ResizedFileHolder.FullName, _ImageCodecInfo, _EncoderParameters); | ||||||
|         else |  | ||||||
|         { |  | ||||||
|             results = Array.Empty<byte>(); |  | ||||||
|             CopyPropertyItems(bytes, propertyItems, bitmap); |  | ||||||
|             bitmap.Save(mappingFromItem.ResizedFileHolder.FullName, _ImageCodecInfo, _EncoderParameters); |  | ||||||
|         } |  | ||||||
|         bitmap.Dispose(); |         bitmap.Dispose(); | ||||||
|         return results; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private byte[] SaveResizedSubfile5(MappingFromItem mappingFromItem, int[] resize, bool returnAndDoNotWrite, byte[] bytes) |     private void SaveResizedSubfile5(MappingFromItem mappingFromItem, int[] resize, byte[] bytes) | ||||||
|     { |     { | ||||||
|         byte[] results; |  | ||||||
|         Bitmap bitmap; |         Bitmap bitmap; | ||||||
|         using Bitmap temp = new(mappingFromItem.ImageFileHolder.FullName, useIcm: false); |         using Bitmap temp = new(mappingFromItem.ImageFileHolder.FullName, useIcm: false); | ||||||
|         PropertyItem[] propertyItems = temp.PropertyItems; |         PropertyItem[] propertyItems = temp.PropertyItems; | ||||||
| @ -279,24 +272,16 @@ public class C_Resize | |||||||
|         { |         { | ||||||
|             using (Graphics graphics = Graphics.FromImage(preRotated)) |             using (Graphics graphics = Graphics.FromImage(preRotated)) | ||||||
|                 graphics.DrawImage(bitmap, new Rectangle(0, 0, outputResolutionWidth, outputResolutionHeight), rectangle, GraphicsUnit.Pixel); |                 graphics.DrawImage(bitmap, new Rectangle(0, 0, outputResolutionWidth, outputResolutionHeight), rectangle, GraphicsUnit.Pixel); | ||||||
|             if (returnAndDoNotWrite) |             CopyPropertyItems(bytes, propertyItems, bitmap); | ||||||
|                 results = GetBitmapData(bitmap); |             bitmap.Save(mappingFromItem.ResizedFileHolder.FullName, _ImageCodecInfo, _EncoderParameters); | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 results = Array.Empty<byte>(); |  | ||||||
|                 CopyPropertyItems(bytes, propertyItems, bitmap); |  | ||||||
|                 bitmap.Save(mappingFromItem.ResizedFileHolder.FullName, _ImageCodecInfo, _EncoderParameters); |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|         bitmap.Dispose(); |         bitmap.Dispose(); | ||||||
|         return results; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| #pragma warning restore CA1416 | #pragma warning restore CA1416 | ||||||
|  |  | ||||||
|     private byte[] SaveResizedSubfile(Shared.Models.Property property, MappingFromItem mappingFromItem, int[] resize, bool returnAndDoNotWrite) |     private void SaveResizedSubfile(Shared.Models.Property property, MappingFromItem mappingFromItem, int[] resize) | ||||||
|     { |     { | ||||||
|         byte[] results; |  | ||||||
|         // string subFile, Shared.Models.Property property, Shared.Models.FileHolder? fileHolder |         // string subFile, Shared.Models.Property property, Shared.Models.FileHolder? fileHolder | ||||||
|         string dateTimeFormat = Shared.Models.Stateless.Methods.IProperty.DateTimeFormat(); |         string dateTimeFormat = Shared.Models.Stateless.Methods.IProperty.DateTimeFormat(); | ||||||
|         DateTime dateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property); |         DateTime dateTime = Shared.Models.Stateless.Methods.IProperty.GetMinimumDateTime(property); | ||||||
| @ -305,43 +290,37 @@ public class C_Resize | |||||||
|         if (_ASCIIEncoding.GetString(bytes, 0, bytes.Length) != dateTimeValue) |         if (_ASCIIEncoding.GetString(bytes, 0, bytes.Length) != dateTimeValue) | ||||||
|             throw new Exception(); |             throw new Exception(); | ||||||
|         if (resize.Length == 3) |         if (resize.Length == 3) | ||||||
|             results = SaveResizedSubfile3(mappingFromItem, resize, returnAndDoNotWrite, bytes); |             SaveResizedSubfile3(mappingFromItem, resize, bytes); | ||||||
|         else if (resize.Length == 5) |         else if (resize.Length == 5) | ||||||
|             results = SaveResizedSubfile5(mappingFromItem, resize, returnAndDoNotWrite, bytes); |             SaveResizedSubfile5(mappingFromItem, resize, bytes); | ||||||
|         else |         else | ||||||
|             throw new Exception(); |             throw new Exception(); | ||||||
|         return results; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public byte[] GetResizedBytes(string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> imageResizeKeyValuePairs) |     (int, int, int) Shared.Models.Methods.IResize.Get(string outputResolution, Dictionary<string, int[]> outputResolutionToResize) | ||||||
|     { |     { | ||||||
|         byte[] results; |         int[] outputResolutionCollection = outputResolutionToResize[outputResolution]; | ||||||
|         if (!imageResizeKeyValuePairs.ContainsKey(outputResolution)) |         int outputResolutionWidth = outputResolutionCollection[0]; | ||||||
|             throw new Exception(); |         int outputResolutionHeight = outputResolutionCollection[1]; | ||||||
|         int[] resize = imageResizeKeyValuePairs[outputResolution]; |         int outputResolutionOrientation = outputResolutionCollection[2]; | ||||||
|         int outputResolutionWidth = resize[_OutputResolutionWidthIndex]; |         return new(outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation); | ||||||
|         int outputResolutionHeight = resize[_OutputResolutionHeightIndex]; |  | ||||||
|         int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex]; |  | ||||||
|         results = SaveResizedSubfile(property, mappingFromItem, resize, returnAndDoNotWrite: true); |  | ||||||
|         subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now)); |  | ||||||
|         return results; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, string original, Dictionary<string, int[]> imageResizeKeyValuePairs) |     public void SaveResizedSubfile(Property.Models.Configuration configuration, string outputResolution, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, Item item, Shared.Models.Property property, MappingFromItem mappingFromItem, Dictionary<string, int[]> outputResolutionToResize) | ||||||
|     { |     { | ||||||
|         if (mappingFromItem.ResizedFileHolder is null) |         if (mappingFromItem.ResizedFileHolder is null) | ||||||
|             throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder)); |             throw new NullReferenceException(nameof(mappingFromItem.ResizedFileHolder)); | ||||||
|         if (!imageResizeKeyValuePairs.ContainsKey(original)) |         if (!outputResolutionToResize.ContainsKey(_Original)) | ||||||
|             throw new Exception(); |             throw new Exception(); | ||||||
|         if (!imageResizeKeyValuePairs.ContainsKey(outputResolution)) |         if (!outputResolutionToResize.ContainsKey(outputResolution)) | ||||||
|             throw new Exception(); |             throw new Exception(); | ||||||
|         FileInfo fileInfo = new(mappingFromItem.ResizedFileHolder.FullName); |         FileInfo fileInfo = new(mappingFromItem.ResizedFileHolder.FullName); | ||||||
|         bool check = false; |         bool check = false; | ||||||
|         int[] resize = imageResizeKeyValuePairs[outputResolution]; |         int[] resize = outputResolutionToResize[outputResolution]; | ||||||
|         int outputResolutionWidth = resize[_OutputResolutionWidthIndex]; |         int outputResolutionWidth = resize[_OutputResolutionWidthIndex]; | ||||||
|         int outputResolutionHeight = resize[_OutputResolutionHeightIndex]; |         int outputResolutionHeight = resize[_OutputResolutionHeightIndex]; | ||||||
|         int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex]; |         int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex]; | ||||||
|         int[] originalCollection = imageResizeKeyValuePairs[original]; |         int[] originalCollection = outputResolutionToResize[_Original]; | ||||||
|         string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata), nameof(C_Resize) }; |         string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata), nameof(C_Resize) }; | ||||||
|         List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); |         List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); | ||||||
|         if (_OverrideForResizeImages) |         if (_OverrideForResizeImages) | ||||||
| @ -367,7 +346,7 @@ public class C_Resize | |||||||
|                 check = true; |                 check = true; | ||||||
|             if (check) |             if (check) | ||||||
|             { |             { | ||||||
|                 _ = SaveResizedSubfile(property, mappingFromItem, resize, returnAndDoNotWrite: false); |                 SaveResizedSubfile(property, mappingFromItem, resize); | ||||||
|                 item.SetResizedFileHolder(_FileNameExtension, Shared.Models.Stateless.Methods.IFileHolder.Refresh(mappingFromItem.ResizedFileHolder)); |                 item.SetResizedFileHolder(_FileNameExtension, Shared.Models.Stateless.Methods.IFileHolder.Refresh(mappingFromItem.ResizedFileHolder)); | ||||||
|                 subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now)); |                 subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now)); | ||||||
|             } |             } | ||||||
| @ -395,7 +374,7 @@ public class C_Resize | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private Dictionary<string, int[]> GetImageResizes(Shared.Models.Property property, List<KeyValuePair<string, string>> metadataCollection, string original) |     private Dictionary<string, int[]> GetImageResizes(Shared.Models.Property property, List<KeyValuePair<string, string>> metadataCollection) | ||||||
|     { |     { | ||||||
|         Dictionary<string, int[]> results = new(); |         Dictionary<string, int[]> results = new(); | ||||||
|         int[] desired; |         int[] desired; | ||||||
| @ -412,12 +391,21 @@ public class C_Resize | |||||||
|             orientation = GetOrientation(metadataCollection); |             orientation = GetOrientation(metadataCollection); | ||||||
|         checkWidth = property.Width.Value; |         checkWidth = property.Width.Value; | ||||||
|         checkHeight = property.Height.Value; |         checkHeight = property.Height.Value; | ||||||
|         results.Add(original, new int[] { checkWidth, checkHeight, orientation }); |         if (!_ValidResolutions.Contains(_Original)) | ||||||
|  |             results.Add(_Original, new int[] { checkWidth, checkHeight, orientation }); | ||||||
|         foreach (string validResolution in _ValidResolutions) |         foreach (string validResolution in _ValidResolutions) | ||||||
|         { |         { | ||||||
|             desired = GetCollection(validResolution); |             if (validResolution == _Original) | ||||||
|             desiredWidth = desired[0]; |             { | ||||||
|             desiredHeight = desired[1]; |                 desiredWidth = checkWidth; | ||||||
|  |                 desiredHeight = checkHeight; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 desired = GetCollection(validResolution); | ||||||
|  |                 desiredWidth = desired[0]; | ||||||
|  |                 desiredHeight = desired[1]; | ||||||
|  |             } | ||||||
|             if (checkWidth <= desiredWidth && checkHeight <= desiredHeight) |             if (checkWidth <= desiredWidth && checkHeight <= desiredHeight) | ||||||
|                 results.Add(validResolution, new int[] { checkWidth, checkHeight, orientation }); |                 results.Add(validResolution, new int[] { checkWidth, checkHeight, orientation }); | ||||||
|             else |             else | ||||||
| @ -447,9 +435,9 @@ public class C_Resize | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Dictionary<string, int[]> GetResizeKeyValuePairs(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string original, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem) |     public Dictionary<string, int[]> GetResizeKeyValuePairs(Property.Models.Configuration configuration, string cResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, List<KeyValuePair<string, string>> metadataCollection, Shared.Models.Property property, MappingFromItem mappingFromItem) | ||||||
|     { |     { | ||||||
|         Dictionary<string, int[]> results; |         Dictionary<string, int[]>? results; | ||||||
|         string json; |         string json; | ||||||
|         string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata) }; |         string[] changesFrom = new string[] { nameof(Property.Models.A_Property), nameof(B_Metadata) }; | ||||||
|         List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); |         List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList(); | ||||||
| @ -466,40 +454,32 @@ public class C_Resize | |||||||
|             fileInfo.Refresh(); |             fileInfo.Refresh(); | ||||||
|         } |         } | ||||||
|         if (_PropertiesChangedForResize) |         if (_PropertiesChangedForResize) | ||||||
|             results = new(); |             results = null; | ||||||
|         else if (!fileInfo.Exists) |         else if (!fileInfo.Exists) | ||||||
|             results = new(); |             results = null; | ||||||
|         else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old")) |         else if (!fileInfo.FullName.EndsWith(".json") && !fileInfo.FullName.EndsWith(".old")) | ||||||
|             throw new ArgumentException("must be a *.json file"); |             throw new ArgumentException("must be a *.json file"); | ||||||
|         else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime) |         else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime) | ||||||
|             results = new(); |             results = null; | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             json = File.ReadAllText(fileInfo.FullName); |             json = File.ReadAllText(fileInfo.FullName); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 Dictionary<string, int[]>? keyValuePairs; |                 results = JsonSerializer.Deserialize<Dictionary<string, int[]>>(json); | ||||||
|                 keyValuePairs = JsonSerializer.Deserialize<Dictionary<string, int[]>>(json); |                 if (results is null) | ||||||
|                 if (keyValuePairs is null) |  | ||||||
|                     throw new Exception(); |                     throw new Exception(); | ||||||
|                 results = keyValuePairs; |  | ||||||
|                 if ((from l in results where l.Value[0] == l.Value[1] select true).Any()) |  | ||||||
|                 { |  | ||||||
|                     results = GetImageResizes(property, metadataCollection, original); |  | ||||||
|                     if (!(from l in results where l.Value[0] == l.Value[1] select true).Any()) |  | ||||||
|                         throw new Exception("Was square!"); |  | ||||||
|                 } |  | ||||||
|                 subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), fileInfo.LastWriteTime)); |                 subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), fileInfo.LastWriteTime)); | ||||||
|             } |             } | ||||||
|             catch (Exception) |             catch (Exception) | ||||||
|             { |             { | ||||||
|                 results = new(); |                 results = null; | ||||||
|                 parseExceptions.Add(nameof(C_Resize)); |                 parseExceptions.Add(nameof(C_Resize)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (results is null || !results.Any()) |         if (results is null) | ||||||
|         { |         { | ||||||
|             results = GetImageResizes(property, metadataCollection, original); |             results = GetImageResizes(property, metadataCollection); | ||||||
|             json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions); |             json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions); | ||||||
|             bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime; |             bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime; | ||||||
|             DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max(); |             DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max(); | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								Shared/Models/Methods/IResize.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Shared/Models/Methods/IResize.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | namespace View_by_Distance.Shared.Models.Methods; | ||||||
|  |  | ||||||
|  | public interface IResize | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     (int, int, int) Get(string outputResolution, Dictionary<string, int[]> outputResolutionToResize); | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -30,12 +30,17 @@ public interface ILocation | |||||||
|     static List<Models.Location> GetLocations<T>(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces, List<LocationContainer<T>> containers) => |     static List<Models.Location> GetLocations<T>(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces, List<LocationContainer<T>> containers) => | ||||||
|         Location.GetLocations(mappingFromPhotoPrismCollection, faces, containers); |         Location.GetLocations(mappingFromPhotoPrismCollection, faces, containers); | ||||||
|  |  | ||||||
|  |     Rectangle? TestStatic_GetNormalizedRectangle(int locationDigits, int normalizedRectangle) => | ||||||
|  |         GetNormalizedRectangle(locationDigits, normalizedRectangle); | ||||||
|  |     static Rectangle? GetNormalizedRectangle(int locationDigits, int normalizedRectangle) => | ||||||
|  |         Location.GetNormalizedRectangle(locationDigits, normalizedRectangle.ToString()); | ||||||
|  |  | ||||||
|     Rectangle? TestStatic_GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) => |     Rectangle? TestStatic_GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) => | ||||||
|         GetRectangle(checkRectangle, locationDigits, locationFactor, normalizedRectangle, outputResolution, useOldWay); |         GetRectangle(checkRectangle, locationDigits, locationFactor, normalizedRectangle, outputResolution, useOldWay); | ||||||
|     static Rectangle? GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) => |     static Rectangle? GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) => | ||||||
|         Location.GetRectangle(checkRectangle, OutputResolution.Get(outputResolution).Height, locationDigits, locationFactor, normalizedRectangle.ToString(), OutputResolution.Get(outputResolution).Width, useOldWay); |         Location.GetRectangle(checkRectangle, OutputResolution.Get(outputResolution).Height, locationDigits, locationFactor, normalizedRectangle.ToString(), OutputResolution.Get(outputResolution).Width, useOldWay); | ||||||
|  |  | ||||||
|     Rectangle? TestStatic_GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) => |     Rectangle? TestStatic_GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) => | ||||||
|  |  | ||||||
|         GetRectangle(height, locationDigits, locationFactor, normalizedRectangle, outputResolutionHeight, outputResolutionWidth, width); |         GetRectangle(height, locationDigits, locationFactor, normalizedRectangle, outputResolutionHeight, outputResolutionWidth, width); | ||||||
|     static Rectangle? GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) => |     static Rectangle? GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) => | ||||||
|         Location.GetRectangle(height, locationDigits, locationFactor, normalizedRectangle.ToString(), outputResolutionHeight, outputResolutionWidth, width); |         Location.GetRectangle(height, locationDigits, locationFactor, normalizedRectangle.ToString(), outputResolutionHeight, outputResolutionWidth, width); | ||||||
|  | |||||||
| @ -140,7 +140,7 @@ internal abstract class Location | |||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static Rectangle? GetRectangle(int locationDigits, int height, string normalizedRectangle, int width) |     internal static Rectangle? GetNormalizedRectangle(int locationDigits, string normalizedRectangle) | ||||||
|     { |     { | ||||||
|         Rectangle? result; |         Rectangle? result; | ||||||
|         int length = (locationDigits - 1) / 4; |         int length = (locationDigits - 1) / 4; | ||||||
| @ -159,10 +159,21 @@ internal abstract class Location | |||||||
|             if (!int.TryParse(segments[1], out int xNormalized) || !int.TryParse(segments[2], out int yNormalized) || !int.TryParse(segments[3], out int wNormalized) || !int.TryParse(segments[4], out int hNormalized)) |             if (!int.TryParse(segments[1], out int xNormalized) || !int.TryParse(segments[2], out int yNormalized) || !int.TryParse(segments[3], out int wNormalized) || !int.TryParse(segments[4], out int hNormalized)) | ||||||
|                 result = null; |                 result = null; | ||||||
|             else |             else | ||||||
|             { |                 result = new(xNormalized, yNormalized, wNormalized, hNormalized); | ||||||
|                 decimal factor = 100; |         } | ||||||
|                 result = new((int)(xNormalized / factor * width), (int)(yNormalized / factor * height), (int)(wNormalized / factor * width), (int)(hNormalized / factor * height)); |         return result; | ||||||
|             } |     } | ||||||
|  |  | ||||||
|  |     private static Rectangle? GetRectangle(int locationDigits, int height, string normalizedRectangle, int width) | ||||||
|  |     { | ||||||
|  |         Rectangle? result; | ||||||
|  |         Rectangle? rectangle = GetNormalizedRectangle(locationDigits, normalizedRectangle); | ||||||
|  |         if (rectangle is null) | ||||||
|  |             result = null; | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             decimal factor = 100; | ||||||
|  |             result = new((int)(rectangle.Value.X / factor * width), (int)(rectangle.Value.Y / factor * height), (int)(rectangle.Value.Width / factor * width), (int)(rectangle.Value.Height / factor * height)); | ||||||
|         } |         } | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -101,14 +101,13 @@ public class UnitTestResize | |||||||
|         Item item; |         Item item; | ||||||
|         bool reverse = false; |         bool reverse = false; | ||||||
|         FileHolder resizedFileHolder; |         FileHolder resizedFileHolder; | ||||||
|         string original = "Original"; |  | ||||||
|         string aResultsFullGroupDirectory; |         string aResultsFullGroupDirectory; | ||||||
|         string bResultsFullGroupDirectory; |         string bResultsFullGroupDirectory; | ||||||
|         string cResultsFullGroupDirectory; |         string cResultsFullGroupDirectory; | ||||||
|         List<string> parseExceptions = new(); |         List<string> parseExceptions = new(); | ||||||
|         bool isValidImageFormatExtension = true; |         bool isValidImageFormatExtension = true; | ||||||
|         Shared.Models.Property? property = null; |         Shared.Models.Property? property = null; | ||||||
|         Dictionary<string, int[]> imageResizeKeyValuePairs; |         Dictionary<string, int[]> outputResolutionToResize; | ||||||
|         List<Tuple<string, DateTime>> subFileTuples = new(); |         List<Tuple<string, DateTime>> subFileTuples = new(); | ||||||
|         List<KeyValuePair<string, string>> metadataCollection; |         List<KeyValuePair<string, string>> metadataCollection; | ||||||
|         int length = _PropertyConfiguration.RootDirectory.Length; |         int length = _PropertyConfiguration.RootDirectory.Length; | ||||||
| @ -148,9 +147,9 @@ public class UnitTestResize | |||||||
|         item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder); |         item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder); | ||||||
|         MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item); |         MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item); | ||||||
|         (int _, metadataCollection) = metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); |         (int _, metadataCollection) = metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); | ||||||
|         imageResizeKeyValuePairs = resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, original, metadataCollection, item.Property, mappingFromItem); |         outputResolutionToResize = resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem); | ||||||
|         Assert.IsNotNull(mappingFromItem.ResizedFileHolder); |         Assert.IsNotNull(mappingFromItem.ResizedFileHolder); | ||||||
|         resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, original, imageResizeKeyValuePairs); |         resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @ -175,7 +175,6 @@ public class UnitTestFace | |||||||
|         string sourceDirectoryName = "zzz Portrait Innovations Files 2007"; |         string sourceDirectoryName = "zzz Portrait Innovations Files 2007"; | ||||||
|         Item item; |         Item item; | ||||||
|         bool reverse = false; |         bool reverse = false; | ||||||
|         string original = "Original"; |  | ||||||
|         FileHolder resizedFileHolder; |         FileHolder resizedFileHolder; | ||||||
|         string aResultsFullGroupDirectory; |         string aResultsFullGroupDirectory; | ||||||
|         string bResultsFullGroupDirectory; |         string bResultsFullGroupDirectory; | ||||||
| @ -183,7 +182,7 @@ public class UnitTestFace | |||||||
|         List<string> parseExceptions = new(); |         List<string> parseExceptions = new(); | ||||||
|         bool isValidImageFormatExtension = true; |         bool isValidImageFormatExtension = true; | ||||||
|         Shared.Models.Property? property = null; |         Shared.Models.Property? property = null; | ||||||
|         Dictionary<string, int[]> imageResizeKeyValuePairs; |         Dictionary<string, int[]> outputResolutionToResize; | ||||||
|         List<Tuple<string, DateTime>> subFileTuples = new(); |         List<Tuple<string, DateTime>> subFileTuples = new(); | ||||||
|         List<KeyValuePair<string, string>> metadataCollection; |         List<KeyValuePair<string, string>> metadataCollection; | ||||||
|         int length = _PropertyConfiguration.RootDirectory.Length; |         int length = _PropertyConfiguration.RootDirectory.Length; | ||||||
| @ -223,9 +222,9 @@ public class UnitTestFace | |||||||
|         item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder); |         item.SetResizedFileHolder(resize.FileNameExtension, resizedFileHolder); | ||||||
|         MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item); |         MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(item); | ||||||
|         (int _, metadataCollection) = metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); |         (int _, metadataCollection) = metadata.GetMetadataCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, subFileTuples, parseExceptions, mappingFromItem); | ||||||
|         imageResizeKeyValuePairs = resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, original, metadataCollection, item.Property, mappingFromItem); |         outputResolutionToResize = resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem); | ||||||
|         Assert.IsNotNull(mappingFromItem.ResizedFileHolder); |         Assert.IsNotNull(mappingFromItem.ResizedFileHolder); | ||||||
|         resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, original, imageResizeKeyValuePairs); |         resize.SaveResizedSubfile(_Configuration.PropertyConfiguration, outputResolution, cResultsFullGroupDirectory, subFileTuples, item, item.Property, mappingFromItem, outputResolutionToResize); | ||||||
|         Image image = FaceRecognition.LoadImageFile(mappingFromItem.ResizedFileHolder.FullName); |         Image image = FaceRecognition.LoadImageFile(mappingFromItem.ResizedFileHolder.FullName); | ||||||
|         Assert.IsNotNull(image); |         Assert.IsNotNull(image); | ||||||
|         (Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(_Configuration); |         (Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(_Configuration); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user