#ifndef __YOLOV5_COMMON_H_ #define __YOLOV5_COMMON_H_ #include #include #include #include #include #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& res, float *output, float conf_thresh, float nms_thresh); // TensorRT weight files have a simple space delimited format: // [type] [size] std::map loadWeights(const std::string file) ; IScaleLayer* addBatchNorm2d(INetworkDefinition *network, std::map& weightMap, ITensor& input, std::string lname, float eps); ILayer* convBlock(INetworkDefinition *network, std::map& weightMap, ITensor& input, int outch, int ksize, int s, int g, std::string lname); ILayer* focus(INetworkDefinition *network, std::map& weightMap, ITensor& input, int inch, int outch, int ksize, std::string lname); ILayer* bottleneck(INetworkDefinition *network, std::map& weightMap, ITensor& input, int c1, int c2, bool shortcut, int g, float e, std::string lname); ILayer* bottleneckCSP(INetworkDefinition *network, std::map& weightMap, ITensor& input, int c1, int c2, int n, bool shortcut, int g, float e, std::string lname) ; ILayer* C3(INetworkDefinition *network, std::map& weightMap, ITensor& input, int c1, int c2, int n, bool shortcut, int g, float e, std::string lname); ILayer* SPP(INetworkDefinition *network, std::map& weightMap, ITensor& input, int c1, int c2, int k1, int k2, int k3, std::string lname) ; ILayer* SPPF(INetworkDefinition *network, std::map& weightMap, ITensor& input, int c1, int c2, int k, std::string lname) ; std::vector> getAnchors(std::map& weightMap, std::string lname); IPluginV2Layer* addYoLoLayer(INetworkDefinition *network, std::map& weightMap, std::string lname, std::vector dets); #endif