# Object detection

- FASTCV\_API int fcvDescriptor17x17u8To36s8(const uint8\_t \*\_\_restrict patch, int8\_t \*\_\_restrict descriptorChar, int32\_t \*\_\_restrict descriptorNormSq)

    - Create a 36-dimension gradient based descriptor on 17x17 patch.

- Parameters:

    - - **patch** – Input luminance data for 17x17 patch to describe.
- **descriptorChar** – Output descriptor vector. 36 x 8-bit vector. Normalized and quantized to range [-127, 127]
- **descriptorNormSq** – Output squared norm (L2 norm) of the descriptor vector.

- FASTCV\_API int fcvMserInit(const unsigned int width, const unsigned int height, unsigned int delta, unsigned int minArea, unsigned int maxArea, float maxVariation, float minDiversity, void \*\*mserHandle)

    - Function to initialize MSER. To invoke MSER functionality, 3 functions have to be called: fcvMserInit, fcvMseru8, fcvMserRelease. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { fcvMseru8 (mserHandle,…); fcvMserRelease(mserHandle); }.

- Parameters:

    - - **width** – Width of the image for which MSER has to be done.
- **height** – Height of the image for which MSER has to be done.
- **delta** – Delta to be used in MSER algorithm (the difference in grayscale values within which the region is stable ). Typical value range [0.8 8], typical value 2
- **minArea** – Minimum area (number of pixels) of a mser contour. Typical value range [10 50], typical value 30
- **maxArea** – Maximum area (number of pixels) of a mser contour. Typical value 14400 or 0.25\*width\*height
- **maxVariation** – Maximum variation in grayscale between 2 levels allowed. Typical value range [0.1 1.0], typical value 0.15
- **minDiversity** – Minimum diversity in grayscale between 2 levels allowed. Typical value range [0.1 1.0], typical value 0.2
- **mserHandle** – Output. the mserHandle to be used in subsequent calls.

- Returns:

    - 1 if successful. 0 if unsuccessful, mserHandle is invalid.

- FASTCV\_API void fcvMserRelease(void \*mserHandle)

    - Function to release MSER resources.

- Parameters:

    - **mserHandle** – Handle to be used to free up MSER resources.

- FASTCV\_API void fcvMseru8(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, unsigned int srcWidth, unsigned int srcHeight, unsigned int srcStride, unsigned int maxContours, unsigned int \*\_\_restrict numContours, unsigned int \*\_\_restrict numPointsInContour, unsigned int pointsArraySize, unsigned int \*\_\_restrict pointsArray)

    - Function to invoke MSER. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { fcvMseru8 (mserHandle,…); fcvMserRelease(mserHandle); }.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvMseru8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga4eb56dbc6f78a3394be58d417761114f). In the 2.0.0 release, fcvMseru8\_v2 will be renamed to fcvMseru8. and the signature of fcvMseru8 as it appears now, will be removed.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserInit.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserInit.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pointsArraySize** – Size of the output points Array. Typical size: (# of pixels in source image) \* 30
- **pointsArray** – Output. This is the points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pointArraySize. pointsArray[0…numPointsInContour[0]-1] defines the first MSER region, pointsArray[numPointsInContour[0] .. numPointsInContour[1]-1] defines 2nd MSER region and so on.

- FASTCV\_API void fcvMserExtu8(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, unsigned int srcWidth, unsigned int srcHeight, unsigned int srcStride, unsigned int maxContours, unsigned int \*\_\_restrict numContours, unsigned int \*\_\_restrict numPointsInContour, unsigned int \*\_\_restrict pointsArray, unsigned int pointsArraySize, unsigned int \*\_\_restrict contourVariation, int \*\_\_restrict contourPolarity, unsigned int \*\_\_restrict contourNodeId, unsigned int \*\_\_restrict contourNodeCounter)

    - Function to invoke MSER, with additional outputs for each contour. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { fcvMserExtu8 (mserHandle,…); fcvMserRelease(mserHandle); }.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvMserExtu8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga624ade2f96b970ee44cbb1eb8232ae23). In the 2.0.0 release, fcvMserExtu8\_v2 will be renamed to fcvMserExtu8. and the signature of fcvMserExtu8 as it appears now, will be removed.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserInit.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserInit.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned. Application dependent. OCR usually requires 100-1000 contours. Segmentation usually requires 50-100
- **numContours** – Output, Number of MSER contours in the region.
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pointsArraySize** – Size of the output points Array. Typical size: (# of pixels in source image)\*30
- **pointsArray** – Output. This is the points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pointArraySize. pointsArray[0…numPointsInContour[0]-1] defines the first MSER region; pointsArray[numPointsInContour[0] .. numPointsInContour[1]-1] defines 2nd MSER region and so on.
- **contourVariation** – Output, Variation for each contour from previous grey level. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourPolarity** – Output, Polarity for each contour. This value is 1 if this is a MSER+ region, -1 if this is a MSER- region. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourNodeId** – Output, Node id for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours
- **contourNodeCounter** – Output, Node counter for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.

- FASTCV\_API int fcvMseru8\_v2(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t maxContours, uint32\_t \*\_\_restrict numContours, uint16\_t \*\_\_restrict recArray, uint32\_t \*\_\_restrict numPointsInContour, uint32\_t pointsArraySize, uint16\_t \*\_\_restrict pointsArray)

    - Function to invoke MSER with a smaller memory footprint and the (optional) output of contour bound boxes. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { if ( !fcvMseru8\_v2 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserInit.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserInit.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **recArray** – Output, This is the bounding rectangle info for each contour. If recArray is specified as NULL, MSER will skip finding the bounding rectangles of the contours. Typical allocation size: 4\*maxContours. rectArray[0..3] defines the xMin, xMax, yMax, yMin positions of the first MSER contour, rectArray[4..7] defines the xMin, xMax, yMax, yMin positions of the second MSER contour, and so on.
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pointsArraySize** – Size of the output points Array. Typical size: (# of pixels in source image) \* 30
- **pointsArray** – Output. This is the points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pointArraySize. pointsArray[0…numPointsInContour[0]-1] defines the first MSER region, pointsArray[numPointsInContour[0] .. numPointsInContour[1]-1] defines 2nd MSER region and so on.

- Returns:

    - 1 if successful. 0 if failure, e.g., to indicate detected contours are greater than maxContours. In that case, please consider increasing maxContours.

- FASTCV\_API int fcvMserExtu8\_v2(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t maxContours, uint32\_t \*\_\_restrict numContours, uint16\_t \*\_\_restrict recArray, uint32\_t \*\_\_restrict numPointsInContour, uint32\_t pointsArraySize, uint16\_t \*\_\_restrict pointsArray, uint32\_t \*\_\_restrict contourVariation, int8\_t \*\_\_restrict contourPolarity, uint32\_t \*\_\_restrict contourNodeId, uint32\_t \*\_\_restrict contourNodeCounter)

    - Function to invoke MSER with a smaller memory footprint, the (optional) output of contour bound boxes, and additional information. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { if ( !fcvMserExtu8\_v2 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserInit.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserInit.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **recArray** – Output, This is the bounding rectangle info for each contour. If recArray is specified as NULL, MSER will skip finding the bounding rectangles of the contours. Typical allocation size: 4\*maxContours. rectArray[0..3] defines the xMin, xMax, yMax, yMin positions of the first MSER contour, rectArray[4..7] defines the xMin, xMax, yMax, yMin positions of the second MSER contour, and so on.
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pointsArraySize** – Size of the output points Array. Typical size: (# of pixels in source image) \* 30
- **pointsArray** – Output. This is the points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pointArraySize. pointsArray[0…numPointsInContour[0]-1] defines the first MSER region, pointsArray[numPointsInContour[0] .. numPointsInContour[1]-1] defines 2nd MSER region and so on.
- **contourVariation** – Output, Variation for each contour from previous grey level. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourPolarity** – Output, Polarity for each contour. This value is 1 if this is a MSER+ region, -1 if this is a MSER- region. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourNodeId** – Output, Node id for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours
- **contourNodeCounter** – Output, Node counter for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.

- Returns:

    - 1 if successful. 0 if failure, e.g., to indicate detected contours are greater than maxContours. In that case, please consider increasing maxContours.

- FASTCV\_API int fcvMserExtu8\_v3(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t maxContours, uint32\_t \*\_\_restrict numContours, uint16\_t \*\_\_restrict recArray, uint32\_t \*\_\_restrict staPointsInPath, uint32\_t \*\_\_restrict numPointsInContour, uint32\_t pathArraySize, uint16\_t \*\_\_restrict pathArray, uint32\_t \*\_\_restrict contourVariation, int8\_t \*\_\_restrict contourPolarity, uint32\_t \*\_\_restrict contourNodeId, uint32\_t \*\_\_restrict contourNodeCounter)

    - Function to invoke MSER with a smaller memory footprint, the (optional) output of contour bound boxes, and additional information. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserInit (width,……..,&mserHandle)) { if ( !fcvMserExtu8\_v3 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserInit.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserInit.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **recArray** – Output, This is the bounding rectangle info for each contour. If recArray is specified as NULL, MSER will skip finding the bounding rectangles of the contours. Typical allocation size: 4\*maxContours. rectArray[0..3] defines the xMin, xMax, yMax, yMin positions of the first MSER contour, rectArray[4..7] defines the xMin, xMax, yMax, yMin positions of the second MSER contour, and so on.
- **staPointsInPath** – Output. Return the index of contour starting points in pathArray. This memory has to be allocated by the caller. The allocated size should be maxContours\*sizeof(uint32\_t).
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pathArraySize** – Input. The size of output pathArray in terms of how many uint16\_t numbers. Must be srcWidth\*srcHeight\*4. Note: this parameter is not measured in terms of bytes.
- **pathArray** – Output. This is the compressed representation of points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pathArraySize\*sizeof(uint16\_t). For example: pathArray[ staPointsInPath[0] ] : x coord of the FIRST point in the FIRST mser region. pathArray[ staPointsInPath[0] + 1 ] : y coord of the FIRST point in the FIRST mser region. pathArray[ staPointsInPath[0] + 2 ] : x coord of the SECOND point in the FIRST mser region. pathArray[ staPointsInPath[0] + 3 ] : y coord of the SECOND point in the FIRST mser region… . pathArray[ staPointsInPath[0] + 2\*numPointsInContour[0] - 2 ] : x coord of the LAST point in the FIRST mser region. pathArray[ staPointsInPath[0] + 2\*numPointsInContour[0] - 1 ] : y coord of the LAST point in the FIRST mser region. and pathArray[ staPointsInPath[1] ] : x coord of the FIRST point in the SECOND mser region. pathArray[ staPointsInPath[1] + 1 ] : y coord of the FIRST point in the SECOND mser region. pathArray[ staPointsInPath[1] + 2 ] : x coord of the SECOND point in the SECOND mser region. pathArray[ staPointsInPath[1] + 3 ] : y coord of the SECOND point in the SECOND mser region… . pathArray[ staPointsInPath[1] + 2\*numPointsInContour[1] - 2 ] : x coord of the LAST point in the SECOND mser region. pathArray[ staPointsInPath[1] + 2\*numPointsInContour[1] - 1 ] : y coord of the LAST point in the SECOND mser region… .
- **contourVariation** – Output, Variation for each contour from previous grey level. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourPolarity** – Output, Polarity for each contour. This value is 1 if this is a MSER+ region, -1 if this is a MSER- region. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.
- **contourNodeId** – Output, Node id for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours
- **contourNodeCounter** – Output, Node counter for each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller with size of maxContours.

- Returns:

    - 1 if successful. 0 if failure, e.g., to indicate detected contours are greater than maxContours. In that case, please consider increasing maxContours.

- FASTCV\_API int fcvMserNN8Init(const uint32\_t width, const uint32\_t height, uint32\_t delta, uint32\_t minArea, uint32\_t maxArea, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) maxVariation, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) minDiversity, void \*\*mserHandle)

    - Function to initialize 8-neighbor MSER. To invoke 8-neighbor MSER functionality, 3 functions have to be called: fcvMserNN8Init, fcvMserNN8u8, fcvMserRelease. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserNN8Init (width,……..,&mserHandle)) { if ( !fcvMserNN8u8 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **width** – Width of the image for which MSER has to be done.
- **height** – Height of the image for which MSER has to be done.
- **delta** – Delta to be used in MSER algorithm (the difference in grayscale values within which the region is stable ). Typical value range [0.8 8], typical value 2
- **minArea** – Minimum area (number of pixels) of a mser contour. Typical value range [10 50], typical value 30
- **maxArea** – Maximum area (number of pixels) of a mser contour. Typical value 14400 or 0.25\*width\*height
- **maxVariation** – Maximum variation in grayscale between 2 levels allowed. Typical value range [0.1 1.0], typical value 0.15
- **minDiversity** – Minimum diversity in grayscale between 2 levels allowed. Typical value range [0.1 1.0], typical value 0.2
- **mserHandle** – Output. the mserHandle to be used in subsequent calls.

- Returns:

    - 1 if successful. 0 if unsuccessful, mserHandle is invalid.

- FASTCV\_API int fcvMserNN8u8(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t maxContours, uint32\_t \*\_\_restrict numContours, uint16\_t \*\_\_restrict recArray, uint32\_t \*\_\_restrict numPointsInContour, uint32\_t pointsArraySize, uint16\_t \*\_\_restrict pointsArray)

    - Function to invoke 8-neighbor MSER. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserNN8Init (width,……..,&mserHandle)) { if ( !fcvMserNN8u8 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserNN8Init.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserNN8Init.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **recArray** – Output, This is the bounding rectangle info for each contour. If recArray is specified as NULL, MSER will skip finding the bounding rectangles of the contours. Typical allocation size: 4\*maxContours. rectArray[0..3] defines the xMin, xMax, yMax, yMin positions of the first MSER contour, rectArray[4..7] defines the xMin, xMax, yMax, yMin positions of the second MSER contour, and so on.
- **numPointsInContour** – Output, Number of points in each contour. This will have values filled up for the first (\*numContours) values. This memory has to be allocated by the caller.
- **pointsArraySize** – Size of the output points Array. Typical size: (# of pixels in source image) \* 30
- **pointsArray** – Output. This is the points in all the contours. This is a linear array, whose memory has to be allocated by the caller. Typical allocation size: pointArraySize. pointsArray[0…numPointsInContour[0]-1] defines the first MSER region, pointsArray[numPointsInContour[0] .. numPointsInContour[1]-1] defines 2nd MSER region and so on.

- Returns:

    - 1 if successful. 0 if failure, e.g., to indicate detected contours are greater than maxContours. In that case, please consider increasing maxContours.

- FASTCV\_API int fcvMserExtNN8u8(void \*mserHandle, const uint8\_t \*\_\_restrict srcPtr, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t maxContours, uint32\_t \*\_\_restrict numContours, uint16\_t \*\_\_restrict recArray, uint32\_t \*\_\_restrict numPointsInContour, uint32\_t pointsArraySize, uint16\_t \*\_\_restrict pointsArray, uint32\_t \*\_\_restrict contourVariation, int8\_t \*\_\_restrict contourPolarity, uint32\_t \*\_\_restrict contourNodeId, uint32\_t \*\_\_restrict contourNodeCounter)

    - Function to invoke 8-neighbor MSER, , with additional outputs for each contour. Image width has to be greater than 50, and image height has to be greater than 5. Pixels at the image boundary are not processed. If boundary pixels are important for a particular application, please consider padding the input image with dummy pixels of one pixel wide. Here is the typical usage: void \*mserHandle; if (fcvMserNN8Init (width,……..,&mserHandle)) { if ( !fcvMserExtNN8u8 (mserHandle,…) ) { // Error handle } fcvMserRelease(mserHandle); }.

- Parameters:

    - - **mserHandle** – The MSER Handle returned by init.
- **srcPtr** – Pointer to an image array (unsigned char ) for which MSER has to be done.
- **srcWidth** – Width of the source image. **NOTE:** srcWidth must be &lt;= the width passed to fcvMserNN8Init.
- **srcHeight** – Height of the source image. **NOTE:** srcHeight must be &lt;= the height passed to fcvMserNN8Init.
- **srcStride** – Stride of the source image.
- **maxContours** – Maximum contours that will be returned.
- **numContours** – Output, Number of MSER contours in the region.
- **recArray** – Output, This is the bounding rectangle info for each contour. If recArray is specified as NULL, MSER will skip finding the bounding rectangles of the contours. Typical allocation size: 4\*maxContours. rectArray[0..3] defines the xMin, xMax, yMax, yMin positions of the first MSER contour, rectArray[4..7] defines the xMin, xMax, yMax, yMin positions of the second MSER contour, and so on.
- **numPointsInContour** –
- **pointsArraySize** –
- **pointsArray** –
- **contourVariation** –
- **contourPolarity** –
- **contourNodeId** –
- **contourNodeCounter** –

- Returns:

    - 1 if successful. 0 if failure, e.g., to indicate detected contours are greater than maxContours. In that case, please consider increasing maxContours.

- FASTCV\_API int fcvDescriptorSampledMeanAndVar36f32(const float \*\_\_restrict src, int first, int last, int32\_t \*vind, float \*\_\_restrict means, float \*\_\_restrict vars, float \*\_\_restrict temp)

    - compute approximate mean and variance for the range of NFT4 float descriptors where descriptor elements along dimension are treated as random vars

Variances computed here do not have to be true variances because their values do not matter in kdtrees. The only thing that matters is that the ordering relation of variances is preserved

Remark

If descriptor range is &gt; 100 then only 100 samples are drawn from the range to compute approximate means and variances.

- Parameters:

    - - **src** – contiguous block of descriptors of dimension 36
- **first** – index of the first descriptor in range array vind for computing mean and var
- **last** – index of the last descriptor in range array vind for computing mean and range
- **vind** – array of randomized indexes of descriptors
- **means** – buffer for approximate means, must be 36 long
- **vars** – buffer for approximate variances, must be 36 long
- **temp** – bufffer, must be 46 long

- Returns:

    - 0 - success EFAULT - invalid address EINVAL - invalid argument

- FASTCV\_API int fcvNCCPatchOnCircle8x8u8(const uint8\_t \*\_\_restrict patch, const uint8\_t \*\_\_restrict src, unsigned short srcWidth, unsigned short srcHeight, unsigned short search\_center\_x, unsigned short search\_center\_y, unsigned short search\_radius, uint16\_t \*best\_x, uint16\_t \*best\_y, uint32\_t \*bestNCC, int findSubPixel, float \*subX, float \*subY)

    - Searches a 8x8 patch within radius around a center pixel for the max NCC.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvNCCPatchOnCircle8x8u8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga6cd488afcf5a6bd1cba7b6fb4e7d5f4f). In the 2.0.0 release, fcvNCCPatchOnCircle8x8u8\_v2 will be renamed to fcvNCCPatchOnCircle8x8u8 and the signature of fcvNCCPatchOnCircle8x8u8 as it appears now, will be removed.

- Parameters:

    - - **patch** – Pointer to 8-bit patch pixel values linearly laid out in memory.
- **src** – Pointer to 8-bit image pixel values linearly laid out in memory. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Width in pixels of the image. **WARNING:** should be multiple of 8.
- **srcHeight** – Height in pixels of the image.
- **search\_center\_x** – X location of search center in pixels of the image.
- **search\_center\_y** – Y location of search center in pixels of the image.
- **search\_radius** – Radius of search in pixels. Must be &lt;=5.
- **best\_x** – Center X location on the image of the best NCC match. The center X has 4 pixels to the left and 3 to the right.
- **best\_y** – Center Y location on the image of the best NCC match. The center Y has 4 pixels above and 3 pixels below.
- **bestNCC** – Largest value of the normalized cross-correlation found in the NCC search. It’s quantized to integer value in Q7 (between -128 and 128).
- **findSubPixel** – (0 or 1) Use parabolic interpolation of NCC values to find sub-pixel estimates.
- **subX** –

    Sub-pixel estimate for optimal NCC relative to best\_x.

    e.g., float x = (float)best\_x + subX;
- **subY** – Sub-pixel estimate for optimal NCC relative to best\_y.

- Returns:

    - 0 = OK

1 = “search\_radius” too large

2 = invalid “search\_center\_x,y”

3 = not found

- FASTCV\_API int fcvNCCPatchOnCircle8x8u8\_v2(const uint8\_t \*\_\_restrict patch, const uint8\_t \*\_\_restrict src, unsigned short srcWidth, unsigned short srcHeight, unsigned short search\_center\_x, unsigned short search\_center\_y, unsigned short search\_radius, int filterLowVariance, uint16\_t \*best\_x, uint16\_t \*best\_y, uint32\_t \*bestNCC, int findSubPixel, float \*subX, float \*subY)

    - Searches a 8x8 patch within radius around a center pixel for the max NCC.

**ATTENTION:** This function is a duplication of [fcvNCCPatchOnCircle8x8u8()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1gae7e7e79173e7c7b503fb5699974452ff) with the addition of extra parameters. This function has been added to allow for backward compatibility with the original function. When the 2.0.0 release of this library is made, this function will be renamed to: *fcvNCCPatchOnCircle8x8u8*, *fcvNCCPatchOnCircle8x8u8\_v2* will be removed, and the current signature for *fcvNCCPatchOnCircle8x8u8* will be removed. Until 2.0.0, the developer should use this implementation with the expectation of renaming it to *fcvNCCPatchOnCircle8x8u8* when transitioning to 2.0.0.

- Parameters:

    - - **patch** – Pointer to 8-bit patch pixel values linearly laid out in memory.
- **src** – Pointer to 8-bit image pixel values linearly laid out in memory. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Width in pixels of the image. **WARNING:** should be multiple of 8.
- **srcHeight** – Height in pixels of the image.
- **search\_center\_x** – X location of search center in pixels of the image.
- **search\_center\_y** – Y location of search center in pixels of the image.
- **search\_radius** – Radius of search in pixels. Must be &lt;=5.
- **filterLowVariance** – Minimum variance. Used to as threshold to compare against variance of 8x8 block of src or patch.
- **best\_x** – Center X location on the image of the best NCC match. The center X has 4 pixels to the left and 3 to the right.
- **best\_y** – Center Y location on the image of the best NCC match. The center Y has 4 pixels above and 3 pixels below.
- **bestNCC** – Largest value of the normalized cross-correlation found in the NCC search. It’s quantized to integer value in Q7 (between -128 and 128).
- **findSubPixel** – (0 or 1) Use parabolic interpolation of NCC values to find sub-pixel estimates.
- **subX** –

    Sub-pixel estimate for optimal NCC relative to best\_x.

    e.g., float x = (float)best\_x + subX;
- **subY** – Sub-pixel estimate for optimal NCC relative to best\_y.

- Returns:

    - 0 = OK

1 = “search\_radius” too large

2 = invalid “search\_center\_x,y”

3 = not found

4 = Patch has too low variance

5 = Image region has too low variance

- FASTCV\_API int fcvNCCPatchOnSquare8x8u8(const uint8\_t \*\_\_restrict patch, const uint8\_t \*\_\_restrict src, unsigned short srcWidth, unsigned short srcHeight, unsigned short search\_center\_x, unsigned short search\_center\_y, unsigned short search\_w, uint16\_t \*best\_x, uint16\_t \*best\_y, uint32\_t \*bestNCC, int doSubPixel, float \*subX, float \*subY)

    - Searches a 8x8 patch within square region around a center pixel for the max NCC.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvNCCPatchOnSquare8x8u8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga42544cc2e27f8d81fb2960626d978878). In the 2.0.0 release, fcvNCCPatchOnSquare8x8u8\_v2 will be renamed to fcvNCCPatchOnSquare8x8u8 and the signature of fcvNCCPatchOnSquare8x8u8 as it appears now, will be removed.

- Parameters:

    - - **patch** – Pointer to 8-bit patch pixel values linearly laid out in memory.
- **src** – Pointer to 8-bit image pixel values linearly laid out in memory. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Width in pixels of the image. **WARNING:** should be multiple of 8.
- **srcHeight** – Height in pixels of the image.
- **search\_center\_x** – Center X coordinate of the search window
- **search\_center\_y** – Center Y coordinate of the search window
- **search\_w** – Width of search square in pixels **WARNING:** must be 11 or less.
- **best\_x** – Center X location on the image of the best NCC match. The center X has 4 pixels to the left and 3 to the right.
- **best\_y** – Center Y location on the image of the best NCC match. The center Y has 4 pixels above and 3 pixels below.
- **bestNCC** – NCC value of the best match block. It’s quantized to integer value in Q7 (between -128 and 128).
- **doSubPixel** – (0 or 1) Use parabolic interpolation of NCC values to find sub-pixel estimates.
- **subX** –

    Sub-pixel estimate for optimal NCC relative to best\_x.

    e.g., float x = (float)best\_x + subX;
- **subY** – Sub-pixel estimate for optimal NCC relative to best\_y.

- Returns:

    - 0 = OK

1 = “search\_radius” too large

2 = invalid “search\_center\_x,y”

3 = not found

- FASTCV\_API int fcvNCCPatchOnSquare8x8u8\_v2(const uint8\_t \*\_\_restrict patch, const uint8\_t \*\_\_restrict src, unsigned short srcWidth, unsigned short srcHeight, unsigned short search\_center\_x, unsigned short search\_center\_y, unsigned short search\_w, int filterLowVariance, uint16\_t \*best\_x, uint16\_t \*best\_y, uint32\_t \*bestNCC, int doSubPixel, float \*subX, float \*subY)

    - Searches a 8x8 patch within square region around a center pixel for the max NCC.

**ATTENTION:** This function is a duplication of fcvNCCPatchOnSquare8x8u8 with the addition of extra parameters. This function has been added to allow for backward compatibility with the original function. When the 2.0.0 release of this library is made, this function will be renamed to: *fcvNCCPatchOnSquare8x8u8*, *fcvNCCPatchOnSquare8x8u8\_v2* will be removed, and the current signature for *fcvNCCPatchOnSquare8x8u8* will be removed. Until 2.0.0, the developer should use this implementation with the expectation of renaming it to *fcvNCCPatchOnSquare8x8u8* when transitioning to 2.0.0.

- Parameters:

    - - **patch** – Pointer to 8-bit patch pixel values linearly laid out in memory.
- **src** – Pointer to 8-bit image pixel values linearly laid out in memory. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Width in pixels of the image. **WARNING:** should be multiple of 8.
- **srcHeight** – Height in pixels of the image.
- **search\_center\_x** – Center X coordinate of the search window
- **search\_center\_y** – Center Y coordinate of the search window
- **search\_w** – Width of search square in pixels **WARNING:** must be 11 or less.
- **filterLowVariance** – Minimum variance. Used to as threshold to compare against variance of 8x8 block of src or patch.
- **best\_x** – Center X location on the image of the best NCC match. The center X has 4 pixels to the left and 3 to the right.
- **best\_y** – Center Y location on the image of the best NCC match. The center Y has 4 pixels above and 3 pixels below.
- **bestNCC** – NCC value of the best match block. It’s quantized to integer value in Q7 (between -128 and 128).
- **doSubPixel** – (0 or 1) Use parabolic interpolation of NCC values to find sub-pixel estimates.
- **subX** –

    Sub-pixel estimate for optimal NCC relative to best\_x.

    e.g., float x = (float)best\_x + subX;
- **subY** – Sub-pixel estimate for optimal NCC relative to best\_y.

- Returns:

    - 0 = OK

1 = “search\_radius” too large

2 = invalid “search\_center\_x,y”

3 = not found

4 = Patch has too low variance

5 = Image region has too low variance

- FASTCV\_API void fcvSumOfAbsoluteDiffs8x8u8(const uint8\_t \*\_\_restrict patch, const uint8\_t \*\_\_restrict src, unsigned int srcWidth, unsigned int srcHeight, unsigned int srcStride, uint16\_t \*\_\_restrict dst)

    - Sum of absolute differences of an image against an 8x8 template.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvSumOfAbsoluteDiffs8x8u8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1gabe93d5ebf206034c77ec152e9f577f42). In the 2.0.0 release, fcvSumOfAbsoluteDiffs8x8u8\_v2 will be renamed to fcvSumOfAbsoluteDiffs8x8u8 and the signature of fcvSumOfAbsoluteDiffs8x8u8 as it appears now, will be removed.

8x8 sum of ||A-B||. The template patch is swept over the entire image and the results are put in dst.

- Parameters:

    - - **patch** – 8x8 template
- **src** – Reference Image. **NOTE:** should be 128-bit aligned.
- **srcWidth** – Width of the src image.
- **srcHeight** – Height of the src image.
- **srcStride** – Stride of image (i.e., how many pixels between column 0 of row 1 and column 0 of row 2).
- **dst** – The dst buffer shall be width X height bytes in length. Output of SAD(A,B). dst[4][4] correspondes to the 0,0 pixel of the template aligned with the 0,0 pixel of src. The dst border values not covered by entire 8x8 patch window will remain unmodified by the function. The caller should either initialize these to 0 or ignore. **NOTE:** should be 128-bit aligned.

- FASTCV\_API void fcvSumOfAbsoluteDiffs8x8u8\_v2(const uint8\_t \*\_\_restrict patch, unsigned int patchStride, const uint8\_t \*\_\_restrict src, unsigned int srcWidth, unsigned int srcHeight, unsigned int srcStride, uint16\_t \*\_\_restrict dst, unsigned int dstStride)

    - Sum of absolute differences of an image against an 8x8 template.

**ATTENTION:** This function is a duplication of [fcvSumOfAbsoluteDiffs8x8u8()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga975d4a9d6b35921fe0833a160812b64f) with the addition of extra parameters. This function has been added to allow for backward compatibility with the original function. When the 2.0.0 release of this library is made, this function will be renamed to: *fcvSumOfAbsoluteDiffs8x8u8*, *fcvSumOfAbsoluteDiffs8x8u8\_v2* will be removed, and the current signature for *fcvSumOfAbsoluteDiffs8x8u8* will be removed. Until 2.0.0, the developer should use this implementation with the expectation of renaming it to *fcvSumOfAbsoluteDiffs8x8u8* when transitioning to 2.0.0.

8x8 sum of ||A-B||. The template patch is swept over the entire image and the results are put in dst.

- Parameters:

    - - **patch** – 8x8 template
- **patchStride** – Stride of the 8x8 template buffer
- **dstStride** – Stride of the patch (in bytes) - i.e., how many bytes between column 0 of row N and column 0 of row N+1.
- **src** – Reference Image. **NOTE:** should be 128-bit aligned.
- **srcWidth** – Width of the src image.
- **srcHeight** – Height of the src image.
- **srcStride** – Stride of image (in bytes) - i.e., how many bytes between column 0 of row N and column 0 of row N+1.
- **dst** – The dst buffer shall be at least ( width x height ) values in length. Output of SAD(A,B). dst[4][4]correspondes to the 0,0 pixel of the template aligned with the 0,0 pixel of src. The dst border values not covered by entire 8x8 patch window will remain unmodified by the function. The caller should either initialize these to 0 or ignore. **NOTE:** should be 128-bit aligned.
- **dstStride** – Stride of destination (in bytes) - i.e., how many bytes between column 0 of row N and column 0 of row N+1.

- FASTCV\_API void fcvTrackLKOpticalFlowu8(const uint8\_t \*\_\_restrict src1, const uint8\_t \*\_\_restrict src2, int srcWidth, int srcHeight, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*src1Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*src2Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*dx1Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*dy1Pyr, const float \*featureXY, float \*featureXY\_out, int32\_t \*featureStatus, int featureLen, int windowWidth, int windowHeight, int maxIterations, int nPyramidLevels, float maxResidue, float minDisplacement, float minEigenvalue, int lightingNormalized)

    - Optical flow. Bitwidth optimized implementation.

**ATTENTION:** This function’s signature will become **OBSOLETE** in a future release of this library (2.0.0). The new interface is specified in the function: [fcvTrackLKOpticalFlowu8\_v2()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga38d206c86ecb5737539c3dc3bbb95e04). In the 2.0.0 release, fcvTrackLKOpticalFlowu8\_v2 will be renamed to fcvTrackLKOpticalFlowu8 and the signature of fcvTrackLKOpticalFlowu8 as it appears now, will be removed.

- Parameters:

    - - **src1** – Input image from frame #1. **WARNING:** should be 128-bit aligned.
- **src2** – Input image from frame #2. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Input image width. **WARNING:** should be multiple of 8.
- **srcHeight** – Input image height.
- **src1Pyr** – Image Pyradmid of src1 **WARNING:** obtained by calling fcvPyramidCreateu8
- **src2Pyr** – Image Pyradmid of src2 **WARNING:** obtained by calling fcvPyramidCreateu8
- **dx1Pyr** – Horizontal Sobel gradient pyramid for src1 **NOTE:** To be left NULL. In this case the function will build the pyramid internally.
- **dy1Pyr** – Vertical Sobel grading pyraid for src1 **NOTE:** To be left NULL. In this case the function will build the pyramid internally.
- **featureXY** – Pointer to X,Y floating point, sub-pixel coordinates for features to track. Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureXY\_out** – Pointer to X,Y floating point, sub-pixel coordinates for tracked features Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureStatus** – Pointer to integer array for status of each feature defined in featureXY. featureStatus array storage must be &gt;= featureLen.
- **featureLen** – Number of features in featuresXY and featureStatus array.
- **windowWidth** – Width of window for optical flow searching. Must be odd number. **NOTE:** suggested value 5, 7 or 9
- **windowHeight** – Height of window for optical flow searching. Must be odd number. **NOTE:**: suggested value 5, 7 or 9
- **maxIterations** – Maximum number of LK iterations to perform per pyramid level. **NOTE:** suggested value 5 or 7
- **nPyramidLevels** – Number of pyramid levels. **NOTE:** suggested value 3 or 4 depending on size of image
- **maxResidue** – Maximum feature residue above which feature is declared lost. **NOTE:** obsolete parameters, set to 0
- **minDisplacement** – Minimum displacement solved below which iterations are stopped. **NOTE:** obsolete parameters, set to 0
- **minEigenvalue** – Threshold for feature goodness. If it is set it to 0, the check is disabled. **NOTE:** If good features are passed to the function, then it is suggested that you set it to 0 to have faster function time **NOTE:** obsolete parameters, set to 0
- **lightingNormalized** –

    if 1 Enable lightning normalization

    if 0 Disable lightning normalization

**NOTE:** obsolete parameters, set to 0

- FASTCV\_API void fcvTrackLKOpticalFlowu8\_v2(const uint8\_t \*\_\_restrict src1, const uint8\_t \*\_\_restrict src2, uint32\_t width, uint32\_t height, uint32\_t stride, const [fcvPyramidLevel\_v2](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00018.html#_CPPv418fcvPyramidLevel_v2) \*src1Pyr, const [fcvPyramidLevel\_v2](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00018.html#_CPPv418fcvPyramidLevel_v2) \*src2Pyr, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*featureXY, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*featureXY\_out, int32\_t \*featureStatus, int32\_t featureLen, int32\_t windowWidth, int32\_t windowHeight, int32\_t maxIterations, int32\_t nPyramidLevels)

    - Optical flow (with stride so ROI can be supported)

**ATTENTION:** This function is a duplication of [fcvTrackLKOpticalFlowu8()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga0af1c588201a116f0ac302da8cfc102f) with the addition of extra parameters. This function has been added to allow for backward compatibility with the original function. When the 2.0.0 release of this library is made, this function will be renamed to: *fcvTrackLKOpticalFlowu8*, *fcvTrackLKOpticalFlowu8\_v2* will be removed, and the current signature for *fcvTrackLKOpticalFlowu8* will be removed. Until 2.0.0, the developer should use this implementation with the expectation of renaming it to *ffcvTrackLKOpticalFlowu8* when transitioning to 2.0.0.

- Parameters:

    - - **src1** – Input image from frame #1. **WARNING:** should be 128-bit aligned.
- **src2** – Input image from frame #2. **WARNING:** should be 128-bit aligned.
- **width** – Input image width.
- **height** – Input image height.
- **stride** – Stride is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 srcStride is default to width. NOTE: should be a multiple of 8.
- **src1Pyr** – Image Pyramid of src1 (with stride) **WARNING:** obtained by calling fcvPyramidCreateu8\_v2
- **src2Pyr** – Image Pyradmid of src2 (with stride) **WARNING:** obtained by calling fcvPyramidCreateu8\_v2
- **featureXY** – Pointer to X,Y floating point, sub-pixel coordinates for features to track. Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureXY\_out** – Pointer to X,Y floating point, sub-pixel coordinates for tracked features Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureStatus** – Pointer to integer array for status of each feature defined in featureXY. featureStatus array storage must be &gt;= featureLen.
- **featureLen** – Number of features in featuresXY and featureStatus array.
- **windowWidth** – Width of window for optical flow searching. Must be odd number. **NOTE:** suggested value 5, 7 or 9
- **windowHeight** – Height of window for optical flow searching. Must be odd number. **NOTE:**: suggested value 5, 7 or 9
- **maxIterations** – Maximum number of LK iterations to perform per pyramid level. **NOTE:** suggested value 5 or 7
- **nPyramidLevels** – Number of pyramid levels. **NOTE:** suggested value 3 or 4 depending on size of image

- FASTCV\_API void fcvTrackLKOpticalFlowf32(const uint8\_t \*\_\_restrict src1, const uint8\_t \*\_\_restrict src2, unsigned int srcWidth, unsigned int srcHeight, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*src1Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*src2Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*dx1Pyr, const [fcvPyramidLevel](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00017.html#_CPPv415fcvPyramidLevel) \*dy1Pyr, const float \*featureXY, float \*featureXY\_out, int32\_t \*featureStatus, int featureLen, int windowWidth, int windowHeight, int maxIterations, int nPyramidLevels, float maxResidue, float minDisplacement, float minEigenvalue, int lightingNormalized)

    - Optical flow.

**ATTENTION:** This function will be removed when the 2.0.0 release of this library is made. Until 2.0.0, the developer should use this implementation with the expectation of using *fcvTrackLKOpticalFlowu8* when transitioning to 2.0.0.

- Parameters:

    - - **src1** – Input image from frame #1. **WARNING:** should be 128-bit aligned.
- **src2** – Input image from frame #2. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Input image width. **WARNING:** should be multiple of 8.
- **srcHeight** – Input image height.
- **src1Pyr** – Image Pyradmid of src1 **WARNING:** obtained by calling fcvPyramidCreateu8
- **src2Pyr** – Image Pyradmid of src2 **WARNING:** obtained by calling fcvPyramidCreateu8
- **dx1Pyr** – Horizontal Sobel gradient pyramid for src1 **NOTE:** To be left NULL. In this case the function will build the pyramid internally.
- **dy1Pyr** – Vertical Sobel grading pyraid for src1 **NOTE:** To be left NULL. In this case the function will build the pyramid internally.
- **featureXY** – Pointer to X,Y floating point, sub-pixel coordinates for features to track. Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureXY\_out** – Pointer to X,Y floating point, sub-pixel coordinates for tracked features Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureStatus** – Pointer to integer array for status of each feature defined in featureXY. featureStatus array storage must be &gt;= featureLen. **NOTE:**

    Possible status are :

    TRACKED 1

    NOT\_FOUND -1

    SMALL\_DET -2

    MAX\_ITERATIONS -3

    OUT\_OF\_BOUNDS -4

    LARGE\_RESIDUE -5

    SMALL\_EIGVAL -6

 INVALID -99
- **featureLen** – Number of features in featuresXY and featureStatus array.
- **windowWidth** – Width of window for optical flow searching. Must be odd number. **NOTE:** suggested value 5, 7 or 9
- **windowHeight** – Height of window for optical flow searching. Must be odd number. **NOTE:**: suggested value 5, 7 or 9
- **maxIterations** – Maximum number of LK iterations to perform per pyramid level. **NOTE:** suggested value 5 or 7
- **nPyramidLevels** – Number of pyramid levels. **NOTE:** suggested value 3 or 4 depending on size of image
- **maxResidue** – Maximum feature residue above which feature is declared lost. **NOTE:** obsolete parameters, set to 0
- **minDisplacement** – Minimum displacement solved below which iterations are stopped. **NOTE** : Suggest that be set to between 0.1 and 0.2, say 0.15 **NOTE:** obsolete parameters, set to 0
- **minEigenvalue** – Threshold for feature goodness. If it is set it to 0, the check is disabled. **NOTE:** If good features are passed to the function, then it is suggested that you set it to 0 to have faster function time **NOTE:** obsolete parameters, set to 0
- **lightingNormalized** –

    if 1 Enable lightning normalization

    if 0 Disable lightning normalization

**NOTE:** obsolete parameters, set to 0

- FASTCV\_API int fcvTrackBMOpticalFlow16x16u8(const uint8\_t \*\_\_restrict src1, const uint8\_t \*\_\_restrict src2, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t roiLeft, uint32\_t roiTop, uint32\_t roiRight, uint32\_t roiBottom, uint32\_t shiftSize, uint32\_t searchWidth, uint32\_t searchHeight, uint32\_t searchStep, uint32\_t usePrevious, uint32\_t \*numMv, uint32\_t \*locX, uint32\_t \*locY, uint32\_t \*mvX, uint32\_t \*mvY)

    - Block Optical Flow 16x16 - Tracks all 16x16 blocks in the Region of Interest (ROI) from Source-1 to Source-2. Generates Motion Vectors for blocks where motion is detected.

- Parameters:

    - - **src1** – **[in]**

    Pointer to source image where the original blocks are present.

    Dimensions should be same as

*src2*, and equal to *srcWidth*, *srcHeight*, *srcStride*. **WARNING:** should be 128-bit aligned. Buffer size is srcStride\*srcHeight bytes.
- **src2** – **[in]** Pointer to second source image where motion vectors for blocks in *img1*

    are to be located.

    Dimensions should be same as

*src1*, and equal to *srcWidth*, *srcHeight*, *srcStride*. **WARNING:** should be 128-bit aligned.
- **srcWidth** – **[in]** Width of source images pointed by *src1* and *src2*.
- **srcHeight** – **[in]** Height of source images pointed by *src1* and *src2*.
- **srcStride** – **[in]** Stride of source images pointed by *src1* and *src2*.
- **roiLeft** – **[in]** Left co-ordinate (x0) of Region-of-Interest (ROI).
- **roiTop** – **[in]** Top co-orgdinate (y0) of Region-of-Interest (ROI).
- **roiRight** – **[in]** Right co-ordinate (x1) of Region-of-Interest (ROI).
- **roiBottom** – **[in]** Bottom co-ordinate (y1) of Region-of-Interest (ROI).
- **shiftSize** – **[in]** Distance in number of pixels (both horizontally and vertically) between consecutive blocks for which motion vector is searched. **NOTE:** Larger the value, less number of blocks will be tracked, and hence the function will run faster.
- **searchWidth** – **[in]** Numbers of pixels horizontally on left and right of the source block (src2) where a match is searched for. For example, if searchWidth is 8 and searchHeight is 8, then the search area for any given block will be 32x32 around the location of that block.
- **searchHeight** – **[in]** Numbers of pixels vertically on top and bottom of the source block (src2) where a match is searched for. For example, if searchWidth is 8 and searchHeight is 8, then the search area for any given block will be 32x32 around the location of that block.
- **searchStep** – **[in]** Distance in number of pixels between consecutive search targets within the above search window. **NOTE:** Larger the value, more coarse the search will be and thus will make the fucntion run faster. Smaller the value, more dense the search will be, making the funciton run slower.
- **usePrevious** – **[in]** Indicates if the function should use the existing motion vectors in locX and locY as the starting point for motion vector search. **NOTE:** This parameter is redundant at the moment.
- **numMv** – **[out]** Pointer to variable that will store the count of Motion Vectors generated by the function. **WARNING:** This pointer should be Non-NULL.
- **locX** – **[out]** Pointer to an array which will store the X co-ordinates of the original Block for which a Motion Vector is generated. **NOTE:** The array will contain *numMv* valid entries. **NOTE:** the maximum number of MVs is related to ROI size and shiftSize, as follows: (roiRight-roiLeft)/shiftSize \* (roiBottom-roiTop)/shiftSize; **WARNING:** This pointer should be Non-NULL, and the array size should be &gt;= number of 16x16 blocks in ROI.
- **locY** – **[out]** Pointer to an array which will store the Y co-ordinates of the original Block for which a Motion Vector is generated. **NOTE:** The array will contain *numMv* valid entries. **NOTE:** the maximum number of MVs is related to ROI size and shiftSize, as follows: (roiRight-roiLeft)/shiftSize \* (roiBottom-roiTop)/shiftSize; **WARNING:** This pointer should be Non-NULL, and the array size should be &gt;= number of 16x16 blocks in ROI.
- **mvX** – **[out]** Pointer to an array which will store the X co-ordinates of the block in *src2* corresponding block in *src1*. (*mvX*[i]-*locX*[i]) will give the motion vector for the block in *src1*. **NOTE:** The array will contain *numMv* valid entries. **NOTE:** the maximum number of MVs is related to ROI size and shiftSize, as follows: (roiRight-roiLeft)/shiftSize \* (roiBottom-roiTop)/shiftSize; **WARNING:** This pointer should be Non-NULL, and the array size should be &gt;= number of 16x16 blocks in ROI.
- **mvY** – **[out]** Pointer to an array which will store the Y co-ordinates of the block in *src2* corresponding block in *src1*. (*mvY*[i]-*locY*[i]) will give the motion vector for the block in *src1*. **NOTE:** The array will contain *numMv* valid entries. **NOTE:** the maximum number of MVs is related to ROI size and shiftSize, as follows: (roiRight-roiLeft)/shiftSize \* (roiBottom-roiTop)/shiftSize; **WARNING:** This pointer should be Non-NULL, and the array size should be &gt;= number of 16x16 blocks in ROI.

- Returns:

    - 0 - Success, Failure otherwise.

- FASTCV\_API [fcvStatus](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a39574810b4ad6914ee8613424f316283.html#_CPPv49fcvStatus) fcvNCCPatchesOnRectu8(const uint8\_t \*\_\_restrict patches, uint32\_t patchWidth, uint32\_t patchHeight, const uint8\_t \*\_\_restrict src, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, const uint32\_t \*\_\_restrict searchCenterX, const uint32\_t \*\_\_restrict searchCenterY, uint32\_t searchWidth, uint32\_t searchHeight, int32\_t filterLowVariance, uint32\_t \*\_\_restrict bestX, uint32\_t \*\_\_restrict bestY, uint32\_t \*\_\_restrict bestNCC, int32\_t findSubPixel, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict subX, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict subY, uint32\_t numSearches)

    - Searches a set of patches within the source image for the max NCCs. The search regions are corresponding to the patches in the search list.

- Parameters:

    - - **patches** – Pointer to a set of 8-bit patches, each patch takes patchWidth \*patchHeight pixel values which are linearly laid out in memory. **WARNING:** patchWidth \* patchHeight must be &lt;= 256
- **patchWidth** – Width in pixels of the patch.
- **patchHeight** – Height in pixels of the patch.
- **src** – Pointer to 8-bit image for search. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Width in pixels of the image.
- **srcHeight** – Height in pixels of the image.
- **srcStride** – The stride of the imge. Stride is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 src1Stride is default to srcWidth. **WARNING:** should be multiple of 8
- **searchCenterX** – The list of Center X coordinate of each search window
- **searchCenterY** – The list of Center Y coordinate of each search window
- **searchWidth** – Width of search range in pixels **WARNING:** must be odd number.
- **searchHeight** – Height of search range in pixels **WARNING:** must be odd number.
- **filterLowVariance** – Minimum variance. Used to as threshold to compare against variance of the block of src or patch.
- **bestX** – The list of Center X location on the image of the best NCC matches. The center X has (patchWidth/2) pixels to the left and (patchWidth - (patchWidth/2) - 1) to the right.
- **bestY** – The list of Center Y location on the image of the best NCC matches. The center Y has (patchWidth/2) pixels above and (patchWidth - (patchWidth/2) - 1) below.
- **bestNCC** – NCC value of the best match blocks. It’s quantized to integer value in Q7 (between -128 and 128).
- **findSubPixel** – (0 or 1) Use parabolic interpolation of NCC values to find sub-pixel estimates.
- **subX** –

    Sub-pixel estimate for optimal NCC relative to bestX.

    e.g., float x = (float)bestX + subX;
- **subY** – Sub-pixel estimate for optimal NCC relative to bestY.
- **numSearches** – number of patch searches in the image.

- Returns:

    - FASTCV\_SUCCESS upon success, other values upon failure.

- FASTCV\_API [fcvStatus](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a39574810b4ad6914ee8613424f316283.html#_CPPv49fcvStatus) fcvTrackLKOpticalFlowu8\_v3(const uint8\_t \*\_\_restrict src1, const uint8\_t \*\_\_restrict src2, uint32\_t width, uint32\_t height, uint32\_t stride, const [fcvPyramidLevel\_v2](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00018.html#_CPPv418fcvPyramidLevel_v2) \*\_\_restrict src1Pyr, const [fcvPyramidLevel\_v2](https://docs.qualcomm.com/doc/80-79511-2/topic/struct_a00018.html#_CPPv418fcvPyramidLevel_v2) \*\_\_restrict src2Pyr, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict featureXY, const [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict featureXY\_estimate, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict featureXY\_out, int32\_t \*\_\_restrict featureStatus, int32\_t featureLen, int32\_t windowWidth, int32\_t windowHeight, int32\_t nPyramidLevels, [fcvTerminationCriteria](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a5689c95a3920a0a45bda70562aa7db11.html#_CPPv422fcvTerminationCriteria) termCriteria, int32\_t maxIterations, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) maxEpsilon, int32\_t use\_initial\_estimate)

    - Optical flow (with stride so ROI can be supported)

**ATTENTION:** This function is a duplication of [fcvTrackLKOpticalFlowu8()](https://docs.qualcomm.com/doc/80-79511-2/topic/object_detection.html#a00026_1ga0af1c588201a116f0ac302da8cfc102f) with the addition of extra parameters. This function has been added to allow for backward compatibility with the original function. When the 2.0.0 release of this library is made, this function will be renamed to: *fcvTrackLKOpticalFlowu8*, *fcvTrackLKOpticalFlowu8\_v3* will be removed, and the current signature for *fcvTrackLKOpticalFlowu8* will be removed. Until 2.0.0, the developer should use this implementation with the expectation of renaming it to *fcvTrackLKOpticalFlowu8* when transitioning to 2.0.0.

- Parameters:

    - - **src1** – Input image from frame #1. **WARNING:** should be 128-bit aligned.
- **src2** – Input image from frame #2. **WARNING:** should be 128-bit aligned.
- **width** – Input image width.
- **height** – Input image height.
- **stride** – Stride is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 srcStride is default to width. NOTE: should be a multiple of 8.
- **src1Pyr** – Image Pyramid of src1 (with stride) **WARNING:** obtained by calling fcvPyramidCreateu8\_v3
- **src2Pyr** – Image Pyradmid of src2 (with stride) **WARNING:** obtained by calling fcvPyramidCreateu8\_v3
- **featureXY** – Pointer to X,Y floating point, sub-pixel coordinates for features to track. Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureXY\_out** – Pointer to X,Y floating point, sub-pixel coordinates for tracked features Stored as X,Y tuples. featureXY array storage must be &gt;= featureLen\*2.
- **featureXY\_estimate** – Pointer to X,Y floating point, sub-pixel coordinates for estimated features on the new frame stored as X,Y tuples. featureXY array storage must has the same length as featureXY
- **featureStatus** – Pointer to integer array for status of each feature defined in featureXY. featureStatus array storage must be &gt;= featureLen.
- **featureLen** – Number of features in featuresXY and featureStatus array.
- **windowWidth** – Width of window for optical flow searching. Must be odd number. **NOTE:** suggested value 5, 7 or 9
- **windowHeight** – Height of window for optical flow searching. Must be odd number. **NOTE:**: suggested value 5, 7 or 9
- **nPyramidLevels** – Number of pyramid levels. **NOTE:** suggested value 3 or 4 depending on size of image
- **termCriteria** – The enum parameter to specify termination criteria. See fcvTerminationCriteria for details
- **maxIterations** – Maximum number of LK iterations to perform per pyramid level if FASTCV\_TERM\_CRITERIA\_ITERATIONS is set as the termCriteria **NOTE:** will be saturated to range [1, 100]; suggested value 5 or 7
- **maxEpsilon** – Epsilon value in float32\_t for error measure to determine the iteration **NOTE:** the value should be within [0, 10]; suggested value 0.03\*0.03
- **use\_initial\_estimate** – The flag indicatiing if to use initial estimations stored in featureXY\_estimate to start the search.

- Returns:

    - FASTCV\_SUCCESS upon success. Other status codes upon failure.

- FASTCV\_API [fcvStatus](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a39574810b4ad6914ee8613424f316283.html#_CPPv49fcvStatus) fcvExtractHOGu16(const uint16\_t \*\_\_restrict strength, uint32\_t width, uint32\_t height, uint32\_t strengthStride, const uint16\_t \*\_\_restrict orientation, uint32\_t orientationStride, uint32\_t cellSize, uint32\_t blockSize, uint32\_t blockStep, uint32\_t binSize, [fcvHOGNormMethod](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a96a938159f8e3fb98c108b301d4d6173.html#_CPPv416fcvHOGNormMethod) normMethod, uint16\_t \*\_\_restrict hogVector, uint32\_t flen, void \*handle)

    - Extract Histogram of Oriented Gradients (HOG) descriptor given an image’s gradient strength and orientation.

- Parameters:

    - - **strength** – The gradient strength at each pixel. **WARNING:** should be 128-bit aligned.
- **width** – Input window width.
- **height** – Input window height.
- **strengthStride** – Stride is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 strengthStride is default to width\*2. NOTE: should be a multiple of 8.
- **orientation** – Gradient orientation at each pixel. When normMethod is FASTCV\_HOG\_NORM\_REGULAR or FASTCV\_HOG\_NORM\_RENORMALIZATION, orientation should be within range of [0, 179]; while FASTCV\_HOG\_NORM\_FHOG is used, orientation should be within [0, 359] to meet its contrast- sensitive requirements. **WARNING:** should be 128-bit aligned.
- **orientationStride** – Stride is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 orientationStride is default to width\*2. NOTE: should be a multiple of 8.
- **cellSize** – The size of one cell in pixels. The typical cell size is 4.
- **blockSize** – Block size in pixels. It must be a multiple of cellSize. **WARNING:** When normMethod is FASTCV\_HOG\_NORM\_FHOG, blockSize is by default equal to cellSize
- **blockStep** – Block step in pixels when sliding the block over the image. If the blockStep is a multiple of cellSize, faster approach would be taken when normMethod is FASTCV\_HOG\_NORM\_REGULAR or FASTCV\_HOG\_NORM\_RENORMALIZATION. **WARNING:** When normMethod is FASTCV\_HOG\_NORM\_FHOG, blockStep is by default equal to cellSize
- **binSize** – Number of bins in the gradient histogram. Typical binSize is 9.
- **normMethod** – The enum parameter to specify the normalization method for HOG descriptor construction. See fcvHOGNormMethod for details.
- **hogVector** – The output descriptor vector in uint16\_t. The length of the vector is obtained by fcvGetHOGVectorLengthu32
- **flen** –
- **handle** –

- Returns:

    - FASTCV\_SUCCESS upon success. Other status codes upon failure.

- FASTCV\_API [fcvStatus](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a39574810b4ad6914ee8613424f316283.html#_CPPv49fcvStatus) fcvHOGInit(uint32\_t width, uint32\_t height, uint32\_t cellSize, uint32\_t blockSize, uint32\_t blockStep, uint32\_t binSize, [fcvHOGNormMethod](https://docs.qualcomm.com/doc/80-79511-2/topic/enum_a00021_1a96a938159f8e3fb98c108b301d4d6173.html#_CPPv416fcvHOGNormMethod) normMethod, uint32\_t \*vecLength, void \*\*hogHandle)

    - Calculate the length of the output vector for HOG extraction.

- Parameters:

    - - **width** – Input window width.
- **height** – Input window height.
- **cellSize** – The size of one cell in pixels. The typical cell size is 4.
- **blockSize** – Block size in pixels. It must be a multiple of cellSize. **WARNING:** When normMethod is FASTCV\_HOG\_NORM\_FHOG, blockStep is by default equal to cellSize
- **blockStep** – Block step in pixels when sliding the block over the image. If the blockStep is a multiple of cellSize, faster approach would be taken when normMethod is FASTCV\_HOG\_NORM\_REGULAR or FASTCV\_HOG\_NORM\_RENORMALIZATION. **WARNING:** When normMethod is FASTCV\_HOG\_NORM\_FHOG, blockStep is by default equal to cellSize
- **binSize** – Number of bins in the gradient histogram. Typical binSize is 9.
- **normMethod** – The enum parameter to specify the normalization method for HOG descriptor construction. See fcvHOGNormMethod for details.
- **vecLength** – The length of HOG vector in uint32\_t
- **hogHandle** – Output. the hogHandle to be used in subsequent calls.

- FASTCV\_API void fcvHOGDeInit(void \*hogHandle)

    - Function to release HOG resources.

- Parameters:

    - **hogHandle** – Handle to be used to free up HOG resources.

Last Published: Aug 30, 2024

[Previous Topic
Motion and object tracking](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/motion_and_object_tracking.md) [Next Topic
Shape and drawing](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/shape_and_drawing.md)