Add Face Recognition executables and scripts for Windows and Unix
All checks were successful
Publish FaceAI Container / publish (push) Successful in 11m44s
All checks were successful
Publish FaceAI Container / publish (push) Successful in 11m44s
This commit is contained in:
parent
774d304220
commit
5df2185c1d
11 changed files with 337 additions and 1 deletions
116
bin/Face_Recognition_Windows/run_face_encoder.ps1
Normal file
116
bin/Face_Recognition_Windows/run_face_encoder.ps1
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
# --- Selezione livello multicore ---
|
||||
Write-Host ""
|
||||
Write-Host "Seleziona il livello di multicore per l'elaborazione CPU:"
|
||||
Write-Host " 1 = 1/8 dei core"
|
||||
Write-Host " 2 = 1/4 dei core"
|
||||
Write-Host " 3 = 1/2 dei core (predefinito)"
|
||||
Write-Host " 4 = 3/4 dei core"
|
||||
Write-Host " 5 = n-2 core"
|
||||
Write-Host ""
|
||||
$input = Read-Host "Inserisci il livello (1-5) oppure premi Invio per usare il predefinito (3)"
|
||||
|
||||
if ($input -match '^[1-5]$') {
|
||||
$multicore = [int]$input
|
||||
} else {
|
||||
$multicore = -1
|
||||
}
|
||||
|
||||
# --- Modern folder picker (IFileOpenDialog, Vista+) ---
|
||||
Add-Type -TypeDefinition @'
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class ModernFolderPicker {
|
||||
private const uint FOS_PICKFOLDERS = 0x00000020;
|
||||
private const int SIGDN_FILESYSPATH = unchecked((int)0x80028000);
|
||||
|
||||
public static string Show(string title = "Select Folder") {
|
||||
var dialog = (IFileOpenDialog)new FileOpenDialogClass();
|
||||
try {
|
||||
uint options;
|
||||
dialog.GetOptions(out options);
|
||||
dialog.SetOptions(options | FOS_PICKFOLDERS);
|
||||
dialog.SetTitle(title);
|
||||
if (dialog.Show(IntPtr.Zero) != 0) return null; // cancelled
|
||||
IShellItem item;
|
||||
dialog.GetResult(out item);
|
||||
string path;
|
||||
item.GetDisplayName(SIGDN_FILESYSPATH, out path);
|
||||
Marshal.ReleaseComObject(item);
|
||||
return path;
|
||||
} finally {
|
||||
Marshal.ReleaseComObject(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
[ComImport, ClassInterface(ClassInterfaceType.None), Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")]
|
||||
private class FileOpenDialogClass {}
|
||||
|
||||
[ComImport, Guid("D57C7288-D4AD-4768-BE02-9D969532D960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IFileOpenDialog {
|
||||
[PreserveSig] int Show(IntPtr hwndOwner);
|
||||
void SetFileTypes(uint cFileTypes, IntPtr rgFilterSpec);
|
||||
void SetFileTypeIndex(uint iFileType);
|
||||
void GetFileTypeIndex(out uint piFileType);
|
||||
void Advise(IntPtr pfde, out uint pdwCookie);
|
||||
void Unadvise(uint dwCookie);
|
||||
void SetOptions(uint fos);
|
||||
void GetOptions(out uint pfos);
|
||||
void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
|
||||
void SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi);
|
||||
void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
|
||||
void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
|
||||
void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
||||
void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName);
|
||||
void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
|
||||
void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);
|
||||
void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
|
||||
void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
|
||||
void AddPlace([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, int fdap);
|
||||
void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
|
||||
void Close(int hr);
|
||||
void SetClientGuid([In] ref Guid guid);
|
||||
void ClearClientData();
|
||||
void SetFilter(IntPtr pFilter);
|
||||
void GetResults(out IntPtr ppenum);
|
||||
void GetSelectedItems(out IntPtr ppenum);
|
||||
}
|
||||
|
||||
[ComImport, Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IShellItem {
|
||||
void BindToHandler(IntPtr pbc, [In] ref Guid bhid, [In] ref Guid riid, out IntPtr ppv);
|
||||
void GetParent(out IShellItem ppsi);
|
||||
void GetDisplayName(int sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
|
||||
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
|
||||
void Compare(IShellItem psi, uint hint, out int piOrder);
|
||||
}
|
||||
}
|
||||
'@
|
||||
|
||||
$inputPath = [ModernFolderPicker]::Show("Select the folder containing images to encode")
|
||||
|
||||
if (-not $inputPath) {
|
||||
Write-Host "No folder selected. Exiting."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# --- Build argument list ---
|
||||
$encoderExe = Join-Path $PSScriptRoot "face_encoder_cpu\face_encoder_cpu.exe"
|
||||
|
||||
$encoderArgs = [System.Collections.Generic.List[string]]::new()
|
||||
$encoderArgs.Add("-i")
|
||||
$encoderArgs.Add($inputPath)
|
||||
$encoderArgs.Add("-r")
|
||||
|
||||
if ($multicore -ge 0) {
|
||||
$encoderArgs.Add("-m")
|
||||
$encoderArgs.Add([string]$multicore)
|
||||
}
|
||||
|
||||
# --- Run encoder ---
|
||||
Write-Host "Input folder : $inputPath"
|
||||
Write-Host "Multicore : $(if ($multicore -ge 0) { $multicore } else { 'default (3)' })"
|
||||
Write-Host "Command : $encoderExe $encoderArgs"
|
||||
Write-Host ""
|
||||
|
||||
& $encoderExe @encoderArgs
|
||||
Loading…
Add table
Add a link
Reference in a new issue