![]() |
ROC SDK
2.4.0
Scalable Face Recognition Software
|
Reading images. More...
Functions | |
| roc_error | roc_read_image (const char *file_name, roc_color_space color_space, roc_image *image) |
| Read an image from a file. More... | |
| roc_error | roc_read_image_w (const wchar_t *file_name, roc_color_space color_space, roc_image *image) |
| Read an image from a wide character file path. More... | |
| roc_error | roc_read_exif (const char *jpeg_file_name, roc_string *exif) |
Returns Exif information of a JPEG file as a JSON object. More... | |
| roc_error | roc_write_image (roc_image image, const char *file_name) |
| Write an image to a file. More... | |
| roc_error | roc_decode_image (const uint8_t *input_byte_array, size_t len, roc_color_space color_space, roc_image *image) |
| Decode an image from a buffer. More... | |
| roc_error | roc_encode_image (roc_image image, const char *format, int quality, roc_buffer *buffer, size_t *buffer_length) |
| Encode an image to a buffer. More... | |
| roc_error | roc_convert_nv21 (const uint8_t *input_byte_array, size_t width, size_t height, roc_image *image) |
| Convert an NV21-formatted buffer to a roc_image. More... | |
| roc_error | roc_redact_image (roc_image image, roc_detection detection, bool blur) |
| Obfuscate a region in the image. More... | |
| roc_error | roc_render_detection (roc_image image, const roc_detection detection, uint8_t r, uint8_t g, uint8_t b) |
| Render a detection bounding box on an image. More... | |
| roc_error | roc_resize_image (roc_image src, roc_image *dst, size_t width, size_t height) |
| Resize an image. More... | |
| roc_error | roc_read_ebts (const char *file_path, int num_face_images, roc_string *ebts, roc_image *images) |
| Read in an EBTS transaction file. More... | |
Reading images.
Decode a roc_image from a file with roc_read_image or from a buffer with roc_decode_image.
| roc_error roc_read_image | ( | const char * | file_name, |
| roc_color_space | color_space, | ||
| roc_image * | image | ||
| ) |
Read an image from a file.
Free image after use with roc_free_image. If this function returns an error then roc_image::data will also be set to NULL. For wide character file paths use roc_read_image_w.
roc_represent operates natively on ROC_GRAY8 images, and will automatically convert provided ROC_BGR24 images. When you don't otherwise need color images, as a speed/memory optimization you may read an image file directly into grayscale to eliminate the color space conversion in roc_represent.
A common unfortunate case is when an image file is originally saved with incorrect orientation information. For such an image rotated 90 degrees in either direction from vertical, or upside down, roc_represent will fail to find any faces in it. If you suspect this is the case with your image, use roc_rotate before roc_represent to try the same image at multiple possible orientations.
| [in] | file_name | Path to the image file. |
| [in] | color_space | Desired color space, see Color Space Considerations. |
| [out] | image | Address to store the decoded image. |
| roc_error roc_read_image_w | ( | const wchar_t * | file_name, |
| roc_color_space | color_space, | ||
| roc_image * | image | ||
| ) |
Read an image from a wide character file path.
See roc_read_image for details.
| [in] | file_name | Wide character path to the image file. |
| [in] | color_space | Desired color space, see Color Space Considerations. |
| [out] | image | Address to store the decoded image. |
| roc_error roc_read_exif | ( | const char * | jpeg_file_name, |
| roc_string * | exif | ||
| ) |
Returns Exif information of a JPEG file as a JSON object.
Please see the easyexif header file for a definition of each key in exif.
Free string after use with roc_free_string, unless this function returns an error in which case exif will not be initialized.
| [in] | jpeg_file_name | Path to JPEG file. |
| [out] | exif | Uninitialized string to contain Exif information as a JSON object. |
Write an image to a file.
The extension of file_name is used to determine the encoding format, see Supported Image Formats for details.
| image | Image to write. |
| file_name | Path to the image to. |
| roc_error roc_decode_image | ( | const uint8_t * | input_byte_array, |
| size_t | len, | ||
| roc_color_space | color_space, | ||
| roc_image * | image | ||
| ) |
Decode an image from a buffer.
Free image after use with roc_free_image. If this function returns an error then roc_image::data will also be set to NULL.
See roc_read_image for Supported Image Formats and Color Space Considerations.
| [in] | input_byte_array | Encoded image buffer. |
| [in] | len | Length of input_byte_array. |
| [in] | color_space | Desired color space, see Color Space Considerations. |
| [out] | image | Address to store the decoded image. |
| roc_error roc_encode_image | ( | roc_image | image, |
| const char * | format, | ||
| int | quality, | ||
| roc_buffer * | buffer, | ||
| size_t * | buffer_length | ||
| ) |
Encode an image to a buffer.
Free buffer after use with roc_free_buffer.
For .jpg the valid range for quality is 0 to 100, where higher values are better quality, and the suggested default is 95. For .png the valid range for quality is 0 to 9, where higher values are more compressed, and the suggested default it 3. The quality parameter is ignored for all other formats.
| [in] | image | Image to encode. |
| [in] | format | File extension specifying the encoding format, see Supported Image Formats for details. The leading period character in the format is optional. |
| [in] | quality | Image encoding quality, see Encoding Quality. |
| [out] | buffer | Encoded image buffer. |
| [out] | buffer_length | Length of buffer. |
| roc_error roc_convert_nv21 | ( | const uint8_t * | input_byte_array, |
| size_t | width, | ||
| size_t | height, | ||
| roc_image * | image | ||
| ) |
Convert an NV21-formatted buffer to a roc_image.
NV21 is the default format for the Android camera preview.
| [in] | input_byte_array | NV21 data buffer. |
| [in] | width | Image width. |
| [in] | height | Image height. |
| [out] | image | Output ROC_BGR24 image. |
| roc_error roc_redact_image | ( | roc_image | image, |
| roc_detection | detection, | ||
| bool | blur | ||
| ) |
Obfuscate a region in the image.
This function will set pixels in the specified region of the image to black.
| [in,out] | image | Image to obfuscate. |
| [in] | detection | Detection to redact. |
| [in] | blur | If true a guassian blur will be applied instead of setting the pixels to black. |
| roc_error roc_render_detection | ( | roc_image | image, |
| const roc_detection | detection, | ||
| uint8_t | r, | ||
| uint8_t | g, | ||
| uint8_t | b | ||
| ) |
Render a detection bounding box on an image.
This function will render the object/face detection on the provided image.
| [in] | image | Image to modify. |
| [in] | detection | Detection bounding box to display. |
| [in] | r | Bounding box color R channel (0-255). |
| [in] | g | Bounding box color G channel (0-255). |
| [in] | b | Bounding box color B channel (0-255). |
Resize an image.
| [in] | src | Input image. |
| [out] | dst | Output image. |
| [in] | width | Output image width. |
| [in] | height | Output image height. |
| roc_error roc_read_ebts | ( | const char * | file_path, |
| int | num_face_images, | ||
| roc_string * | ebts, | ||
| roc_image * | images | ||
| ) |
Read in an EBTS transaction file.
Reads in an EBTS v11.0 transaction file. Processes Type 2 and Type 10 records, and stores metadata information in a json string. Each Type 10 record has its image data returned in a buffer of roc_image.
The returned EBTS data string is a Java Script Object Notation (JSON) object which may contain the following keys if found in the supplied EBTS transaction file:
| Key | Definition |
|---|---|
FIRSTNAME | Subject's first name. |
LASTNAME | Subject's last name. |
DOB | Subject's date of birth. |
GENDER | Subject's gender. |
RACE | Subject's race. |
AGE | Subject's age. |
IMAGE | Image Metadata JSON String for each Type 10 Record. |
The image metadata for each Type 10 record may contain the following keys:
| Key | Definition |
|---|---|
PHOTO CAPTURE DATE | Date photo was captured in yyyyMMdd format. |
POSE | Image subject's pose. |
TYPE | Image type. |
SMT CLASSIFICATION | Scars, marks, tattoos image classification. |
| [in] | file_path | Path to the EBTS file. |
| [in] | num_face_images | The desired number of face images to return from the EBTS file in images. Faces found in the EBTS file after num_face_images will be ignored. If fewer than num_face_images are found, the remaining entries in images will have their roc_image::data pointer set to NULL. |
| [out] | ebts | Uninitialized roc_string to contain EBTS information as a JSON object. User is responsible for freeing this string after use with roc_free_string. |
| [out] | images | Pre-allocated array to hold roc_image. |
1.8.15