# Shape and drawing

- FASTCV\_API void fcvFillConvexPolyu8(uint32\_t nPts, const uint32\_t \*\_\_restrict polygon, uint32\_t nChannel, const uint8\_t \*\_\_restrict color, uint8\_t \*\_\_restrict dst, uint32\_t dstWidth, uint32\_t dstHeight, uint32\_t dstStride)

    - Draw convex polygon.

This function fills the interior of a convex polygon with the specified color.

- Parameters:

    - - **polygon** – Coordinates of polygon vertices (x0,y0,x1,y1,…), size of buffer is 2\*nPts **WARNING:** should be 128-bit aligned.
- **nPts** – Number of polygon vertices
- **color** – Color of drawn polygon stored as B,G,R and A(if supported)
- **nChannel** – Number of color channels (typical value is 1 or 3)
- **dst** – Destination image, size of image buffer is (dstStride \* dstHeight) bytes **WARNING:** should be 128-bit aligned.
- **dstWidth** – Image width, the number of pixels in a row. **NOTE:** should be a multiple of 8.
- **dstHeight** – Image height.
- **dstStride** – Stride of image is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory. If left at 0 dstStride is default to (dstWidth \* nChannel). **NOTE:** should be a multiple of 8.

- FASTCV\_API void fcvPointPolygonTest(uint32\_t nPts, const uint32\_t \*\_\_restrict polygonContour, uint32\_t px, uint32\_t py, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*distance, int16\_t \*resultFlag)

    - Determines whether a given point is inside a contour, outside, or lies on an edge (or coincides with a vertex). It returns positive, negative or zero value, correspondingly. Also measures distance between the point and the nearest contour edge if distance is requested.

- Parameters:

    - - **nPts** – Total number of points in the contour. For example if there are 10 point sets, i.e. (x,y) in the contour, then nPts equals 20.
- **polygonContour** – Input contour containing the points of the polygon. Coordinates are stored in the interleaved form as x y x y. Size of buffer is
- **nPts** – **WARNING:** should be 128-bit aligned.
- **px** – The x-coordinate of the input point to be tested.
- **py** – The y-coordinate of the input point to be tested.
- **distance** – It contains the signed distance of the point to the closest edge of the contour If passed as a NULL pointer, then no distance is computed.
- **resultFlag** – Assumes the value of -1, 0 or 1 based on whether the point is outside, coincides with a vertex, or lies inside the contour respectively.

- FASTCV\_API void fcvFindConvexHull(uint32\_t \*\_\_restrict polygonContour, uint32\_t nPtsContour, uint32\_t \*\_\_restrict convexHull, uint32\_t \*nPtsHull, uint32\_t \*\_\_restrict tmpBuff)

    - Find the convex hull of the input polygon.

Determines the convex hull of a simple polygon using the Melkman algorithm. The input to the function is the interleaved coordinates of the polygon and the output is the set of interleaved coordinates of the convex hull of the polygon. The algorithm assumes that the coordinates of the polygon are provided in the manner of an ordered traversal.

- Parameters:

    - - **polygonContour** – Input contour containing the points of the polygon for which the convex hull is to be found. Coordinates are stored in the interleaved form as x y x y. NOTE: The polygon must be a simple polygon, i.e., it has no self intersections. Also coordinates are assumed to be stored in the manner of an ordered traversal. **WARNING:** should be 128-bit aligned. Size of buffer is
- **nPtsContour** –
- **nPtsContour** – Total number of points in the contour. For example if there are 10 point sets, i.e. (x,y) in the contour, then nPtsContour equals 20.
- **convexHull** – The output buffer containing the interleaved coordinates of the convex hull. **WARNING:** should be 128-bit aligned. Size of buffer is
- **nPtsHull** –
- **nPtsHull** – Total number of points in the convex hull. For example if there are 10 point sets, i.e. (x,y) in the contour, then nPtsHull equals 20.
- **tmpBuff** – Scratch buffer used in the computation of the convex hull. **NOTE:** MUST be allocated twice as large in size as the input polygonContour. **WARNING:** should be 128-bit aligned.

- FASTCV\_API void fcvDrawContouru8(uint8\_t \*\_\_restrict src, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t nContours, const uint32\_t \*\_\_restrict holeFlag, const uint32\_t \*\_\_restrict numContourPoints, const uint32\_t \*\*\_\_restrict contourStartPoints, uint32\_t pointBufferSize, const uint32\_t \*\_\_restrict pointBuffer, int32\_t hierarchy, uint32\_t max\_level, int32\_t thickness, uint8\_t color, uint8\_t hole\_color)

    - Draw the contour or fill the area enclosed by the contour. The algorithm using even-odd rule to fill the contour. Currently Antialiazing is not supported.

- Parameters:

    - - **src** – 8-bit image where keypoints are detected. Size of buffer is srcStride\*srcHeight bytes. **NOTE:** should be 128-bit aligned.
- **srcWidth** – Image width, the number of pixels in a row **NOTE:** should be a multiple of 8.
- **srcHeight** – Image height
- **srcStride** – Stride of image 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 srcWidth. **NOTE:** should be a multiple of 8.
- **nContours** – The total number of contours to be drawn.
- **holeFlag** – The flag arrays indicate if the corresponding contour is a hole. 1 indicates a hole and 0 indicates it’s not a hole.
- **numContourPoints** – The array that stores the length of each contour;
- **contourStartPoints** – The array that stores the pointer of the starting point of each contour
- **pointBufferSize** – The size of the point buffer, in the number of bytes.
- **pointBuffer** – The array that stores all the x,y coordinates of all the contours. **WARNING:** should be 128-bit aligned.
- **hierarchy** – The array that stores the left,right,ancestor and decendant of each contour.
- **max\_level** – The max level we at which we draw the contour, it stops drawing after we reach this level.
- **thickness** – Indicate the thickness of the contour to be drawn, if it’s 0, do a fill.
- **color** – The color value used to draw/fill the contour, currently support grayscale value from 0-255;
- **hole\_color** – The color value used to fill the hole;

- FASTCV\_API void fcvDrawContourInterleavedu8(uint8\_t \*\_\_restrict src, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t nContours, const uint32\_t \*\_\_restrict holeFlag, const uint32\_t \*\_\_restrict numContourPoints, const uint32\_t \*\*\_\_restrict contourStartPoints, uint32\_t pointBufferSize, const uint32\_t \*\_\_restrict pointBuffer, int32\_t hierarchy, uint32\_t max\_level, int32\_t thickness, uint8\_t colorR, uint8\_t colorG, uint8\_t colorB, uint8\_t hole\_colorR, uint8\_t hole\_colorG, uint8\_t hole\_colorB)

    - Draw the contour or fill the area enclosed by the contour. Currently Antialiazing is not supported.

- Parameters:

    - - **src** – Input image/patch. It’s 3 channel RGB color image in interleaved format. Size of buffer is srcStride\*srcHeight bytes. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Image width, the number of pixels in a row **NOTE:** should be a multiple of 8.
- **srcHeight** – Image height
- **srcStride** – Stride of image 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 srcWidth\*3. **NOTE:** should be a multiple of 8.
- **nContours** – The total number of contours to be drawn.
- **holeFlag** – The flag arrays indicate if the corresponding contour is a hole. 1 indicates a hole and 0 indicates it’s not a hole.
- **numContourPoints** – The array that stores the length of each contour;
- **contourStartPoints** – The array that stores the pointer of the starting point of each contour
- **pointBufferSize** – The size of the point buffer, in the number of bytes.
- **pointBuffer** – The array that stores all the x,y coordinates of all the contours. **WARNING:** should be 128-bit aligned.
- **hierarchy** – The array that stores the left,right,ancestor and decendant of each contour.
- **max\_level** – The max level we at which we draw the contour, it stops drawing after we reach this level.
- **thickness** – Indicate the thickness of the contour to be drawn, if it’s 0, do a fill.
- **colorR, colorG, colorB** – The color value used to draw/fill the contour, currently support value from 0-255;
- **hole\_colorR, hole\_colorG, hole\_colorB** – The color value used to fill the hole, currently support value from 0-255;

- FASTCV\_API void fcvDrawContourPlanaru8(uint8\_t \*\_\_restrict src, uint32\_t srcWidth, uint32\_t srcHeight, uint32\_t srcStride, uint32\_t nContours, const uint32\_t \*\_\_restrict holeFlag, const uint32\_t \*\_\_restrict numContourPoints, const uint32\_t \*\*\_\_restrict contourStartPoints, uint32\_t pointBufferSize, const uint32\_t \*\_\_restrict pointBuffer, int32\_t hierarchy, uint32\_t max\_level, int32\_t thickness, uint8\_t colorR, uint8\_t colorG, uint8\_t colorB, uint8\_t hole\_colorR, uint8\_t hole\_colorG, uint8\_t hole\_colorB)

    - Draw the contour or fill the area enclosed by the contour. Currently Antialiazing is not supported.

- Parameters:

    - - **src** – Input image/patch. It’s 3 channel RGB color image in planar format. Size of buffer is srcStride\*srcHeight\*3 bytes. **WARNING:** should be 128-bit aligned.
- **srcWidth** – Image width, the number of pixels in a row **NOTE:** should be a multiple of 8.
- **srcHeight** – Image height
- **srcStride** – Stride of image is the number of bytes between column 0 of row 1 and column 0 of row 2 in data memory of any color plane. If left at 0 srcStride is default to srcWidth. **NOTE:** should be a multiple of 8.
- **nContours** – The total number of contours to be drawn.
- **holeFlag** – The flag arrays indicate if the corresponding contour is a hole. 1 indicates a hole and 0 indicates it’s not a hole.
- **numContourPoints** – The array that stores the length of each contour;
- **contourStartPoints** – The array that stores the pointer of the starting point of each contour
- **pointBufferSize** – The size of the point buffer, in the number of bytes.
- **pointBuffer** – The array that stores all the x,y coordinates of all the contours. **WARNING:** should be 128-bit aligned.
- **hierarchy** – The array that stores the left,right,ancestor and decendant of each contour.
- **max\_level** – The max level we at which we draw the contour, it stops drawing after we reach this level.
- **thickness** – Indicate the thickness of the contour to be drawn, if it’s 0, do a fill.
- **colorR, colorG, colorB** – The color value used to draw/fill the contour, currently support value from 0-255;
- **hole\_colorR, hole\_colorG, hole\_colorB** – The color value used to fill the hole, currently support value from 0-255;

Last Published: Aug 30, 2024

[Previous Topic
Object detection](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/object_detection.md) [Next Topic
Data structures](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/structs.md)