2. TopsCV C API

This is the C API documentation for TopsCV library.

2.1. TopsCV C API 示例

This entity contains all infomation about OpSet/OpParameters/CoreAPI.

2.1.1. OpSet

TOPSCV_EXPORT topscvStatus_t topscvCropCreate (topscvOperator_t *)

Create Op Crop.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvCropSubmit (topscvOperator_t, topsStream_t, topscvImage_t input, topscvImage_t output, const topscvRectI_t *, topscvBackend_t)

Submit Op Crop.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvImage_t[out] output

  • const[in] topscvRectI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvCvtColorCreate (topscvOperator_t *)

Create Op CvtColor.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvCvtColorSubmit (topscvOperator_t, topsStream_t, topscvImage_t input, topscvImage_t output, topscvColorConversionCode_t, topscvBackend_t)

Submit Op CvtColor.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvImage_t[out] output

  • topscvColorConversionCode_t[in]

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvCvtColorBatchSubmit (topscvOperator_t, topsStream_t, topscvImage_t *input, topscvImage_t *output, int64_t batch, topscvColorConversionCode_t, topscvBackend_t)

Submit Op CvtColor in batch.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t*[in] input

  • topscvImage_t*[out] output

  • int64_t[in] batch

  • topscvColorConversionCode_t[in]

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvfindContoursCreate (topscvOperator_t *)

Create Op FindContours.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvfindContoursSubmit (topscvOperator_t, topsStream_t, topscvImage_t, topscvBackend_t, topscvPointArray2D_t *)

Submit Op FindContours.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvBackend_t[in]

  • topscvPointArray2D_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageDecoderCreate (topscvOperator_t *)

Create Op ImageDecoder.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageDecoderSubmit (topscvOperator_t, topsStream_t, const char *file, topscvImage_t, topscvImageFormat_t, topscvBackend_t)

Submit Op ImageDecoder.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • const[in] char* file

  • topscvImage_t[out] output

  • topscvImageFormat_t[in]

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageDecoderGetImageInfo (const char *, int64_t *aligned_length, int64_t *width, int64_t *height)

Calculate the given image ‘s aligend file size, width and height.

Parameters
  • const[in] char*

  • int64_t*[in] aligned_length

  • int64_t*[out] width

  • int64_t*[out] height

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageDecoderBatchSubmit (topscvOperator_t, topsStream_t, topscvImageFormat_t, int64_t batch, const DecoderBatchInputs *, topscvImage_t *, topscvBackend_t)

Submit Op ImageDecoder.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImageFormat_t[in]

  • int64_t[in] batch

  • const[in] DecoderBatchInputs*

  • topscvImage_t*[out]

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPaddingCreate (topscvOperator_t *)

Create Op Padding.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPaddingSubmit (topscvOperator_t, topsStream_t, topscvImage_t input, topscvImage_t output, const topscvPadI_t *, topscvBackend_t)

Submit Op Padding.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvImage_t[out] output

  • const[in] topscvPadI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizeCreate (topscvOperator_t *)

Create Op Resize.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizeSubmit (topscvOperator_t, topsStream_t, topscvImage_t input, topscvImage_t output, const topscvResizeI_t *, topscvBackend_t)

Submit Op Resize.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvImage_t[out] output

  • const[in] topscvResizeI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizeBatchSubmit (topscvOperator_t, topsStream_t, topscvImage_t *input, topscvImage_t *output, int64_t batch, const topscvResizeI_t *, topscvBackend_t)

Submit Op Resize in batch.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t*[in] input

  • topscvImage_t*[out] output

  • int64_t[in] batch

  • const[in] topscvResizeI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvHcvgDataDestroy (topscvHcvgData_t *)

Destroy Hcvg Output Object.

Parameters

topscvHcvgData_t*[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvHcvgDataGetCount (topscvHcvgData_t, int64_t *)

Get Hcvg Output Count.

Parameters
  • topscvHcvgData_t[in]

  • int64_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvHcvgDataGetOutput (topscvHcvgData_t, void **)

Get Hcvg Output Data On Host.

Parameters
  • topscvHcvgData_t[in]

  • void**[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvHcvgCreate (topscvOperator_t *)

Create Customized Op HcvgV2.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvHcvgSubmit (topscvOperator_t, topsStream_t, const void *pix_data, const void *link, const void *angle, topscvHcvgData_t *output, topscvBackend_t)

Submit Op HcvgV2.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • void*[in] input_data

  • void*[in] input_link

  • void*[in] input_angle

  • topscvHcvgData_t*[out] output

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizePaddingCreate (topscvOperator_t *)

Create Op ResizePadding.

Parameters

topscvOperator_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizePaddingSubmit (topscvOperator_t, topsStream_t, topscvImage_t input, topscvImage_t output, const topscvResizeI_t *, const topscvPadI_t *, topscvBackend_t)

Submit Op ResizePadding.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t[in] input

  • topscvImage_t[out] output

  • const[in] topscvRectI_t*

  • const[in] topscvPadI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvResizePaddingBatchSubmit (topscvOperator_t, topsStream_t, topscvImage_t *input, topscvImage_t *output, int64_t batch, const topscvResizeI_t *, const topscvPadI_t *, topscvBackend_t)

Submit Op ResizePadding in batch.

Parameters
  • topscvOperator_t[in]

  • topsStream_t[in]

  • topscvImage_t*[in] input

  • topscvImage_t*[out] output

  • int64_t[in] batch

  • const[in] topscvRectI_t*

  • const[in] topscvPadI_t*

  • topscvBackend_t[in]

Throws

Returns

topscvStatus_t

2.1.2. OpParameters

enum topscvStatus_t

Values:

enumerator TOPSCV_STATUS_SUCCESS
enumerator TOPSCV_STATUS_INVALID_PARAM
enumerator TOPSCV_STATUS_OUT_OF_MEMORY
enumerator TOPSCV_STATUS_INTERNAL_ERROR
enumerator TOPSCV_STATUS_NOT_SUPPORTED
enumerator TOPSCV_STATUS_NOT_IMPLEMENTED
enum topscvImageFormat_t

Values:

enumerator TOPSCV_IMAGE_FORMAT_UNKNOWN
enumerator TOPSCV_IMAGE_FORMAT_GRAY_PACKED_U8
enumerator TOPSCV_IMAGE_FORMAT_YUV444_PACKED_U8
enumerator TOPSCV_IMAGE_FORMAT_YUV444_PLANAR_U8
enumerator TOPSCV_IMAGE_FORMAT_RGB_PACKED_U8
enumerator TOPSCV_IMAGE_FORMAT_RGB_PLANAR_U8
enumerator TOPSCV_IMAGE_FORMAT_BGR_PACKED_U8
enumerator TOPSCV_IMAGE_FORMAT_BGR_PLANAR_U8
enum topscvInterpolationType_t

Values:

enumerator TOPSCV_INTERP_NEAREST
enumerator TOPSCV_INTERP_LINEAR
enumerator TOPSCV_INTERP_CUBIC
enumerator TOPSCV_INTERP_WARP_INVERSE_MAP
enum topscvBorderType_t

Values:

enumerator TOPSCV_BORDER_CONSTANT
enum topscvColorConversionCode_t

Values:

enumerator COLOR_BGR2RGB
enumerator COLOR_RGB2BGR
enumerator COLOR_BGR2GRAY
enumerator COLOR_RGB2GRAY
enumerator COLOR_BGR2YUV
enumerator COLOR_RGB2YUV
enumerator COLOR_YUV2BGR
enumerator COLOR_YUV2RGB
enumerator COLOR_COLORCVT_MAX
enumerator COLOR_BGR2BGR_3P
enumerator COLOR_BGR2RGB_3P
enumerator COLOR_BGR2YUV_3P
enumerator COLOR_RGB2RGB_3P
enumerator COLOR_RGB2BGR_3P
enumerator COLOR_RGB2YUV_3P
enumerator COLOR_YUV2YUV_3P
enumerator COLOR_YUV2BGR_3P
enumerator COLOR_YUV2RGB_3P
enumerator COLOR_YUV2GRAY
enumerator COLOR_RGB_3P2RGB
enumerator COLOR_RGB_3P2BGR
enumerator COLOR_RGB_3P2YUV
enumerator COLOR_RGB_3P2GRAY
enumerator COLOR_RGB_3P2BGR_3P
enumerator COLOR_RGB_3P2YUV_3P
enumerator COLOR_BGR_3P2BGR
enumerator COLOR_BGR_3P2RGB
enumerator COLOR_BGR_3P2YUV
enumerator COLOR_BGR_3P2GRAY
enumerator COLOR_BGR_3P2RGB_3P
enumerator COLOR_BGR_3P2YUV_3P
enumerator COLOR_YUV_3P2BGR
enumerator COLOR_YUV_3P2RGB
enumerator COLOR_YUV_3P2YUV
enumerator COLOR_YUV_3P2GRAY
enumerator COLOR_YUV_3P2RGB_3P
enumerator COLOR_YUV_3P2BGR_3P
enumerator COLOR_GRAY2RGB
enumerator COLOR_GRAY2BGR
enumerator COLOR_GRAY2YUV
enumerator COLOR_GRAY2RGB_3P
enumerator COLOR_GRAY2BGR_3P
enumerator COLOR_GRAY2YUV_3P
enumerator COLOR_COLORCVT_EXT_END
enum topscvBackend_t

Values:

enumerator TOPSCV_BACKEND_NOT_SUPPORTED
enumerator TOPSCV_BACKEND_HOST
enumerator TOPSCV_BACKEND_SIP
enumerator TOPSCV_BACKEND_AP
enumerator TOPSCV_BACKEND_VCU
enumerator TOPSCV_BACKEND_VPP
enumerator TOPSCV_BACKEND_CVA
enumerator TOPSCV_BACKEND_AUTO
typedef struct topscvPointArray2D *topscvPointArray2D_t

PointArray2D warpper for topscv PointArray2D

typedef struct topscvImage *topscvImage_t

Image warpper for topscv Image

typedef struct topscvOperator *topscvOperator_t

operator warpper for topscv ops

struct topscvArray2DData_t
#include <array2d.h>

topscvArray2DData_t is used as a description for results of findcontours

struct topscvPoint_t
struct topscvImageBufferStrided_t
struct topscvImageData_t
#include <image_data.h>

metadata of image data

struct DecoderBatchInputs
#include <image_data.h>

decoder batch inputs

struct topscvRectI_t
struct topscvPadI_t
struct topscvResizeI_t
struct topscvAffineParam_t
struct topscvPerspectiveParam_t

2.1.3. CoreAPI

TOPSCV_EXPORT topscvStatus_t topscvPointArray2DDestroy (topscvPointArray2D_t *)

destory topscvPointArray2D_t

Parameters

topscvPointArray2D_t*[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPointArray2DGetCount (topscvPointArray2D_t, int64_t *)

get coutours count

Parameters
  • topscvPointArray2D_t[in]

  • int64_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPointArray2DGetData (topscvPointArray2D_t, int64_t, const topscvPoint_t **, int64_t *)

get contour coordinates from contours

Parameters
  • topscvPointArray2D_t[in]

  • int64_t, contour[in] index in contours

  • const[out] topscvPoint_t**, address of each topscvPoint_t address

  • int64_t*[out] topscvPoint_t count in selected contour

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPointArray2DExport (topscvPointArray2D_t, topscvArray2DData_t *)

export topscvPointArray2D_t to user accessable topscvArray2DData_t

Parameters
  • topscvPointArray2D_t[in]

  • topscvArray2DData_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvPointArray2DCreate (const topscvArray2DData_t *, topscvPointArray2D_t *)

create topscvPointArray2D_t from topscvArray2DData_t user constructed

Parameters
  • const[in] topscvArray2DData_t*

  • topscvPointArray2D_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvErrCode2String (topscvStatus_t, const char **)

convert topscvStatus_t to string

Parameters
  • topscvStatus_t[in]

  • const[out] char**

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageCreate (int64_t width, int64_t height, topscvImageFormat_t, topscvImage_t *)

create topscvImage based on width/height/format

Parameters
  • int64_t[in] width

  • int64_t[in] height

  • topscvImageFormat_t[in]

  • topscvImage_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageCreateEx (int64_t width, int64_t height, topscvImageFormat_t, void *, int64_t, topscvImage_t *)

create topscvImage based on width/height/format and user’s device memory

Parameters
  • int64_t[in] width

  • int64_t[in] height

  • topscvImageFormat_t[in]

  • void*[in] user’s device memroy

  • int64_t[in] length of user’s device memroy

  • topscvImage_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageCreateWarpData (const topscvImageData_t *, topscvImage_t *)

create topscvImage based on user given topscvImageData_t

Parameters
  • const[in] topscvImageData_t*

  • topscvImage_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageDestroy (topscvImage_t *)

destroy topscvImage

Parameters

topscvImage_t*[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageQueryResolution (topscvImage_t, int64_t *width, int64_t *height)

query width and height from given topscvImage, this is mostly used after image decoder.

Parameters
  • topscvImage_t[in]

  • int64_t*[out] width

  • int64_t*[out] height

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageQueryFormat (topscvImage_t, topscvImageFormat_t *)

query format from given topscvImage, this is mostly used after image decoder.

Parameters
  • topscvImage_t[in]

  • topscvImageFormat_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageSave (topscvImage_t, const char *file)

save raw data from image to file

Parameters
  • topscvImage_t[in]

  • const[in] char* file

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageExportData (topscvImage_t, topscvImageData_t *)

export topscvImage to user accessable ImageData

Parameters
  • topscvImage_t[in]

  • topscvImageData_t*[out]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvImageConcat (void *l3, int64_t l3Size, topscvImage_t *imgs, int64_t count, topsStream_t stream)

concat multi topscv Image to user’s L3

Parameters
  • void*[in] l3

  • int64_t[in] l3Size

  • topscvImage_t*[in]

  • int64_t[in]

  • topsStream_t[in]

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvEnableProfiling ()

enable task profiling

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvDisableProfiling ()

disable task profiling

Throws

Returns

topscvStatus_t

TOPSCV_EXPORT topscvStatus_t topscvVersion (const char **)

get topscv version

Parameters

const[out] char**

Throws

Returns

topscvStatus_t