123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- #ifndef _NET_API_H_
- #define _NET_API_H_
- #include <vector>
- #include <VX/vx.h>
- #include <vx_ext_amd.h>
- typedef enum ImageFormat_E {
- YUV420_SP = 0x02,
- YVU420_SP = 0x04,
- NNA_BGRA = 0x09,
- NNA_GRAY = 0x07,
- } img_fmt;
- typedef enum ImageOperation_E {
- CVT = 1001,
- WARP = 1002,
- } img_op;
- typedef enum ImageDataLayout_E {
- CHW = 2001,
- HWC = 2002,
- WHC = 2003,
- } img_data_layout;
- typedef struct ImageConvertParam_S {
- img_fmt input_fmt;
- int input_width;
- int input_height;
- int input_crop_x;
- int input_crop_y;
- int input_crop_w;
- int input_crop_h;
- int input_color_range;
- img_fmt output_fmt;
- int output_width;
- int output_height;
- int output_crop_x;
- int output_crop_y;
- int output_crop_w;
- int output_crop_h;
- } img_cvt_param;
- typedef struct MbgParam_S {
- int input_width;
- int input_height;
- int blk_width;
- int blk_height;
- int threshold_enable;
- int threshold;
- int alpha;
- int reset_flag;
- int mask_threshold;
- } mbg_param;
- typedef struct ImageWarpParam_S {
- img_fmt input_fmt;
- int input_width;
- int input_height;
- int output_width;
- int output_height;
- int flip;
- float mat[6];
- int output_crop_x;
- int output_crop_y;
- int output_crop_w;
- int output_crop_h;
- } img_warp_param;
- typedef struct InputImage_S {
- img_op op;
- img_fmt fmt;
- int width;
- int height;
- union {
- /* crop out params in cvt_param and warp_param struct have been deprecated. */
- struct {
- int crop_in_x;
- int crop_in_y;
- int crop_in_w;
- int crop_in_h;
- int color_range;
- int crop_out_x;
- int crop_out_y;
- int crop_out_w;
- int crop_out_h;
- } cvt_param;
- struct {
- int flip;
- int crop_out_x;
- int crop_out_y;
- int crop_out_w;
- int crop_out_h;
- float mat[6];
- } warp_param;
- } u;
- vx_size phys_addr;
- vx_size phys_addr_uv;
- } input_image;
- typedef enum NetDataLayout_E {
- NCHW = 3001,
- NHWC = 3002,
- NWHC = 3003,
- } net_data_layout;
- typedef enum NetDataType_E {
- DINT8 = 4001,
- DINT16 = 4002,
- DFLOAT32 = 4003,
- } net_data_type;
- typedef struct NetBlobData_S {
- int n;
- int c;
- int h;
- int w;
- void* data;
- bool need_quantize;
- net_data_type type;
- net_data_layout layout;
- } net_blob_data;
- typedef struct RoiAlignParam_S {
- int input_width;
- int input_height;
- int input_channel;
- int crop_in_c_st;
- int crop_in_c_wd;
- float roi_in_start_w;
- float roi_in_end_w;
- float roi_in_start_h;
- float roi_in_end_h;
- int output_width;
- int output_height;
- int output_channel;
- int crop_out_x_st;
- int crop_out_y_st;
- int crop_out_c_st;
- int bit_width;
- int pooled_w;
- int pooled_h;
- int aligned;
- float spatial_ratio;
- float sampling_ratio;
- } roi_align_param;
- /*
- * network
- */
- VX_API_ENTRY vx_graph VX_API_CALL CreateNetGraph(
- vx_context context,
- vx_uint32 * net_topo,
- vx_int8 * net_blobs,
- bool on_chip_mem_enable = false,
- bool io_mem_shared = false,
- int hold_block_idx = 0x7FFFFFFF,
- int up_to_block_count = -1);
- VX_API_ENTRY vx_status VX_API_CALL GetNetInputBlob(
- vx_graph graph,
- std::vector<std::string> & names,
- std::vector<vx_tensor> & blobs);
- VX_API_ENTRY vx_status VX_API_CALL GetNetOutputBlob(
- vx_graph graph,
- std::vector<std::string> & names,
- std::vector<vx_tensor> & blobs);
- VX_API_ENTRY vx_status VX_API_CALL GetNetIntermediateBlob(
- vx_graph graph,
- std::vector<std::string>& names,
- std::vector<vx_tensor>& blobs);
- VX_API_ENTRY vx_status VX_API_CALL GetNetBlobOriginDims(
- vx_graph graph,
- std::string& blob_name,
- std::vector<int>& dims);
- /*
- * batch network
- */
- VX_API_ENTRY vx_graph VX_API_CALL CreateBatchNetGraph(
- vx_context context,
- vx_uint32* net_topo,
- vx_int8* net_blobs,
- int batch,
- bool io_mem_shared = false);
- VX_API_ENTRY vx_status VX_API_CALL GetBatchNetInputBlob(
- vx_graph graph,
- std::vector<std::string>& names,
- std::vector<std::vector<vx_tensor>>& blobs);
- VX_API_ENTRY vx_status VX_API_CALL GetBatchNetOutputBlob(
- vx_graph graph,
- std::vector<std::string>& names,
- std::vector<std::vector<vx_tensor>>& blobs);
- /*
- * config input buffer
- */
- VX_API_ENTRY vx_status VX_API_CALL SetNetInputBuffer(
- vx_graph graph,
- std::string& blob_name,
- vx_size handle,
- int batch_idx = 0);
- VX_API_ENTRY vx_status VX_API_CALL ResetNetDefaultInputBuffer(
- vx_graph graph,
- std::string& blob_name,
- int batch_idx = 0);
- /*
- * import and export network data
- */
- VX_API_ENTRY vx_status VX_API_CALL ImportNetInputDataFromImage(
- vx_graph graph,
- std::string& blob_name,
- input_image* image,
- int batch_idx = 0);
- VX_API_ENTRY vx_status VX_API_CALL ImportNetInputDataFromMem(
- vx_graph graph,
- std::string & blob_name,
- int mem_data_len,
- vx_uint8* mem_data,
- int batch_idx = 0);
- VX_API_ENTRY vx_status VX_API_CALL ImportNetInputDataFromDataFile(
- vx_graph graph,
- std::string& blob_name,
- char* fname,
- int batch_idx = 0);
- VX_API_ENTRY vx_status VX_API_CALL EnableNetInputDataExtPreprocess(
- vx_graph graph,
- std::string& blob_name);
- VX_API_ENTRY vx_status VX_API_CALL DisableNetInputDataExtPreprocess(
- vx_graph graph,
- std::string& blob_name);
- VX_API_ENTRY vx_status VX_API_CALL ImportNetInputDataFromRawData(
- vx_graph graph,
- std::string& blob_name,
- net_blob_data& blob_data,
- int batch_idx = 0);
- VX_API_ENTRY vx_status VX_API_CALL ExportNetOutputRawData(
- vx_graph graph,
- std::string& blob_name,
- net_blob_data& blob_data,
- int batch_idx = 0);
- /*
- * image process
- */
- VX_API_ENTRY vx_size VX_API_CALL AllocDeviceImageBuffer(
- vx_context context,
- img_fmt fmt,
- int width,
- int height);
- VX_API_ENTRY vx_size VX_API_CALL AllocDeviceMbgMaskImageBuffer(
- vx_context context,
- int width,
- int height,
- int blk_width,
- int blk_height);
- VX_API_ENTRY vx_status VX_API_CALL FreeDeviceImageBuffer(
- vx_context context,
- vx_size handle);
- VX_API_ENTRY vx_status VX_API_CALL ImageConvert(
- vx_context context,
- img_cvt_param * param,
- vx_size input_phys_addr,
- vx_size input_phys_addr_uv,
- vx_size output_handle);
- VX_API_ENTRY vx_status VX_API_CALL BackgroundModeling(
- vx_context context,
- mbg_param * param,
- vx_size input_phys_addr,
- vx_size input_phys_addr_bg,
- vx_size output_handle_bg,
- vx_size output_handle_mask);
- VX_API_ENTRY vx_status VX_API_CALL ImageWarp(
- vx_context context,
- img_warp_param * param,
- vx_size input_phys_addr,
- vx_size input_phys_addr_uv,
- vx_size output_handle);
- VX_API_ENTRY vx_status VX_API_CALL RgbImageConvert(
- int w,
- int h,
- img_data_layout layout,
- vx_uint8 * src,
- vx_uint8 * dst);
-
- VX_API_ENTRY vx_status VX_API_CALL RgbImageRevert(
- int w,
- int h,
- vx_uint8 * src,
- img_data_layout layout,
- vx_uint8 * dst);
- VX_API_ENTRY vx_status VX_API_CALL RoiAlign(
- vx_context context,
- roi_align_param& op_param,
- vx_size input_handle,
- vx_size output_handle);
- /*
- * utility
- */
- VX_API_ENTRY vx_status VX_API_CALL LoadNetModel(
- vx_context context,
- const char * model_file,
- bool encrypted,
- vx_int8 ** model);
- VX_API_ENTRY vx_status VX_API_CALL LoadNetModelFromMem(
- vx_context context,
- vx_int8 * model_data,
- int model_len,
- bool encrypted,
- vx_int8 ** model);
-
- VX_API_ENTRY vx_status VX_API_CALL UnLoadNetModel(vx_int8 * model);
- #endif
|