#ifndef YOLOPV2_H #define YOLOPV2_H #include #include #include #include #include #include using namespace cv; using namespace Ort; using namespace std; struct Net_config { float confThreshold; // Confidence threshold float nmsThreshold; // Non-maximum suppression threshold string modelpath; }; typedef struct BoxInfo { float x1; float y1; float x2; float y2; float score; int label; } BoxInfo; class YOLOPv2 { public: YOLOPv2(Net_config config); Mat detect(Mat& frame); private: int inpWidth; int inpHeight; int nout; int num_proposal; vector class_names; int num_class; float confThreshold; float nmsThreshold; vector input_image_; void normalize_(Mat img); void nms(vector& input_boxes); const float anchors[3][6] = { {12, 16, 19, 36, 40, 28}, {36, 75, 76, 55, 72, 146},{142, 110, 192, 243, 459, 401} }; const float stride[3] = { 8.0, 16.0, 32.0 }; const static int N = 6; //采样点数量 const float dis[N] = {1000, 2000, 3000, 4000, 5000, 6000}; //偏移量采样点实际距离(mm) const int ypos[N] = {928, 839, 778, 735, 707, 686}; //偏移量采样点y轴坐标 const int center = 1048; //车体中心x轴坐标 const float rate[N] = {6.37, 8.26, 10.53, 12.98, 15.87, 19.23}; //图像像素到实际偏移(mm)转换率 Env env = Env(ORT_LOGGING_LEVEL_ERROR, "YOLOPv2"); Ort::Session *ort_session = nullptr; SessionOptions sessionOptions = SessionOptions(); vector input_names; vector output_names; vector> input_node_dims; // >=1 outputs vector> output_node_dims; // >=1 outputs }; #endif // YOLOPV2_H