VoltageMeterALGO.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. using namespace Ort;
  11. using namespace cv;
  12. using namespace std;
  13. using namespace Ort;
  14. #define SEG_IMAGE_SIZE 512
  15. #define LINE_HEIGH 120
  16. #define LINE_WIDTH 1696
  17. #define CIRCLE_RADIUS 250
  18. #define METER_RANGE 450
  19. class VoltageMeterALGO
  20. {
  21. public:
  22. void Init (bool isCuda);
  23. float detect(Mat& cv_image);
  24. Mat creat_line_image(const Mat& circle,int Radius, int RingStride);
  25. float get_meter_reader(const Mat& image);
  26. private:
  27. int inpWidth;
  28. int inpHeight;
  29. int outWidth;
  30. int outHeight;
  31. const float pi = 3.1415926536f;
  32. const int circle_center[2] = { 280, 300 }; //center position[310,320]
  33. const float mean[3] = { 0.5f, 0.5f, 0.5f };
  34. const float stds[3] = { 0.5f, 0.5f, 0.5f };
  35. Env env = Env(ORT_LOGGING_LEVEL_ERROR, "u2net");
  36. Ort::Session* ort_session = nullptr;
  37. SessionOptions sessionOptions = SessionOptions();
  38. vector<char*> input_names;
  39. vector<char*> output_names;
  40. vector<vector<int64_t>> input_node_dims; // >=1 outputs
  41. vector<vector<int64_t>> output_node_dims; // >=1 outputs
  42. };