ContourTracing#
Macros#
- PVA_CONTOUR_TRACING_DIRECTION_TABLE_ENTRIES
Number of entries in the contour tracing direction lookup table.
Functions#
- NVCVStatus pvaContourTracingBuildDirectionTable(uint16_t *table)
Builds the next direction lookup table for contour tracing.
- NVCVStatus pvaContourTracingCreate(NVCVOperatorHandle *handle, NVCVTensorRequirements const *const inTensorRequirements, NVCVTensorRequirements const *const rectTensorRequirements, NVCVTensorRequirements const *const outTensorRequirements, NVCVTensorRequirements const *const lenTensorRequirements)
Constructs an instance of the ContourTracing operator.
- NVCVStatus pvaContourTracingSubmit(NVCVOperatorHandle handle, cupvaStream_t stream, NVCVTensorHandle const inTensor, NVCVTensorHandle const rectTensor, NVCVTensorHandle outTensor, NVCVTensorHandle lenTensor, const int32_t numRects)
Submits the ContourTracing operator to a cuPVA stream.
- NVCVStatus pvaContourTracingSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle const inTensor, NVCVTensorHandle const rectTensor, NVCVTensorHandle outTensor, NVCVTensorHandle lenTensor, const int32_t numRects)
Submits the ContourTracing operator to a CUDA stream.
Functions#
-
NVCVStatus pvaContourTracingBuildDirectionTable(uint16_t *table)#
Builds the next direction lookup table for contour tracing.
For each 8-neighbor bitmap values in [0, 255], packs the next move direction for each of the 4 possible previous directions into one uint16_t entry (4 bits per previous direction).
- Parameters:
table – [out] Caller-allocated array of at least PVA_CONTOUR_TRACING_DIRECTION_TABLE_ENTRIES elements. Must not be NULL.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – Table is null.
NVCV_SUCCESS – Table written successfully.
- NVCVStatus pvaContourTracingCreate(
- NVCVOperatorHandle *handle,
- NVCVTensorRequirements const *const inTensorRequirements,
- NVCVTensorRequirements const *const rectTensorRequirements,
- NVCVTensorRequirements const *const outTensorRequirements,
- NVCVTensorRequirements const *const lenTensorRequirements,
Constructs an instance of the ContourTracing operator.
Given a binary image (foreground is nonzero, background is 0), the ContourTracing operator walks the boundary of each connected foreground component and outputs its boundary pixels as an ordered sequence of (x, y) coordinate pairs. The caller supplies one or more bounding-box ROIs (via the rect tensor) that each enclose a single connected component. There is no restriction on the input image size. Each ROI width and height must be even and no greater than 128. One-pixel-wide bridge cases are supported. If no contour is found within an ROI, its length output is 0 and no valid contour coordinates are produced for that ROI.
Input tensor: Data Layout: [HWC] H: Image height W: Image width C: 1
Data Type
Allowed
8bit Unsigned
Yes
Rect tensor: Data Layout: [W] W: Maximum number of bounding rectangles, must <= 32 Data Type: [4S32]
Output tensor: Data Layout: [HWC] H: Maximum number of bounding rectangles, must <= 32 W: Maximum number of contour pixels per bounding rectangle, must <= 16384 C: 2 (x and y coordinates) Data Type: [16bit Unsigned]
Len tensor: Data Layout: [W] W: Maximum number of bounding rectangles, must <= 32 Data Type: [16bit Unsigned]
- Parameters:
handle – [out] Where the operator instance handle will be written to.
Must not be NULL.
inTensorRequirements – [in] Pointer to the NVCVTensorRequirements structure for the input tensor.
rectTensorRequirements – [in] Pointer to the NVCVTensorRequirements structure for the bounding rectangle tensor.
outTensorRequirements – [in] Pointer to the NVCVTensorRequirements structure for the output tensor.
lenTensorRequirements – [in] Pointer to the NVCVTensorRequirements structure for the contour length tensor.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – Handle is null.
NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.
NVCV_SUCCESS – Operation executed successfully.
- NVCVStatus pvaContourTracingSubmit(
- NVCVOperatorHandle handle,
- cupvaStream_t stream,
- NVCVTensorHandle const inTensor,
- NVCVTensorHandle const rectTensor,
- NVCVTensorHandle outTensor,
- NVCVTensorHandle lenTensor,
- const int32_t numRects,
Submits the ContourTracing operator to a cuPVA stream.
- Parameters:
handle – [in] Handle to the operator.
Must not be NULL.
stream – [in] Handle to a valid cuPVA stream.
inTensor – [in] Input tensor handle.
rectTensor – [in] Bounding rectangle tensor handle. Each element is an NVCVRectI structure, representing {x, y, width, height} in NVCV_DATA_TYPE_4S32 datatype.
outTensor – [out] Output tensor handle.
lenTensor – [out] Contour length tensor handle.
numRects – [in] Number of bounding rectangles to process.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.
NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.
NVCV_SUCCESS – Operation executed successfully.
- NVCVStatus pvaContourTracingSubmit(
- NVCVOperatorHandle handle,
- cudaStream_t stream,
- NVCVTensorHandle const inTensor,
- NVCVTensorHandle const rectTensor,
- NVCVTensorHandle outTensor,
- NVCVTensorHandle lenTensor,
- const int32_t numRects,
Submits the ContourTracing operator to a CUDA stream.
- Parameters:
handle – [in] Handle to the operator.
Must not be NULL.
stream – [in] Handle to a valid CUDA stream.
inTensor – [in] Input tensor handle.
rectTensor – [in] Bounding rectangle tensor handle. Each element is an NVCVRectI structure, representing {x, y, width, height} in NVCV_DATA_TYPE_4S32 datatype.
outTensor – [out] Output tensor handle.
lenTensor – [out] Contour length tensor handle.
numRects – [in] Number of bounding rectangles to process.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.
NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.
NVCV_SUCCESS – Operation executed successfully.