Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
Object Detection

Object Detection's low-level API for Simd::Detection. More...

Functions

SIMD_API void * SimdDetectionLoadA (const char *path)
 Loads an OpenCV-format cascade classifier from an XML file. More...
 
SIMD_API void * SimdDetectionLoadStringXml (char *xml)
 Loads an OpenCV-format cascade classifier from a mutable XML string. More...
 
SIMD_API void SimdDetectionInfo (const void *data, size_t *width, size_t *height, SimdDetectionInfoFlags *flags)
 Gets original window size and feature flags of a loaded classifier cascade. More...
 
SIMD_API void * SimdDetectionInit (const void *data, uint8_t *sum, size_t sumStride, size_t width, size_t height, uint8_t *sqsum, size_t sqsumStride, uint8_t *tilted, size_t tiltedStride, int throughColumn, int int16)
 Initializes a working classifier cascade context for integral images of a fixed input image size. More...
 
SIMD_API void SimdDetectionPrepare (void *hid)
 Prepares hidden classifier cascade context after integral images have been updated. More...
 
SIMD_API void SimdDetectionHaarDetect32fp (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs HAAR cascade detection with 32-bit floating-point arithmetic and scans every point. More...
 
SIMD_API void SimdDetectionHaarDetect32fi (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs HAAR cascade detection with 32-bit floating-point arithmetic and scans every second point. More...
 
SIMD_API void SimdDetectionLbpDetect32fp (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs LBP cascade detection with 32-bit integral sums and floating-point stage weights, scanning every point. More...
 
SIMD_API void SimdDetectionLbpDetect32fi (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs LBP cascade detection with 32-bit integral sums and floating-point stage weights, scanning every second point. More...
 
SIMD_API void SimdDetectionLbpDetect16ip (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs LBP cascade detection with 16-bit integral sums and integer stage weights, scanning every point. More...
 
SIMD_API void SimdDetectionLbpDetect16ii (const void *hid, const uint8_t *mask, size_t maskStride, ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom, uint8_t *dst, size_t dstStride)
 Performs LBP cascade detection with 16-bit integral sums and integer stage weights, scanning every second point. More...
 

Detailed Description

Object Detection's low-level API for Simd::Detection.

Function Documentation

◆ SimdDetectionLoadA()

void * SimdDetectionLoadA ( const char *  path)

Loads an OpenCV-format cascade classifier from an XML file.

The loader parses BOOST cascades with HAAR or LBP features. HOG cascades, tree-based cascades and old cascade formats are not supported. The returned object contains parsed cascade data (original window size, stages, features and flags) and is used to create working detection contexts.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]path- a path to XML cascade file.
Returns
a pointer to loaded cascade. On error it returns NULL. This pointer is used in functions SimdDetectionInfo and SimdDetectionInit, and must be released by function SimdRelease.

◆ SimdDetectionLoadStringXml()

void * SimdDetectionLoadStringXml ( char *  xml)

Loads an OpenCV-format cascade classifier from a mutable XML string.

The loader parses BOOST cascades with HAAR or LBP features. HOG cascades, tree-based cascades and old cascade formats are not supported. The XML buffer must be zero-terminated and writable: the parser can modify it while parsing. The buffer is needed only during this call; parsed cascade data is stored in the returned object.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in,out]xml- a zero-terminated writable XML string with classifier cascade.
Returns
a pointer to loaded cascade. On error it returns NULL. This pointer is used in functions SimdDetectionInfo and SimdDetectionInit, and must be released by function SimdRelease.

◆ SimdDetectionInfo()

void SimdDetectionInfo ( const void *  data,
size_t *  width,
size_t *  height,
SimdDetectionInfoFlags flags 
)

Gets original window size and feature flags of a loaded classifier cascade.

For a valid cascade this function writes original scanning window size and cascade flags to non-NULL output pointers. If data is NULL the function does nothing. The low bits of flags contain cascade feature type (see SimdDetectionInfoFeatureMask). Other bits describe presence of tilted HAAR features and availability of 16-bit LBP detection.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]data- a pointer to cascade received from SimdDetectionLoadA or SimdDetectionLoadStringXml.
[out]width- a pointer to returned width of original cascade window. It can be NULL.
[out]height- a pointer to returned height of original cascade window. It can be NULL.
[out]flags- a pointer to returned flags with other information (see SimdDetectionInfoFlags). It can be NULL.

◆ SimdDetectionInit()

void * SimdDetectionInit ( const void *  data,
uint8_t *  sum,
size_t  sumStride,
size_t  width,
size_t  height,
uint8_t *  sqsum,
size_t  sqsumStride,
uint8_t *  tilted,
size_t  tiltedStride,
int  throughColumn,
int  int16 
)

Initializes a working classifier cascade context for integral images of a fixed input image size.

The hidden context stores references to provided integral images and precomputes pointers to cascade features. The sum image size is also the integral image size; the corresponding source gray image has width - 1 by height - 1 pixels. Integral images must be calculated by SimdIntegral with 32-bit integer sum format. HAAR cascades require sum and squared sum images, and require tilted image only when SimdDetectionInfoHasTilted is set. LBP cascades use only the sum image.

If throughColumn is non-zero, the context is prepared for the interlaced detection functions (*32fi and *16ii), which scan every second row and column. If int16 is non-zero and the loaded LBP cascade has SimdDetectionInfoCanInt16, the context uses a 16-bit integer LBP representation and must be used with *16ip or *16ii detection functions. Otherwise LBP detection uses 32-bit integral sums and must be used with *32fp or *32fi detection functions.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]data- a pointer to cascade received from SimdDetectionLoadA or SimdDetectionLoadStringXml.
[in]sum- a pointer to 32-bit integer integral sum image of input 8-bit gray image. See SimdIntegral in order to estimate this integral sum.
[in]sumStride- a row size of the sum image (in bytes).
[in]width- a width of the integral images. It must be one greater than width of input 8-bit gray image.
[in]height- a height of the integral images. It must be one greater than height of input 8-bit gray image.
[in]sqsum- a pointer to 32-bit integer squared integral sum image. It is required for HAAR cascades and ignored for LBP cascades.
[in]sqsumStride- a row size of the sqsum image (in bytes).
[in]tilted- a pointer to 32-bit integer tilted integral sum image. It is required only for HAAR cascades with tilted features.
[in]tiltedStride- a row size of the tilted image (in bytes).
[in]throughColumn- a flag to prepare context for scanning every second row and column.
[in]int16- a flag to request 16-bit integer LBP detection (see SimdDetectionInfoCanInt16).
Returns
a pointer to hidden cascade. On error it returns NULL. This pointer is used in functions SimdDetectionPrepare, SimdDetectionHaarDetect32fp, SimdDetectionHaarDetect32fi, SimdDetectionLbpDetect32fp, SimdDetectionLbpDetect32fi, SimdDetectionLbpDetect16ip and SimdDetectionLbpDetect16ii. It must be released by function SimdRelease.

◆ SimdDetectionPrepare()

void SimdDetectionPrepare ( void *  hid)

Prepares hidden classifier cascade context after integral images have been updated.

This function rebuilds internal derived buffers from current integral image data: through-column copies for interlaced scanning and 16-bit converted sums for integer LBP detection. It must be called after every update of integral images and before any call to SimdDetectionHaarDetect32fp, SimdDetectionHaarDetect32fi, SimdDetectionLbpDetect32fp, SimdDetectionLbpDetect32fi, SimdDetectionLbpDetect16ip or SimdDetectionLbpDetect16ii.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden cascade received from SimdDetectionInit.

◆ SimdDetectionHaarDetect32fp()

void SimdDetectionHaarDetect32fp ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs HAAR cascade detection with 32-bit floating-point arithmetic and scans every point.

Use this function only with a HAAR hidden cascade initialized with throughColumn equal to 0. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. For each point in the half-open rectangle [left, right) x [top, bottom), a zero mask value skips detection and a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden HAAR cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).

◆ SimdDetectionHaarDetect32fi()

void SimdDetectionHaarDetect32fi ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs HAAR cascade detection with 32-bit floating-point arithmetic and scans every second point.

Use this function only with a HAAR hidden cascade initialized with throughColumn not equal to 0. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. The function checks every second row and column in the half-open rectangle [left, right) x [top, bottom). A zero mask value skips detection; a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden HAAR cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).

◆ SimdDetectionLbpDetect32fp()

void SimdDetectionLbpDetect32fp ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs LBP cascade detection with 32-bit integral sums and floating-point stage weights, scanning every point.

Use this function only with an LBP hidden cascade initialized with throughColumn equal to 0 and without 16-bit integer representation. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. For each point in the half-open rectangle [left, right) x [top, bottom), a zero mask value skips detection and a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden LBP cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).

◆ SimdDetectionLbpDetect32fi()

void SimdDetectionLbpDetect32fi ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs LBP cascade detection with 32-bit integral sums and floating-point stage weights, scanning every second point.

Use this function only with an LBP hidden cascade initialized with throughColumn not equal to 0 and without 16-bit integer representation. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. The function checks every second row and column in the half-open rectangle [left, right) x [top, bottom). A zero mask value skips detection; a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden LBP cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).

◆ SimdDetectionLbpDetect16ip()

void SimdDetectionLbpDetect16ip ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs LBP cascade detection with 16-bit integral sums and integer stage weights, scanning every point.

Use this function only with an LBP hidden cascade initialized with throughColumn equal to 0 and int16 not equal to 0. The loaded cascade must have SimdDetectionInfoCanInt16 set. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. For each point in the half-open rectangle [left, right) x [top, bottom), a zero mask value skips detection and a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden LBP cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).

◆ SimdDetectionLbpDetect16ii()

void SimdDetectionLbpDetect16ii ( const void *  hid,
const uint8_t *  mask,
size_t  maskStride,
ptrdiff_t  left,
ptrdiff_t  top,
ptrdiff_t  right,
ptrdiff_t  bottom,
uint8_t *  dst,
size_t  dstStride 
)

Performs LBP cascade detection with 16-bit integral sums and integer stage weights, scanning every second point.

Use this function only with an LBP hidden cascade initialized with throughColumn not equal to 0 and int16 not equal to 0. The loaded cascade must have SimdDetectionInfoCanInt16 set. SimdDetectionPrepare must be called before this function. The mask and bounding box restrict positions of the left-top corner of the scanning window. The function checks every second row and column in the half-open rectangle [left, right) x [top, bottom). A zero mask value skips detection; a non-zero mask value allows it. When a window passes the cascade, the corresponding dst point is set to 1. Initialize dst before calling this function if a zero background is required.

Note
This function is used for implementation of Simd::Detection.
Parameters
[in]hid- a pointer to hidden LBP cascade received from SimdDetectionInit.
[in]mask- a pointer to 8-bit mask image. Its size is equal to source image size.
[in]maskStride- a row size of the mask image (in bytes).
[in]left- a left side of scan rectangle for window left-top corner.
[in]top- a top side of scan rectangle for window left-top corner.
[in]right- a right side of scan rectangle for window left-top corner.
[in]bottom- a bottom side of scan rectangle for window left-top corner.
[out]dst- a pointer to 8-bit output image. Points set to 1 refer to left-top corners of detected objects.
[in]dstStride- a row size of the dst image (in bytes).