1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #ifndef RKNNMANAGER_HPP
- #define RKNNMANAGER_HPP
- #include <rknn_api.h>
- #include <opencv4/opencv2/opencv.hpp>
- // #include <opencv2/opencv.hpp>
- #include <string>
- #include <vector>
- static unsigned char *load_model(const char *filename, int *model_size);
- class RKNNManager
- {
- public:
- static RKNNManager &getInstance()
- {
- static RKNNManager instance;
- return instance;
- }
- bool initialize(const std::string &model_path);
- bool infer(const cv::Mat &input_image, cv::Mat &output_image);
- void release();
- private:
- RKNNManager();
- ~RKNNManager();
- RKNNManager(const RKNNManager &) = delete;
- RKNNManager &operator=(const RKNNManager &) = delete;
- rknn_context ctx;
- unsigned char *model_data;
- int model_data_size;
- rknn_input_output_num io_num;
- rknn_tensor_attr input_attrs[1];
- rknn_tensor_attr output_attrs[3];
- int width, height, channel;
- void *resize_buf;
- // output image buffer
- };
- #endif // RKNNMANAGER_HPP
|