AmpereMeterALGO.h 1.2 KB

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