/* * @Author: turboLIU * @Date: 2022-07-25 09:47:04 * @LastEditTime: 2024-07-08 13:18:05 * @Description: Do not edit * @FilePath: /Cudayolo_track/utils.h */ #ifndef UTILS #define UTILS #include #include #include #include #include #include #include #include "detection_type_api.h" #include "objTracker.h" #include "imageMat.h" float sigmoid(float x); std::vector softmax(std::vector scores); void splitStr(const std::string& str, std::vector& tokens, char delim); std::string splitKeyname(std::string imgname); void nms(std::vector &input, std::vector &output, float nmsthreshold, int type); void nms1(std::vector& input, std::vector& output, float nmsthreshold, int type); void nms_cls(std::vector &inputs, std::vector &outputs, float nmsThresh, int clsnum); int nhwc2nchw(char* src, char* dst, int width, int height, int depth, bool rbswap=false); int loadbin2float(const char* binname, float* dst, int datalen); int loadbin2uint8(const char* binname, unsigned char* dst, int datalen); int savefloat2bin(float* src, int datalen, char* dstname); // std::vector bboxes_iou(OBJTRACK objtracker, std::vector dets, int iouType=0); int bboxes_iou(std::shared_ptr objtracker, std::vector dets, std::vector &ious, int iouType=0); //int bboxes_list(OBJTRACK objtracker, std::vector dets, std::vector& , int iouType = 0); int bboxes_dists(std::shared_ptr objtracker, std::vector dets, std::vector& distances, int iouType); int find_arg_min(std::vector datas, int& idx, float& Mindata); int find_arg_max(std::vector datas, int &idx, float &Maxdata); std::vector get_color(int cls); bool InVector(int idx, std::vector flags); #ifdef WITH_OPENCV void BGR2YUV_nv12(cv::Mat src, cv::Mat &dst); #endif int pad_img(ImgMat img, int padleft, int padright, int padtop, int padbot, unsigned char *dst, std::vector values={0,0,0}); //int add_TensorMat(std::shared_ptr a, std::shared_ptr b); //int resize_TensorMat(std::shared_ptr src, std::shared_ptr dst); void crop_img(unsigned char* src, int srcw, int srch, int srcc, int x1, int y1, int x2, int y2, unsigned char* dst); void crop_yuv(unsigned char* srcYUV, int srcw, int srch, int x1, int y1, int x2, int y2, unsigned char* dstYUV); void seg_NMS(std::vector &boxes, float thr, std::vector &result); void makeRect(int& x1, int& y1, int& x2, int& y2, int srcW, int srcH); #endif