#ifndef _POST_PROCESS_H_ #define _POST_PROCESS_H_ #include #include #include #include #include #include #include #include "model.h" using namespace std; using namespace cv; std::tuple hsv2bgr(float h, float s, float v); std::tuple hsv2rgb(float h, float s, float v); std::tuple randomColor(int id); //坐标转换 void xywh2xyxy(float *xywh, float * xyxy); //获取区域框1 cv::Rect getRect(cv::Mat& img, unsigned int uiModelWidth, unsigned int uiModelHeight, float fBbox[4]); //获取区域框2 cv::Rect getRectangle(cv::Mat& img, float fBbox[4]); //计算IOU float iou(float fLbox[4], float fRbox[4]); //比较两者置信度 bool confCmp(const Detection& a, const Detection& b); //获取缩放比例 float GetResizeRatio(unsigned int uiImgWidth, unsigned int uiImgHeight, unsigned int uiModelWidth, unsigned int uiModelHeight); //左上顶点补边方式坐标还原 void UpperVertexResetLocation(float fResizeRatio, unsigned int uiOrigWidth, unsigned int uiOrigHeight, Detection &detection); //中心补边方式坐标还原 void CenterResetLocation(float fResizeRatio, unsigned int uiOrigWidth, unsigned int uiOrigHeight, unsigned int uiInputWidth, unsigned int uiInputHeight, Detection &detection); //YoloV5带清晰度后处理 非极大值抑制,默认0.5 void yolov5ClearDecodeOpenCVNms(std::vector& vecRes, float *fOutput, unsigned int uiOutSize, unsigned int uiDetSize, unsigned int uiClassNum, unsigned int uiClearNum, float fConfThresh, float fNmsThresh); //YoloV5标准后处理 非极大值抑制,默认0.5 void yolov5DecodeOpenCVNms(std::vector& vecRes, float *fOutput, unsigned int uiOutSize, unsigned int uiDetSize, unsigned int uiClassNum, float fConfThresh, float fNmsThresh); #endif //END OF _POST_PROCESS_H_