InferNetOnnxPaddleOcrAngClsC.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #ifndef __InferNetOnnxPaddleOcrAngCls_H__
  3. #define __InferNetOnnxPaddleOcrAngCls_H__
  4. #include <iostream>
  5. #include <fstream>
  6. #include <numeric>
  7. #include <opencv2/imgproc.hpp>
  8. #include <opencv2/highgui.hpp>
  9. #include <onnxruntime_cxx_api.h>
  10. #include "../TextBlock.h"
  11. #include <locale>
  12. #include <codecvt>
  13. using namespace cv;
  14. using namespace std;
  15. using namespace Ort;
  16. class InferNetOnnxPaddleOcrAngCls
  17. {
  18. public:
  19. InferNetOnnxPaddleOcrAngCls();
  20. void LoadNetwork(const void* modelData, size_t modelDataLength);
  21. int Process(cv::Mat imageCv);
  22. int PostProcess(float* pdataIn);
  23. void Dispose();
  24. private:
  25. Mat preprocess(Mat srcimg);
  26. void normalize_(Mat img);
  27. int inpWidth = 192;
  28. int inpHeight = 48;
  29. int numOut;
  30. std::vector<float> input_image_;
  31. Env env = Env(ORT_LOGGING_LEVEL_ERROR, "Angle classify");
  32. Ort::Session* ort_session = nullptr;
  33. SessionOptions sessionOptions = SessionOptions();
  34. std::vector<char*> inputNames;
  35. std::vector<char*> outputNames;
  36. std::vector<std::vector<int64_t>> inputNodeDims; // >=1 outputs
  37. std::vector<std::vector<int64_t>> outputNodeDims; // >=1 outputs
  38. volatile bool _modelLoaded = false;
  39. };
  40. #endif