54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
#ifndef _POST_PROCESS_H_
|
|
#define _POST_PROCESS_H_
|
|
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/core/core.hpp>
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
|
|
|
#include "model.h"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
std::tuple<uint8_t, uint8_t, uint8_t> hsv2bgr(float h, float s, float v);
|
|
|
|
std::tuple<uint8_t, uint8_t, uint8_t> hsv2rgb(float h, float s, float v);
|
|
|
|
std::tuple<uint8_t, uint8_t, uint8_t> 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<ClearDetection>& 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<Detection>& vecRes, float *fOutput, unsigned int uiOutSize, unsigned int uiDetSize, unsigned int uiClassNum, float fConfThresh, float fNmsThresh);
|
|
|
|
#endif //END OF _POST_PROCESS_H_
|