更新时间:2021-03-18 GMT+08:00
AIImageBuffer
图像的通用Buffer定义。该类在ai_tensor.h中定义。
class AIImageBuffer : public AISimpleTensor { public: AIImageBuffer() { format_ = JPEG; width_ = 0; height_ = 0; }; /* * @brief 获取类型名称 */ const char* const GetTypeName(); /* @brief 获取size字节大小 */ uint32_t ByteSizeLong(); /* @brief 初始化 @param [in] tensor_desc tensor描述 */ bool Init(const AITensorDescription &tensor_desc); #if defined( __ANDROID__) || defined(ANDROID) /* * @brief 序列化到buffer,用于数据跨进程交互 * @param [in] buffer 序列化输出的内存区域地址,由调用方分配 * @param [in] size 输出内存区域的大小 * @return SUCCESS: 成功 * FAILED: 失败,如果该Tensor不支持跨进程,则不需要实现此接口,直接返回失败 */ AIStatus SerializeTo(void* buffer, uint32_t size_); /* * @brief 从buffer反序列化回tensor,用于数据跨进程交互 * @param [in] buffer 输入的内存区域地址 * @param [in] size 输入内存区域的大小 * @return SUCCESS: 成功 * FAILED: 失败,如果该Tensor不支持跨进程,则不需要实现此接口,直接返回失败 */ AIStatus DeserializeFrom(const void* buffer, uint32_t size_); #endif /* * @brief 获取描述信息 */ static AITensorDescription GetDescription( const std::string &size = "0",const std::string &height="0", const std::string &width="0", const std::string format="JPEG"); /* @brief 创建tensor */ static std::shared_ptr<IAITensor> CreateTensor(const AITensorDescription& tensor_desc); /* @brief 获取图像格式 */ ImageFormat GetFormat(); /* @brief 设置图像格式 */ void SetFormat(ImageFormat format); /* @brief 获取height */ int32_t GetHeight(); /* @brief 设置height */ void SetHeight(int32_t height); /* @brief 获取width */ int32_t GetWidth(); /* @brief 设置width */ void SetWidth(int32_t width); private: ImageFormat format_; int32_t width_; int32_t height_; };
父主题: 其他用于编译依赖的接口