initFacialRecognition()

Description

Initialize facial recognition functionality.

IMPORTANT: only one field can be setup for the annotation side and it also MUST be a dynamic keywords list

Parameters

This function accepts no parameters.

Return

boolean

Location

include/facial_recognition_functions.php lines 14 to 71

Definition

 
function initFacialRecognition()
{
    global 
$facial_recognition_tag_field$facial_recognition_face_recognizer_models_location$annotate_enabled,
           
$annotate_fields;

    if (!
is_numeric($facial_recognition_tag_field) || >= $facial_recognition_tag_field) {
        return 
false;
    }

    if (!
is_dir($facial_recognition_face_recognizer_models_location)) {
        if (
strpos($facial_recognition_face_recognizer_models_location$GLOBALS["storagedir"]) === 0) {
            
// Create the directory as it is in the configured filestore
            
mkdir($facial_recognition_face_recognizer_models_location0777true);
        } else {
            
// Folder needs to be created by server admin
            
$error str_replace(
                [
"%variable","%path"],
                [
"\$facial_recognition_face_recognizer_models_location"$facial_recognition_face_recognizer_models_location],
                
$GLOBALS["lang"]["error_invalid_path"]
            );
            if (
PHP_SAPI == "cli") {
                echo 
$error PHP_EOL;
            } else {
                
debug($error);
            }
            return 
false;
        }
    }

    
$facial_recognition_rtf_type ps_value(
        
"SELECT `type` AS `value`
           FROM resource_type_field
          WHERE ref = ?
        "
,
        array(
"i",$facial_recognition_tag_field),
        
null,
        
"schema"
    
);

    if (
FIELD_TYPE_DYNAMIC_KEYWORDS_LIST != $facial_recognition_rtf_type) {
        
$error str_replace(
            [
"%variable","%type"],
            [
"\$facial_recognition_tag_field"$GLOBALS["lang"]["fieldtype-dynamic_keywords_list"]],
            
$GLOBALS["lang"]["error_invalid_field_type"]
        );
        if (
PHP_SAPI == "cli") {
            echo 
$error PHP_EOL;
        } else {
            
debug($error);
        }
        return 
false;
    }

    
$annotate_enabled true;
    
$annotate_fields[] = $facial_recognition_tag_field;

    return 
true;
}

This article was last updated 21st April 2025 07:35 Europe/London time based on the source file dated 14th April 2025 15:05 Europe/London time.