img_helper.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef _NPU_CV_IMG_HELPER_H_
  2. #define _NPU_CV_IMG_HELPER_H_
  3. #include "ax_base_type.h"
  4. #include "ax_global_type.h"
  5. #include <string>
  6. #include <vector>
  7. #include "ax_interpreter_external_api.h"
  8. #include "npu_common.h"
  9. #include "drc_callbacks.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. AX_NPU_SDK_EX_ATTR_T get_npu_hard_mode(const std::string& mode);
  14. AX_NPU_SDK_EX_MODEL_TYPE_T get_npu_mode_type(const std::string& mode_type);
  15. uint32_t get_image_stride_w(const AX_NPU_CV_Image* pImg);
  16. void load_file(const std::string& path, void** vir_addr, AX_U64 *phy_addr, long *file_size);
  17. void release_image_buffer(AX_NPU_CV_Image * img);
  18. int get_image_data_size(const AX_NPU_CV_Image* img);
  19. AX_NPU_CV_DataType get_data_type(const std::string& data_type);
  20. std::string get_data_type_name(AX_NPU_CV_DataType type);
  21. AX_NPU_CV_FrameDataType get_color_space(const std::string& color_space);
  22. std::vector<std::string> split_string(const std::string& content, const std::string delimitter);
  23. int get_data_bit_width(const AX_NPU_CV_DataType eDtype);
  24. AX_NPU_CV_Image * create_img_by_size(AX_U32 h, AX_U32 w, AX_NPU_CV_FrameDataType type);
  25. AX_NPU_CV_Matrix2D create_matrix_by_size(AX_U32 nRow, AX_U32 nColumn,AX_NPU_CV_DataType type);
  26. AX_NPU_CV_Matrix3D create_matrix_by_size_3d(AX_U32 N, AX_U32 nRow, AX_U32 nColumn, AX_NPU_CV_DataType type);
  27. AX_NPU_CV_Matrix2D create_matrix_from_file(const std::string &path, int nRow, int nColumn, AX_NPU_CV_DataType type);
  28. AX_NPU_CV_Matrix3D create_matrix_from_file_3d(const std::string &path, int N, int nRow, int nColumn, AX_NPU_CV_DataType type);
  29. void release_matrix_memory(AX_NPU_CV_Matrix2D& matrix);
  30. void release_matrix_memory_3d(AX_NPU_CV_Matrix3D& matrix);
  31. void release_image_memory(AX_NPU_CV_Image * img);
  32. void dump_matrix_to_file(const std::string& path, const AX_NPU_CV_Matrix2D& matrix_2d);
  33. void dump_matrix_to_file_3d(const std::string& path, const AX_NPU_CV_Matrix3D& matrix_3d);
  34. void dump_image_to_file(const std::string& path, AX_NPU_CV_Image* img);
  35. void dump_mem_to_file(const std::string& path, void * ptr, int size);
  36. void matrix_binary(AX_NPU_CV_Matrix2D * mat);
  37. AX_NPU_CV_Matrix2D create_random_matrix(AX_U32 nRow, AX_U32 nColumn,AX_NPU_CV_DataType type, float x1=-1, float x2=1);
  38. AX_NPU_CV_Matrix3D create_random_matrix_3d(AX_U32 N, AX_U32 nRow, AX_U32 nColumn,AX_NPU_CV_DataType type, float x1=-1, float x2=1);
  39. AX_NPU_CV_Matrix2D create_matrix_universal(const std::string &path, int nRow, int nColumn, AX_NPU_CV_DataType type, float x1=-1, float x2=1);
  40. AX_NPU_CV_Matrix3D create_matrix_universal_3d(const std::string &path, int N, int nRow, int nColumn, AX_NPU_CV_DataType type, float x1=-1, float x2=1);
  41. void transposeMat(AX_NPU_CV_Matrix2D& matrix);
  42. AX_NPU_SDK_EX_WORK_CYCLE_T get_current_work_cycle();
  43. typedef AX_NPU_SDK_EX_WORK_CYCLE_T eu_work_cycle_info_t;
  44. void print_work_cycle(eu_work_cycle_info_t result);
  45. void print_matrix(AX_NPU_CV_Matrix2D& mat);
  46. AX_NPU_CV_Matrix2D copy_from_matrix_3d(AX_NPU_CV_Matrix3D&mat, AX_U32 i);
  47. void print_matrix_3d(AX_NPU_CV_Matrix3D& mat);
  48. bool matrix_cmp(AX_NPU_CV_Matrix2D& mat1, AX_NPU_CV_Matrix2D& mat2);
  49. bool matrix_cmp_3d(AX_NPU_CV_Matrix3D& mat1, AX_NPU_CV_Matrix3D& mat2);
  50. void matrx_stats(AX_NPU_CV_Matrix2D& src, AX_NPU_CV_Matrix2D& dst, std::string method);
  51. void matrix_transpose(AX_NPU_CV_Matrix2D& src);
  52. void matrix_transpose_3d(AX_NPU_CV_Matrix3D& src);
  53. void matrix_map(AX_NPU_CV_Matrix2D& src, AX_NPU_CV_Matrix2D& dst, float(*pFun)(float));
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif