DoubleTemperatureGuageALGO.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <iostream>
  11. #include <fstream>
  12. #include <string>
  13. #include <math.h>
  14. #include <cmath>
  15. #include <opencv2/imgproc.hpp>
  16. #include <opencv2/highgui.hpp>
  17. #include <opencv2/highgui/highgui.hpp>
  18. #include "opencv2/imgproc/types_c.h"
  19. #include <onnxruntime_cxx_api.h>
  20. #include <vector>
  21. using namespace cv;
  22. using namespace std;
  23. using namespace Ort;
  24. #define SEG_IMAGE_SIZE 512
  25. #define LINE_HEIGH 120
  26. #define LINE_WIDTH 1600
  27. #define CIRCLE_RADIUS 250
  28. //#define METER_RANGE 120
  29. class DoubleTemperatureGuageALGO
  30. {
  31. private:
  32. const float pi = 3.1415926536f;
  33. const int circle_center[2] = { 270, 256 };//300,238 300,255
  34. int METER_RANGE = 120;
  35. public:
  36. void Init(bool IsCuda);
  37. pair<float, float> detect(Mat& cv_image, int MaxRange);
  38. Mat creat_line_image(const Mat& circle, int Radius, int RingStride);
  39. pair<float, float> get_meter_reader(const Mat& image);
  40. private:
  41. int inpWidth;
  42. int inpHeight;
  43. int outWidth;
  44. int outHeight;
  45. const float mean[3] = { 0.5f,0.5f,0.5f };
  46. const float stds[3] = { 0.5f,0.5f,0.5f };
  47. Env env = Env(ORT_LOGGING_LEVEL_ERROR, "u2net");
  48. Ort::Session* ort_session = nullptr;
  49. SessionOptions sessionOptions = SessionOptions();
  50. vector<char*> input_names;
  51. vector<char*> output_names;
  52. vector<vector<int64_t>> input_node_dims; // >=1 outputs
  53. vector<vector<int64_t>> output_node_dims; // >=1 outputs
  54. };