@ -290,6 +290,9 @@ public partial class DlibDotNet
private void SetMapping ( MapLogic mapLogic , Item item , bool? isFocusRelativePath , bool? isIgnoreRelativePath , MappingFromItem mappingFromItem , List < MappingFromPhotoPrism > ? mappingFromPhotoPrismCollection , List < Shared . Models . Face > faces )
{
double? α ;
int? eyeα ;
bool? eyeReview ;
Mapping mapping ;
int faceAreaPermyriad ;
int confidencePercent ;
@ -309,11 +312,18 @@ public partial class DlibDotNet
}
else
{
if ( face . FaceParts is null )
( eyeα , eyeReview ) = ( null , null ) ;
else
{
( eyeReview , α ) = Shared . Models . Stateless . Methods . IFace . GetEyeα ( face . FaceParts ) ;
eyeα = α is null ? null : ( int ) Math . Round ( Math . Abs ( α . Value ) ) ;
}
confidencePercent = Shared . Models . Stateless . Methods . ILocation . GetConfidencePercent ( _Configuration . FaceConfidencePercent , _Configuration . RangeFaceConfidence , face . Location . Confidence ) ;
faceAreaPermyriad = Shared . Models . Stateless . Methods . IMapping . GetAreaPermyriad ( _Configuration . FaceAreaPermyriad , face . Location , face . OutputResolution ) ;
wholePercentRectangle = Shared . Models . Stateless . Methods . ILocation . GetWholePercentages ( face . Location , Shared . Models . Stateless . ILocation . Digits , face . OutputResolution ) ;
deterministicHashCodeKey = Shared . Models . Stateless . Methods . IMapping . GetDeterministicHashCodeKey ( item . Property . Id . Value , face . Location , Shared . Models . Stateless . ILocation . Digits , face . OutputResolution ) ;
mappingFromLocation = new ( faceAreaPermyriad , confidencePercent , deterministicHashCodeKey , wholePercentRectangle ) ;
mappingFromLocation = new ( faceAreaPermyriad , confidencePercent , deterministicHashCodeKey , eyeα , eyeReview , wholePercentRectangle ) ;
inSkipCollection = mapLogic . InSkipCollection ( item . Property . Id . Value , mappingFromLocation ) ;
mappingFromFilter = new ( isFocusModel , isFocusRelativePath , isIgnoreRelativePath , inSkipCollection ) ;
}
@ -326,6 +336,8 @@ public partial class DlibDotNet
private Mapping GetMapping ( MapLogic mapLogic , Item item , bool? isFocusRelativePath , bool? isIgnoreRelativePath , MappingFromItem mappingFromItem )
{
Mapping result ;
int? eyeα = null ;
bool? eyeReview = null ;
bool? inSkipCollection ;
int wholePercentRectangle ;
int faceAreaPermyriad = 0 ;
@ -344,7 +356,7 @@ public partial class DlibDotNet
{
wholePercentRectangle = Shared . Models . Stateless . Methods . ILocation . GetWholePercentages ( Shared . Models . Stateless . ILocation . Digits ) ;
deterministicHashCodeKey = Shared . Models . Stateless . Methods . IMapping . GetDeterministicHashCodeKey ( item . Property . Id . Value , Shared . Models . Stateless . ILocation . Digits ) ;
mappingFromLocation = new ( faceAreaPermyriad , confidencePercent , deterministicHashCodeKey , wholePercentRectangle ) ;
mappingFromLocation = new ( faceAreaPermyriad , confidencePercent , deterministicHashCodeKey , eyeα , eyeReview , wholePercentRectangle ) ;
inSkipCollection = mapLogic . InSkipCollection ( item . Property . Id . Value , mappingFromLocation ) ;
mappingFromFilter = new ( isFocusModel , isFocusRelativePath , isIgnoreRelativePath , inSkipCollection ) ;
}
@ -381,6 +393,7 @@ public partial class DlibDotNet
string outputResolution ,
string cResultsFullGroupDirectory ,
string dResultsFullGroupDirectory ,
string d2ResultsFullGroupDirectory ,
List < Tuple < string , DateTime > > sourceDirectoryChanges ,
Dictionary < int , List < MappingFromPhotoPrism > > fileNameToCollection ,
Container container ,
@ -436,8 +449,8 @@ public partial class DlibDotNet
if ( property is null | | item . Property is null )
throw new NullReferenceException ( nameof ( property ) ) ;
item . SetResizedFileHolder ( _Resize . FileNameExtension , resizedFileHolder ) ;
string facesDirectory = _Configuration . LoadOrCreateThenSaveImageFacesResultsForOutputResolutions . Contains ( outputResolution ) ? _Faces . GetFacesDirectory ( dResultsFullGroupDirectory , item ) : string . Empty ;
string facePartsDirectory = _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) ? _FaceParts . GetFacePartsDirectory ( _Configuration . PropertyConfiguration , dResultsFullGroupDirectory , item , includeNameWithoutExtension : true ) : string . Empty ;
string? facesDirectory = ! _Configuration . LoadOrCreateThenSaveImageFacesResultsForOutputResolutions . Contains ( outputResolution ) ? null : _Faces . GetFacesDirectory ( dResultsFullGroupDirectory , item ) ;
string? facePartsDirectory = ! _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) ? null : _FaceParts . GetFacePartsDirectory ( _Configuration . PropertyConfiguration , dResultsFullGroupDirectory , item , includeNameWithoutExtension : true ) ;
MappingFromItem mappingFromItem = Shared . Models . Stateless . Methods . IMappingFromItem . GetMappingFromItem ( containerDateTimes , item , resizedFileHolder ) ;
( int metadataGroups , metadataCollection ) = metadata . GetMetadataCollection ( subFileTuples , parseExceptions , mappingFromItem ) ;
if ( _AppSettings . MaxDegreeOfParallelism < 2 )
@ -451,9 +464,9 @@ public partial class DlibDotNet
if ( _AppSettings . MaxDegreeOfParallelism < 2 )
ticks = LogDelta ( ticks , nameof ( C_Resize . SaveResizedSubfile ) ) ;
}
if ( ! mappingFromItem . ResizedFileHolder . Exists & & ! File . Exists ( mappingFromItem . ResizedFileHolder . FullName ) )
if ( facesDirectory is null )
faces = new ( ) ;
else if ( ! _Configuration . LoadOrCreateThenSaveImageFacesResultsForOutputResolution s. Contains ( outputResolution ) )
else if ( ! mappingFromItem . ResizedFileHolder . Exists & & ! File . Exist s( mappingFromItem . ResizedFileHolder . FullName ) )
faces = new ( ) ;
else
{
@ -468,8 +481,8 @@ public partial class DlibDotNet
faces = _Faces . GetFaces ( outputResolution , dResultsFullGroupDirectory , subFileTuples , parseExceptions , property , mappingFromItem , outputResolutionToResize , locationContainers , mappingFromPhotoPrismCollection ) ;
if ( _AppSettings . MaxDegreeOfParallelism < 2 )
ticks = LogDelta ( ticks , nameof ( D_Face . GetFaces ) ) ;
List < ( Shared . Models . Face , FileInfo ? , string , bool Saved ) > faceCollection = _Faces . SaveFaces ( _FaceParts . FileNameExtension , dResultsFullGroupDirectory , subFileTuples , parseExceptions , mappingFromItem , facesDirectory , faces ) ;
SetMapping ( mapLogic , item , isFocusRelativePath , isIgnoreRelativePath , mappingFromItem , mappingFromPhotoPrismCollection , faces ) ;
List < ( Shared . Models . Face , FileInfo ? , string , bool Saved ) > faceCollection = _Faces . SaveFaces ( _FaceParts . FileNameExtension , dResultsFullGroupDirectory , subFileTuples , parseExceptions , mappingFromItem , facesDirectory , faces ) ;
if ( _Configuration . CopyFacesAndSaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) )
_FaceParts . CopyFacesAndSaveFaceLandmarkImage ( facePartsCollectionDirectory , mappingFromItem , faceCollection ) ;
if ( _AppSettings . MaxDegreeOfParallelism < 2 )
@ -478,10 +491,14 @@ public partial class DlibDotNet
& & _Configuration . LoadOrCreateThenSaveDistanceResultsForOutputResolutions . Contains ( outputResolution )
& & locationContainers is not null & & faceCollection . All ( l = > ! l . Saved ) )
_Distance . LookForMatchFacesAndPossiblyRename ( _Faces . FileNameExtension , mappingFromItem , faces , locationContainers ) ;
if ( _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputR esolution ) )
( bool review , int [ ] eyesCollection ) = Shared . Models . Stateless . Methods . IFace . GetEyeCollection ( _Configuration . EyeThr esh old , faces ) ;
if ( review | | _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) )
{
bool saveRotated = false ;
if ( ! _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) )
_FaceParts . SetAngleBracketCollection ( _Configuration . PropertyConfiguration , d2ResultsFullGroupDirectory , container . SourceDirectory ) ;
string sourceDirectorySegment = Property . Models . Stateless . IResult . GetRelativePath ( _Configuration . PropertyConfiguration , container . SourceDirectory ) ;
facePartsDirectory ? ? = _FaceParts . GetFacePartsDirectory ( _Configuration . PropertyConfiguration , dResultsFullGroupDirectory , item , includeNameWithoutExtension : true ) ;
_FaceParts . SaveFaceLandmarkImages ( _Configuration . PropertyConfiguration , facePartsDirectory , subFileTuples , parseExceptions , mappingFromItem , faces , saveRotated ) ;
if ( _AppSettings . MaxDegreeOfParallelism < 2 )
ticks = LogDelta ( ticks , nameof ( D2_FaceParts . SaveFaceLandmarkImages ) ) ;
@ -517,8 +534,8 @@ public partial class DlibDotNet
ProgressBarOptions options = new ( ) { ProgressCharacter = '─' , ProgressBarOnBottom = true , DisableBottomPercentage = true } ;
string focusRelativePath = Path . GetFullPath ( string . Concat ( _Configuration . PropertyConfiguration . RootDirectory , _Configuration . FocusDirectory ) ) ;
bool? isFocusRelativePath = string . IsNullOrEmpty ( _Configuration . FocusDirectory ) ? null : container . SourceDirectory . StartsWith ( focusRelativePath ) ;
string facePartsCollectionDirectory = _Configuration . CopyFacesAndSaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) ? _FaceParts . GetFacePartsDirectory ( _Configuration . PropertyConfiguration , d2ResultsFullGroupDirectory , item : filteredItems . First ( ) , includeNameWithoutExtension : false ) : string . Empty ;
bool? isIgnoreRelativePath = ! _Configuration . IgnoreRelativePaths . Any ( ) ? null : _Configuration . IgnoreRelativePaths . Any ( l = > container . SourceDirectory . Contains ( l ) ) & & Shared . Models . Stateless . Methods . IContainer . IsIgnoreRelativePath ( _Configuration . PropertyConfiguration , _Configuration . IgnoreRelativePaths , container . SourceDirectory ) ;
string facePartsCollectionDirectory = _Configuration . CopyFacesAndSaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) | | _Configuration . SaveFaceLandmarkForOutputResolutions . Contains ( outputResolution ) ? _FaceParts . GetFacePartsDirectory ( _Configuration . PropertyConfiguration , d2ResultsFullGroupDirectory , item : filteredItems . First ( ) , includeNameWithoutExtension : false ) : string . Empty ;
using ProgressBar progressBar = new ( filteredItems . Length , message , options ) ;
_ = Parallel . For ( 0 , filteredItems . Length , parallelOptions , ( i , state ) = >
{
@ -531,6 +548,7 @@ public partial class DlibDotNet
outputResolution ,
cResultsFullGroupDirectory ,
dResultsFullGroupDirectory ,
d2ResultsFullGroupDirectory ,
sourceDirectoryChanges ,
fileNameToCollection ,
container ,