Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 146 to 180

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 4th December 2024 08:35 Europe/London time based on the source file dated 19th September 2024 17:30 Europe/London time.