Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

faceRecognizerPredict()

Description

Use FaceRecognizer to predict the association between a face and a label (i.e person name)

Parameters

ColumnTypeDefaultDescription
$model_file_path string Path to the FaceRecognizer model state file
$test_image_path string Path to the prepared image we are testing

Return

boolean|array Return the label ID and probability on successful prediction or FALSE on error

Location

include/facial_recognition_functions.php lines 123 to 157

Definition

 
function faceRecognizerPredict($model_file_path$test_image_path)
    {
    if(!
file_exists($model_file_path))
        {
        
debug("FACIAL_RECOGNITION: Could not find model at '{$model_file_path}'");
        return 
false;
        }

    if(!
file_exists($test_image_path))
        {
        
debug("FACIAL_RECOGNITION: Could not find the test image at '{$test_image_path}'");
        return 
false;
        }

    
$python_fullpath get_utility_path('python');
    if(
false === $python_fullpath)
        {
        
debug('FACIAL_RECOGNITION: Could not find Python!');
        return 
false;
        }

    
$faceRecognizer_path __DIR__ '/../lib/facial_recognition/faceRecognizer.py';
    
$model_file_path     escapeshellarg($model_file_path);
    
$test_image_path     escapeshellarg($test_image_path);

    
$prediction run_command("{$python_fullpath} {$faceRecognizer_path} {$model_file_path} {$test_image_path}");
    
$prediction json_decode($prediction);

    if(
null === $prediction || count($prediction))
        {
        return 
false;
        }

    return 
$prediction;
    }

This article was last updated 27th April 2024 11:35 Europe/London time based on the source file dated 31st October 2021 14:15 Europe/London time.