![]() |
ROC SDK
2.4.0
Scalable Face Recognition Software
|
Image data structure and related functions. More...
Data Structures | |
| struct | roc_image |
| Common representation for still images and video frames. More... | |
| struct | roc_roi |
| Image region of interest to restrict processing. More... | |
Typedefs | |
| typedef enum roc_color_space | roc_color_space |
| Supported image formats. | |
| typedef struct roc_image | roc_image |
| Common representation for still images and video frames. More... | |
| typedef struct roc_roi | roc_roi |
| Image region of interest to restrict processing. More... | |
| typedef const char * | roc_string |
| Represents a string output value that should be freed with roc_free_string after use. | |
| typedef const uint8_t * | roc_buffer |
| Represents a buffer output value that should be freed with roc_free_buffer after use. | |
Enumerations | |
| enum | roc_color_space { ROC_GRAY8, ROC_BGR24 } |
| Supported image formats. More... | |
Functions | |
| roc_roi | roc_roi_get (float x, float y, float width, float height) |
| Construct a roc_roi. More... | |
| bool | roc_roi_is_null (roc_roi roi) |
true if the area of roi is 0. More... | |
| bool | roc_roi_is_fractional (roc_roi roi) |
| Fractional regions of interest are scaled by the image width and height. More... | |
| bool | roc_roi_within (roc_roi test, roc_roi reference, size_t image_width, size_t image_height, float min_overlap) |
| Determine if a rectangle is contained within a region of interest. More... | |
| bool | roc_roi_within_set (roc_roi test, const roc_roi *include, size_t num_include, const roc_roi *exclude, size_t num_exclude, size_t image_width, size_t image_height, float min_overlap) |
| Determine if a rectangle satisfies the sets of include and exclude regions of interest. More... | |
| roc_error | roc_new_image (size_t width, size_t height, size_t step, roc_color_space color_space, roc_media_id media_id, roc_camera_id camera_id, roc_time timestamp, const uint8_t *input_byte_array, roc_image *image) |
| Construct a new image. More... | |
| roc_error | roc_copy_image (roc_image src, roc_image *dst) |
| Deep copy an image. More... | |
| roc_error | roc_rotate (roc_image *image, int degrees) |
| Rotate an image clockwise in intervals of 90 degrees. More... | |
| roc_error | roc_swap_channels (roc_image image) |
| Swap red and blue channels to convert between RGB and BGR color spaces. More... | |
| roc_error | roc_bgr2gray (roc_image src, roc_image *dst) |
| Convert a color image to grayscale. More... | |
| roc_error | roc_gray2bgr (roc_image src, roc_image *dst) |
| Expand a grayscale image to color. More... | |
| roc_error | roc_to_rgba (roc_image src, uint8_t *output_byte_array) |
Copy a roc_image to a pre-allocated ARGB_8888 buffer. More... | |
| roc_error | roc_from_rgba (const uint8_t *input_byte_array, size_t width, size_t height, size_t step, roc_image *image) |
Initialize a roc_image from an ARGB_8888 buffer. More... | |
| roc_error | roc_from_bgra (const uint8_t *input_byte_array, size_t width, size_t height, size_t step, roc_image *image) |
Initialize a roc_image from a BGRA_8888 buffer. More... | |
| roc_error | roc_from_yuv (const uint8_t *y_in, const uint8_t *u_in, const uint8_t *v_in, size_t y_row_stride, size_t uv_row_stride, size_t uv_pixel_stride, size_t width, size_t height, roc_image *image) |
Initialize a roc_image from a YUV_420_888 buffer. More... | |
| roc_error | roc_enhance_contrast (const roc_image src, float clip_limit, int num_tiles, roc_image *dst) |
| Image contrast enhancement. More... | |
| roc_error | roc_read_ppm (const char *file_name, roc_image *image) |
| Read a PPM or PGM image file. More... | |
| roc_error | roc_write_ppm (const char *file_name, roc_image image) |
| Write a PPM or PGM image file. More... | |
| roc_error | roc_free_image (roc_image image) |
| Frees the memory previously allocated for a roc_image. More... | |
| roc_error | roc_set_string (const char *src, roc_string *dst) |
| Set a string value. More... | |
| roc_error | roc_free_string (roc_string *str) |
| Free a roc_string previously returned by another function. More... | |
| roc_error | roc_free_buffer (roc_buffer *buffer) |
| Free a roc_buffer previously returned by another function. More... | |
Image data structure and related functions.
Copy an image with roc_copy_image, rotate an image with roc_rotate, and free an image with roc_free_image.
| struct roc_image |
Common representation for still images and video frames.
Images can be read with roc_read_image or roc_read_frame, and freed with roc_free_image.
Pixels are stored in row-major order. In other words, pixel layout with respect to decreasing memory spatial locality is channel, column, row. Thus pixel intensity can be retrieved as follows:
Coordinate (0, 0) corresponds to the top-left corner of the image. Coordinate (width-1, height-1) corresponds to the bottom-right corner of the image.
Conversion from/to an OpenCV Mat is as follows:
| Data Fields | ||
|---|---|---|
| uint8_t * | data | Buffer of pixel intensities. |
| size_t | width | Column count in pixels. |
| size_t | height | Row count in pixels. |
| size_t | step | Bytes per row, including padding. |
| roc_color_space | color_space | Interpretation of roc_image::data. |
| roc_media_id | media_id | See roc_media_id. |
| roc_camera_id | camera_id | See roc_camera_id. |
| roc_time | timestamp | Timestamp associated with the image, if applicable. |
| struct roc_roi |
Image region of interest to restrict processing.
Regions of interest (ROIs) can be specified as either absolute pixel values or as fractions of the image size. roc_roi_is_fractional determines which convention is used.
Common representation for still images and video frames.
Images can be read with roc_read_image or roc_read_frame, and freed with roc_free_image.
Pixels are stored in row-major order. In other words, pixel layout with respect to decreasing memory spatial locality is channel, column, row. Thus pixel intensity can be retrieved as follows:
Coordinate (0, 0) corresponds to the top-left corner of the image. Coordinate (width-1, height-1) corresponds to the bottom-right corner of the image.
Conversion from/to an OpenCV Mat is as follows:
Image region of interest to restrict processing.
Regions of interest (ROIs) can be specified as either absolute pixel values or as fractions of the image size. roc_roi_is_fractional determines which convention is used.
| enum roc_color_space |
| roc_roi roc_roi_get | ( | float | x, |
| float | y, | ||
| float | width, | ||
| float | height | ||
| ) |
Construct a roc_roi.
| [in] | x | roc_roi::x. |
| [in] | y | roc_roi::y. |
| [in] | width | roc_roi::width. |
| [in] | height | roc_roi::height. |
| bool roc_roi_is_null | ( | roc_roi | roi | ) |
true if the area of roi is 0.
| [in] | roi | ROI to check for NULL. |
| bool roc_roi_is_fractional | ( | roc_roi | roi | ) |
Fractional regions of interest are scaled by the image width and height.
A roc_roi is considered fractional if roc_roi::width and roc_roi::height are greater than zero but less than or equal to one. In this case roc_roi::x and roc_roi::width are implicitly scaled by roc_image::width, and roc_roi::y and roc_roi::height are implicitly scaled by roc_image::height.
| [in] | roi | ROI to check for fractional size. |
| bool roc_roi_within | ( | roc_roi | test, |
| roc_roi | reference, | ||
| size_t | image_width, | ||
| size_t | image_height, | ||
| float | min_overlap | ||
| ) |
Determine if a rectangle is contained within a region of interest.
| [in] | test | Test region of interest. |
| [in] | reference | Reference region of interest. |
| [in] | image_width | To be used if reference or test is roc_roi_is_fractional. |
| [in] | image_height | To be used if reference or test is roc_roi_is_fractional. |
| [in] | min_overlap | Fractional area of test that must be contained within reference. |
| bool roc_roi_within_set | ( | roc_roi | test, |
| const roc_roi * | include, | ||
| size_t | num_include, | ||
| const roc_roi * | exclude, | ||
| size_t | num_exclude, | ||
| size_t | image_width, | ||
| size_t | image_height, | ||
| float | min_overlap | ||
| ) |
Determine if a rectangle satisfies the sets of include and exclude regions of interest.
| [in] | test | Test region of interest. |
| [in] | include | Regions for which test must be contained within at least one, or NULL. |
| [in] | num_include | Length of include. |
| [in] | exclude | Regions for which test must not be contained within any, or NULL. |
| [in] | num_exclude | Length of exclude. |
| [in] | image_width | To be used if any roc_roi is roc_roi_is_fractional. |
| [in] | image_height | To be used if any roc_roi is roc_roi_is_fractional. |
| [in] | min_overlap | Fractional area of test that must be contained within reference. |
| roc_error roc_new_image | ( | size_t | width, |
| size_t | height, | ||
| size_t | step, | ||
| roc_color_space | color_space, | ||
| roc_media_id | media_id, | ||
| roc_camera_id | camera_id, | ||
| roc_time | timestamp, | ||
| const uint8_t * | input_byte_array, | ||
| roc_image * | image | ||
| ) |
Construct a new image.
This function initializes a roc_image with the provided parameters and allocates memory for roc_image::data. If the provided input_byte_array is NULL, this function leaves the allocated buffer uninitialized, otherwise it initializes the allocated data buffer by copying input_byte_array.
Free image after use with roc_free_image.
| [in] | width | See roc_image::width. |
| [in] | height | See roc_image::height. |
| [in] | step | See roc_image::step. |
| [in] | color_space | See roc_image::color_space. |
| [in] | media_id | See roc_image::media_id. |
| [in] | camera_id | See roc_image::camera_id. |
| [in] | timestamp | See roc_image::timestamp. |
| [in] | input_byte_array | See roc_image::data. |
| [out] | image | Output image. |
Deep copy an image.
| [in] | src | Image to copy to dst. |
| [out] | dst | Uninitialized output to hold a copy of src. |
Rotate an image clockwise in intervals of 90 degrees.
image is rotated in-place. degrees must be evenly divisible by 90. A negative value indicates a counter-clockwise rotation.
| [in,out] | image | Image to rotate. |
| [in] | degrees | Degrees to rotate image clockwise. |
Swap red and blue channels to convert between RGB and BGR color spaces.
| [in,out] | image | Image to swap channels in-place. |
Convert a color image to grayscale.
Converts an image from ROC_BGR24 to ROC_GRAY8. Free dst after use with roc_free_image.
| [in] | src | Input color image. |
| [out] | dst | Output grayscale image. |
Expand a grayscale image to color.
Converts an image from ROC_GRAY8 to ROC_BGR24. The grayscale channel is copied int the red, green and blue channels of dst. Free dst after use with roc_free_image.
| [in] | src | Input grayscale image. |
| [out] | dst | Output color image. |
Copy a roc_image to a pre-allocated ARGB_8888 buffer.
ARGB_8888 is the common format for the Android Bitmap class. Despite the name, the true byte order is RGBA.
| [in] | src | Input image to copy of type ROC_BGR24. |
| [out] | output_byte_array | Output pre-allocated ARGB_8888 data buffer of length 4 * roc_image::width * roc_image::height bytes. |
| roc_error roc_from_rgba | ( | const uint8_t * | input_byte_array, |
| size_t | width, | ||
| size_t | height, | ||
| size_t | step, | ||
| roc_image * | image | ||
| ) |
Initialize a roc_image from an ARGB_8888 buffer.
Free image after use with roc_free_image.
| [in] | input_byte_array | ARGB_8888 buffer. |
| [in] | width | Width of the input_byte_array image. |
| [in] | height | Height of the input_byte_array image. |
| [in] | step | Step of the input_byte_array image. |
| [out] | image | Uninitialized output image to construct. |
| roc_error roc_from_bgra | ( | const uint8_t * | input_byte_array, |
| size_t | width, | ||
| size_t | height, | ||
| size_t | step, | ||
| roc_image * | image | ||
| ) |
Initialize a roc_image from a BGRA_8888 buffer.
Free image after use with roc_free_image.
| [in] | input_byte_array | BGRA_8888 buffer. |
| [in] | width | Width of the input_byte_array image. |
| [in] | height | Height of the input_byte_array image. |
| [in] | step | Step of the input_byte_array image. |
| [out] | image | Uninitialized output image to construct. |
| roc_error roc_from_yuv | ( | const uint8_t * | y_in, |
| const uint8_t * | u_in, | ||
| const uint8_t * | v_in, | ||
| size_t | y_row_stride, | ||
| size_t | uv_row_stride, | ||
| size_t | uv_pixel_stride, | ||
| size_t | width, | ||
| size_t | height, | ||
| roc_image * | image | ||
| ) |
Initialize a roc_image from a YUV_420_888 buffer.
YUV_420_888 is the common raw camera format for the Android Image class.
Free image after use with roc_free_image.
| [in] | y_in | Y channel buffer. |
| [in] | u_in | U channel buffer. |
| [in] | v_in | V channel buffer. |
| [in] | y_row_stride | Y channel row stride. |
| [in] | uv_row_stride | U and V channel row stride. |
| [in] | uv_pixel_stride | U and V channel pixel stride. |
| [in] | width | Image width. |
| [in] | height | Image height. |
| [out] | image | Uninitialized output image to construct. |
| roc_error roc_enhance_contrast | ( | const roc_image | src, |
| float | clip_limit, | ||
| int | num_tiles, | ||
| roc_image * | dst | ||
| ) |
Image contrast enhancement.
This function can be used to pre-process a low-contrast image to reduce missed detections.
Free dst after use with roc_free_image.
| [in] | src | Input low-contrast image. |
| [in] | clip_limit | Adaptive histogram equalization contrast limit. For more information please reference Contrast Limited AHE. |
| [in] | num_tiles | Partition the image into this many horizontal and vertical tiles. |
| [out] | dst | Uninitialized output contrast-enhanced image. |
Read a PPM or PGM image file.
Free image after use with roc_free_image.
| [in] | file_name | Path to the image file. |
| [out] | image | Address to store the decoded image. |
Write a PPM or PGM image file.
image roc_image::roc_color_space value.| [in] | file_name | Path to the image file. |
| [in] | image | Image to write. |
| roc_error roc_set_string | ( | const char * | src, |
| roc_string * | dst | ||
| ) |
Set a string value.
str must be initialized, if it already has a value call roc_free_string first.| [in] | src | roc_string to copy. |
| [out] | dst | roc_string to set. |
| roc_error roc_free_string | ( | roc_string * | str | ) |
Free a roc_string previously returned by another function.
If str is NULL, this function does nothing.
| [in,out] | str | roc_string to free. |
| roc_error roc_free_buffer | ( | roc_buffer * | buffer | ) |
Free a roc_buffer previously returned by another function.
If buffer is NULL, this function does nothing.
| [in,out] | buffer | roc_buffer to free. |
1.8.15