Files

34 lines
1.2 KiB
PowerShell

param(
[Parameter(Mandatory = $true)]
[string]$VideoRelativePath,
[Parameter(Mandatory = $true)]
[string]$OutputName
)
$ErrorActionPreference = 'Stop'
$q1Directory = $PSScriptRoot
$repositoryDirectory = Split-Path (Split-Path $q1Directory -Parent) -Parent
$packageDirectory = Join-Path $q1Directory 'cache/openface/OpenFace_2.2.0_win_x64'
$executable = Join-Path $packageDirectory 'FeatureExtraction.exe'
$videoPath = Join-Path $repositoryDirectory ($VideoRelativePath -replace '/', '\')
$outputDirectory = Join-Path $q1Directory 'cache/openface_outputs'
$null = New-Item -ItemType Directory -Force -Path $outputDirectory
if (-not (Test-Path -LiteralPath $executable -PathType Leaf)) {
throw "OpenFace 2.2.0 executable not found: $executable"
}
if (-not (Test-Path -LiteralPath $videoPath -PathType Leaf)) {
throw "Input video not found: $videoPath"
}
Push-Location $packageDirectory
try {
& $executable -mloc model/main_clnf_general.txt -f $videoPath -out_dir $outputDirectory -of $OutputName -2Dfp -pose -aus -gaze
if ($LASTEXITCODE -ne 0) {
throw "OpenFace FeatureExtraction failed with exit code $LASTEXITCODE for $VideoRelativePath"
}
}
finally {
Pop-Location
}