ROC SDK  2.4.0
Scalable Face Recognition Software
Data Structures | Typedefs | Functions
Template Generation

Process faces in an image. More...

Data Structures

struct  roc_thumbnail_parameters
 Set the characteristics of generated roc_template thumbnails. See ROC_THUMBNAIL for details. More...
 

Typedefs

typedef struct roc_thumbnail_parameters roc_thumbnail_parameters
 Set the characteristics of generated roc_template thumbnails. See ROC_THUMBNAIL for details. More...
 

Functions

roc_error roc_get_thumbnail_parameters (roc_thumbnail_parameters *thumbnail_parameters)
 Get the parameters used by ROC_THUMBNAIL in roc_represent. More...
 
roc_error roc_set_thumbnail_parameters (roc_thumbnail_parameters thumbnail_parameters)
 Set the parameters used by ROC_THUMBNAIL in roc_represent. More...
 
roc_error roc_preload (roc_algorithm_id algorithm_id)
 Pre-load the model files to be used by roc_represent. More...
 
roc_error roc_set_model_path (const char *path)
 Set path to the object and/or text detection configuration files. More...
 
roc_error roc_represent (roc_image image, roc_algorithm_id algorithm_id, size_t min_size, int k, float false_detection_rate, float min_quality, roc_template *templates)
 Detect faces and objects in an image. Process faces into templates for comparison. More...
 
roc_error roc_represent_roi (roc_image image, roc_algorithm_id algorithm_id, float relative_min_size, size_t absolute_min_size, size_t min_representation_size, int k, float false_detection_rate, float min_quality, const roc_roi *include, size_t num_include, const roc_roi *exclude, size_t num_exclude, float min_roi_overlap, const roc_string text_filter, const roc_thumbnail_parameters thumbnail_parameters, bool rotate_on_failure, roc_template *templates)
 A generalization of roc_represent that supports additional fields specifying where in an image to process. This function also supports filtering text detections. This function computes Minimum Size internally. More...
 
roc_error roc_represent_fingerprint (roc_image image, roc_finger_id finger_id, const int resolution, const int k, float false_detection_rate, float min_quality, roc_template *templates)
 Encode a fingerprint image into a ROC fingerprint template suitable for comparison and matching. More...
 
roc_error roc_merge_fingerprints (const roc_template *templates, int n, roc_template *merged)
 Merge multiple individual fingerprint templates into a single comined template. More...
 
roc_error roc_representation_limit (size_t *representation_limit)
 Query the remaining representation limit. More...
 

Detailed Description

Process faces in an image.

Process faces in an image with roc_represent. Free a face roc_template after use with roc_free_template.


Data Structure Documentation

◆ roc_thumbnail_parameters

struct roc_thumbnail_parameters

Set the characteristics of generated roc_template thumbnails. See ROC_THUMBNAIL for details.

Native Resolution Thumbnails

A width and height of -1 may be specified to use the roc_detection width and height.

Full-Image Thumbnails

As a special case, if scale is 0.0 then the full image will used as the thumbnail instead of the detection.

Example
// pre-set default parameters
roc_thumbnail_parameters thumbnailParameters = {288, 384, 0.6f, 80};
// size-optimized parameters
roc_thumbnail_parameters thumbnailParameters = {192, 256, 0.6f, 32};
// fixed size without alignment
roc_thumbnail_parameters thumbnailParameters = {288, 384, -0.6f, 80};
// native resolution
roc_thumbnail_parameters thumbnailParameters = {-1, 0, 1.f, 95};
// full image parameters
roc_thumbnail_parameters thumbnailParameters = {-1, -1, 0.f, 95};
Data Fields
int width Image width in pixels. The default is 288, and the range is -1 to 4096.
int height Image height in pixels. The default is 384, and the range is -1 to 4096.
float scale Thumbnail face scale, where larger values are a tighter cropping. The default is 0.6, and the range is 0.0 to 1.0.
float quality Thumbnail quality, where larger values are higher quality at the expense of more storage. The default is 80, and the range is 0 to 100.

Typedef Documentation

◆ roc_thumbnail_parameters

Set the characteristics of generated roc_template thumbnails. See ROC_THUMBNAIL for details.

Native Resolution Thumbnails

A width and height of -1 may be specified to use the roc_detection width and height.

Full-Image Thumbnails

As a special case, if scale is 0.0 then the full image will used as the thumbnail instead of the detection.

Example
// pre-set default parameters
roc_thumbnail_parameters thumbnailParameters = {288, 384, 0.6f, 80};
// size-optimized parameters
roc_thumbnail_parameters thumbnailParameters = {192, 256, 0.6f, 32};
// fixed size without alignment
roc_thumbnail_parameters thumbnailParameters = {288, 384, -0.6f, 80};
// native resolution
roc_thumbnail_parameters thumbnailParameters = {-1, 0, 1.f, 95};
// full image parameters
roc_thumbnail_parameters thumbnailParameters = {-1, -1, 0.f, 95};

Function Documentation

◆ roc_get_thumbnail_parameters()

roc_error roc_get_thumbnail_parameters ( roc_thumbnail_parameters thumbnail_parameters)

Get the parameters used by ROC_THUMBNAIL in roc_represent.

Example
roc_thumbnail_parameters thumbnail_parameters;
roc_get_thumbnail_parameters(&thumbnail_parameters);
Parameters
[out]thumbnail_parametersroc_thumbnail_parameters object.
See also
roc_set_thumbnail_parameters
Remarks
This function is thread-safe.

◆ roc_set_thumbnail_parameters()

roc_error roc_set_thumbnail_parameters ( roc_thumbnail_parameters  thumbnail_parameters)

Set the parameters used by ROC_THUMBNAIL in roc_represent.

Parameters
[in]thumbnail_parametersNew roc_thumbnail_parameters settings.
See also
roc_get_thumbnail_parameters
Remarks
This function is thread-unsafe.

◆ roc_preload()

roc_error roc_preload ( roc_algorithm_id  algorithm_id)

Pre-load the model files to be used by roc_represent.

Call this function once after roc_initialize with the algorithm_id that will be used in roc_represent. See Lazy Initialization for details.

Example
Parameters
[in]algorithm_idPre-load the model files to be used by roc_represent for this roc_algorithm_id.
Remarks
This function is thread-safe.
See also
roc_set_model_path

◆ roc_set_model_path()

roc_error roc_set_model_path ( const char *  path)

Set path to the object and/or text detection configuration files.

path is expected to point to the models folder of the SDK. This function must be called before a call to roc_preload or roc_represent in which ROC_ALL_OBJECT_DETECTION, ROC_TEXT_DETECTION or ROC_TEXT_REPRESENTATION is used.

Remarks
This function is thread-unsafe.

◆ roc_represent()

roc_error roc_represent ( roc_image  image,
roc_algorithm_id  algorithm_id,
size_t  min_size,
int  k,
float  false_detection_rate,
float  min_quality,
roc_template templates 
)

Detect faces and objects in an image. Process faces into templates for comparison.

Each face and object is represented by a roc_template. In the case that the number of representable faces or objects is less than k, the trailing elements of templates will have roc_template::algorithm_id set to ROC_NO_ALGORITHM_OPTIONS. In the case that the number of representable faces is greater than k, the implementation will choose which faces to represent, see Maximum Faces for details. The populated templates will be returned sorted by decreasing roc_detection::confidence where faces are always prioritized over objects in the case that both are detected. Each constructed template will have roc_template::template_id initialized by roc_uuid_get_random.

Each roc_template in templates should be freed after use with roc_free_template. Templates with roc_algorithm_id equal to ROC_NO_ALGORITHM_OPTIONS do not have any allocated memory associated with them, freeing them is a no-op and therefore optional.

This function is exposed in the Command Line Interface as roc-represent.

Specifying an Algorithm ID

The algorithm_id is a combination of roc_algorithm_options indicating how to process faces in an image. There are three components to an algorithm id: detection, representation and metadata. Components are combined together using a bitwise-or operation, as in Algorithm ID Examples. You do not need to specify ROC_TEMPLATE_VERSION, this will be added automatically.

Detection Options

The below options are available as face detection algorithms.

Detection Options Description
ROC_FRONTAL_DETECTION Detect faces from -30 to +30 degrees yaw.
ROC_STANDARD_DETECTION Detect faces from -100 to +100 degrees yaw with high accuracy.
ROC_MANUAL_DETECTION Bypass automatic face detection by using caller-provided bounding boxes.
ROC_ALL_OBJECT_DETECTION Detect all objects in an image.
None Use ROC_FRONTAL_DETECTION.

When ROC_STANDARD_DETECTION is specified, ROC_FRONTAL_DETECTION is ignored.

Representation Options

In the typical case, one option should be specified to indicate the desired face comparison mechanism. Detected objects will not be templatized. If no option is specified, roc_template::fv_size will be zero and the resulting roc_template can not be used in roc_compare_templates or roc_search.

Representation Options Description
ROC_STANDARD_REPRESENTATION Represent faces for comparison.
ROC_DEEP_REPRESENTATION Slower but more accurate alternative to ROC_STANDARD_REPRESENTATION.
ROC_FAST_REPRESENTATION Faster but less accurate alternative to ROC_STANDARD_REPRESENTATION.
ROC_TATTOO_REPRESENTATION Represent a law enforcement booking-style scar/mark/tattoo (SMT) image.
None No template comparison needed.

Metadata Options

Each metadata option may be optionally included to add additional fields to the Metadata.

Metadata Options Description
ROC_PITCHYAW Add Yaw and Pitch (degrees) estimation to the template metadata.
ROC_ANALYTICS Estimate age, emotion, gaussian blur, geographic origin, gender, glasses, facial hair, artwork and mask detection.
ROC_LANDMARKS Add the full set of landmark locations to the template metadata.
ROC_THUMBNAIL An aligned and cropped face image suitable for displaying.
ROC_SPOOF Add Spoof metric for static Face Liveness detection.
ROC_ICAO_METRICS Compute ICAO face portrait quality measures.
ROC_ICAO_BACKGROUND Compute ICAO uniform background face portrait quality metric.
None No additional metadata needed.

Algorithm ID Examples

// Detect frontal faces and represent for comparison.
// Detect frontal faces, represent for comparison, and report analytics
// and pose estimation.
// Detect faces across all yaw ranges, report pose estimation, and construct
// a thumbnail.
// Detect and represent objects, and construct a thumbnail.

Minimum Size

The min_size parameter indicates the smallest face to detect in an image. This parameter does not apply to object detection. Face detection size is measured by the width of the face in pixels. A larger value for min_size will result in faster execution speed and fewer false positives, as the image won't be scanned for smaller faces. While faces smaller than 20 pixels can be detected, they will be unreliable for recognition. Faces between 20 and 36 pixels can be used for recognition, albeit at a lower accuracy. A min_size less than 12 will be set to 12. Most applications should use roc_adaptive_minimum_size to compute a sensible minimum size relative to the image dimensions.

Maximum Faces

The parameter k indicates the maximum number of faces and objects to detect in an image. When k is less than the number of faces in the image, the faces with the highest roc_detection::width will be returned.

k == -1

When k == -1 the following special-case behavior applies:

  • If no faces above the False Detection Rate are found, the detector will return the most face-like region in the image.

This is useful for enrolling controlled capture datasets where exactly one face is expected. In the general case where k == -N, at least 1 and up to N faces will be returned.

This setting has an analagous effect for object detection.

False Detection Rate

The false_detection_rate parameter specifies the allowable false positive rate for face detection. The suggested default value for false_detection_rate is ROC_SUGGESTED_FALSE_DETECTION_RATE which corresponds to one false detection in 50 images on an internal dataset similar to FDDB. A higher false detection rate will correctly detect more faces at the cost of also incorrectly detecting more non-faces. The accepted range of values for false_detection_rate is between 0 and 1 inclusive. Values outside this range will be truncated to the aforementioned bounds automatically.

The confidence values for detected objects do not have the same meaning as face detections. Thus, this parameter has no effect on objects detection and users can filter objects after calling roc_represent as desired.

Minimum Quality

See Face Quality.

Lazy Initialization

The first call to roc_represent incurs additional overhead as the model files needed to execute the specified algorithm_id are loaded from disk. Call roc_preload beforehand to avoid incuring this overhead on the first call.

Operating System Compatibility

Identical templates are produced across all operating systems when provided the same input parameters. Templates are completely compatible when transferred to a different operating system.

For use cases that involve matching both masked and unmasked faces we recommend using all of the following flags:

Speed

To increase speed, the following changes will have the most impact:

Example
Parameters
[in]imageInput image to process for faces.
[in]algorithm_idAlgorithm identifier, see Specifying an Algorithm ID.
[in]min_sizeMinimum size face to detect, see Minimum Size.
[in]kThe desired number of face templates, see Maximum Faces.
[in]false_detection_rateThe lower bound for face detection confidence, see False Detection Rate.
[in]min_qualityMinimum Face Quality to templatize.
[out]templatesPre-allocated array to hold the generated templates.
Remarks
This function is reentrant and parallel.
See also
roc_represent_roi

◆ roc_represent_roi()

roc_error roc_represent_roi ( roc_image  image,
roc_algorithm_id  algorithm_id,
float  relative_min_size,
size_t  absolute_min_size,
size_t  min_representation_size,
int  k,
float  false_detection_rate,
float  min_quality,
const roc_roi include,
size_t  num_include,
const roc_roi exclude,
size_t  num_exclude,
float  min_roi_overlap,
const roc_string  text_filter,
const roc_thumbnail_parameters  thumbnail_parameters,
bool  rotate_on_failure,
roc_template templates 
)

A generalization of roc_represent that supports additional fields specifying where in an image to process. This function also supports filtering text detections. This function computes Minimum Size internally.

Parameters
[in]imageInput image to process for faces.
[in]algorithm_idAlgorithm identifier, see Specifying an Algorithm ID.
[in]relative_min_sizeFaces will be no smaller than this fraction of the image width and height.
[in]absolute_min_sizeFaces will be no smaller than this in pixels.
[in]min_representation_sizeMinimum size face in pixels to construct a feature vector, or 0 to represent all detected faces.
[in]kThe desired number of face templates, see Maximum Faces.
[in]false_detection_rateThe lower bound for face detection confidence, see False Detection Rate.
[in]min_qualityMinimum Face Quality to templatize.
[in]includeRegions of interest that detections must lie within, or NULL.
[in]num_includeLength of include.
[in]excludeRegions of interest that detections must not lie within, or NULL.
[in]num_excludeLength of exclude.
[in]min_roi_overlapMinimum fraction of detection area that must be contained within include or exclude. Also used as the threshold for ROC_IGNORE_PARTIAL.
[in]text_filterRegular expressions describing text to check for in detection areas.
[in]thumbnail_parametersSettings used for generating template thumbnails. See ROC_THUMBNAIL.
[in]rotate_on_failureRotate and reattempt failed templatizations for the input image. Function will attempt up to three 90 degree rotations. This argument generates an 'ImageRotation' field in the template Metadata.
[out]templatesPre-allocated array to hold the generated templates.
Remarks
This function is reentrant and parallel.
See also
roc_represent

◆ roc_represent_fingerprint()

roc_error roc_represent_fingerprint ( roc_image  image,
roc_finger_id  finger_id,
const int  resolution,
const int  k,
float  false_detection_rate,
float  min_quality,
roc_template templates 
)

Encode a fingerprint image into a ROC fingerprint template suitable for comparison and matching.

The returned templates should be freed after use with roc_free_template.

This function is exposed in the Command Line Interface as roc-represent.

Specifying a Finger ID

The user is required to specify which finger created the provided print from the roc_finger_options list. If the user doesn't know the finger, they may specify ROC_UNKNOWN_FINGER to indicate the finger is unknown.

roc_finger_id can be combined as bit flags to express uncertainty, for example ROC_RIGHT_HAND | ROC_INDEX_FINGER | ROC_MIDDLE_FINGER indicates the finger is either the index or middle finger of the subject's right hand. This finger will be compared against both right hand index and middle fingers in a search.

If an image contains multiple fingers change the k value to the expected number of fingers in the image. If k >= 1, then finger_id should contain each finger expected to appear in the image. For example, a left hand four finger slap should have finger_id ROC_LEFT_HAND | ROC_FOUR_FINGERS and k equal to 4. The SDK will attempt to detect and assign the correct finger_id to k fingerprints. It is possible that detection will fail and fewer than k fingerprints will be returned. In this case, each returned fingerprint is assigned finger_id as its FingerID.

The output templates shall be pre-allocated but initialized array of length k.

The roc_template::algorithm_id will be automatically set to include ROC_FINGERPRINT_REPRESENTATION. If detection was run it will also include ROC_FINGERPRINT_DETECTION.

Fingerprint Resolution

Fingerprint sensors have a fixed capture resolution given in pixels per inch or PPI. 500 and 1000 are common PPI values, but any resolution is supported.

Fingerprint Quality

A metric indicating how accurately a template will perform in recognition.

A higher fingerprint quality (or "finger matchability") value indicates a lower false non-match rate. The metric provides the number of standard deviations a template is from an average template. Lower quality templates will have a negative quality score.

See roc_merge_fingerprints for a method to merge individual finger templates into a ten print set.

Parameters
[in]imageThe grayscale input image containing one fingerprint.
[in]finger_idThe index of the finger that created the print. See Specifying a Finger ID.
[in]resolutionThe resolution of the image. See Fingerprint Resolution.
[in]kThe expected number of fingerprints in the image. At most k fingerprints will be detected and templatized.
[in]false_detection_rateThe lower bound for fingerprint detection
[in]min_qualityMinimum Fingerprint Quality to templatize.
[out]templatesA preallocated output array of templates holding the representation of each fingerprint. The length of this array is determined by finger_id.
See also
roc_merge_fingerprints
Remarks
This function is reentrant and parallel.

◆ roc_merge_fingerprints()

roc_error roc_merge_fingerprints ( const roc_template templates,
int  n,
roc_template merged 
)

Merge multiple individual fingerprint templates into a single comined template.

The combined representation is useful to group multiple fingers from one encounter with the same individual when multiple fingers are collected. A merged template should contain at most one instance of each finger.

Parameters
[in]templatesAn array of templates of length n to merge. The templates should contain a unique set of fingers.
[in]nThe length of templates.
[out]mergedA single merged template containing all individual finger templates.
Remarks
This function is reentrant.
See also
roc_represent_fingerprint

◆ roc_representation_limit()

roc_error roc_representation_limit ( size_t *  representation_limit)

Query the remaining representation limit.

Some licenses of the ROC SDK include a limit to the number of representations that can be made over the lifetime of the license. The number of representations is the number of times roc_represent has been called. This function returns the number of representations specified in the license file less the number of representations used to date.

Example
size_t representation_limit;
roc_representation_limit(&representation_limit);
Parameters
[out]representation_limitThe remaining number of representations available.
Remarks
This function is thread-safe.
See also
roc_comparison_limit roc_template_limit