1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef __YOLOV5_COMMON_H_
- #define __YOLOV5_COMMON_H_
- #include <fstream>
- #include <map>
- #include <sstream>
- #include <vector>
- #include <opencv2/opencv.hpp>
- #include "NvInfer.h"
- #include "yololayer.h"
- using namespace nvinfer1;
- cv::Rect get_rect(cv::Mat& img, float bbox[4]);
- float iou(float lbox[4], float rbox[4]);
- bool cmp(const Yolo::Detection& a, const Yolo::Detection& b);
- void nms(std::vector<Yolo::Detection>& res, float *output, float conf_thresh, float nms_thresh);
- // TensorRT weight files have a simple space delimited format:
- // [type] [size] <data x size in hex>
- std::map<std::string, Weights> loadWeights(const std::string file) ;
- IScaleLayer* addBatchNorm2d(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, std::string lname, float eps);
- ILayer* convBlock(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int outch, int ksize, int s, int g, std::string lname);
- ILayer* focus(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int inch, int outch, int ksize, std::string lname);
- ILayer* bottleneck(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int c1, int c2, bool shortcut, int g, float e, std::string lname);
- ILayer* bottleneckCSP(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int c1, int c2, int n, bool shortcut, int g, float e, std::string lname) ;
- ILayer* C3(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int c1, int c2, int n, bool shortcut, int g, float e, std::string lname);
- ILayer* SPP(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int c1, int c2, int k1, int k2, int k3, std::string lname) ;
- ILayer* SPPF(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, ITensor& input, int c1, int c2, int k, std::string lname) ;
- std::vector<std::vector<float>> getAnchors(std::map<std::string, Weights>& weightMap, std::string lname);
- IPluginV2Layer* addYoLoLayer(INetworkDefinition *network, std::map<std::string, Weights>& weightMap, std::string lname, std::vector<IConvolutionLayer*> dets);
- #endif
|