CircularOilSinglePointALGO.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <math.h>
  7. #include <opencv2/imgproc.hpp>
  8. #include <opencv2/highgui.hpp>
  9. #include <onnxruntime_cxx_api.h>
  10. #include <string>
  11. #include <math.h>
  12. #include <cmath>
  13. #include <opencv2/imgproc.hpp>
  14. #include <opencv2/highgui.hpp>
  15. #include <opencv2/highgui/highgui.hpp>
  16. #include "opencv2/imgproc/types_c.h"
  17. #include <onnxruntime_cxx_api.h>
  18. #include <vector>
  19. using namespace cv;
  20. using namespace std;
  21. using namespace Ort;
  22. class CircularOilSinglePointALGO
  23. {
  24. private:
  25. int inpWidth;
  26. int inpHeight;
  27. int outWidth;
  28. int outHeight;
  29. const float mean[3] = { 0.5f,0.5f,0.5f };
  30. const float stds[3] = { 0.5f,0.5f,0.5f };
  31. const float pi = 3.1415926536f;
  32. const int circle_center[2] = { 256, 256 };//300,238 300,255
  33. Env env = Env(ORT_LOGGING_LEVEL_ERROR, "u2net");
  34. Ort::Session* ort_session = nullptr;
  35. SessionOptions sessionOptions = SessionOptions();
  36. vector<char*> input_names;
  37. vector<char*> output_names;
  38. vector<vector<int64_t>> input_node_dims; // >=1 outputs
  39. vector<vector<int64_t>> output_node_dims; // >=1 outputs
  40. public:
  41. void Init(bool isCuda);
  42. float detect(Mat& cv_image);
  43. Mat creat_line_image(const Mat& circle, int Radius, int RingStride);
  44. float get_meter_reader(const Mat& image);
  45. };