You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.6 KiB
66 lines
2.6 KiB
/*
|
|
* @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 <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <memory>
|
|
|
|
#include "detection_type_api.h"
|
|
#include "objTracker.h"
|
|
#include "imageMat.h"
|
|
|
|
|
|
float sigmoid(float x);
|
|
std::vector<float> softmax(std::vector<float> scores);
|
|
void splitStr(const std::string& str, std::vector<std::string>& tokens, char delim);
|
|
std::string splitKeyname(std::string imgname);
|
|
|
|
void nms(std::vector<objinfo> &input, std::vector<objinfo> &output, float nmsthreshold, int type);
|
|
void nms1(std::vector<objinfo>& input, std::vector<objinfo>& output, float nmsthreshold, int type);
|
|
void nms_cls(std::vector<objinfo> &inputs, std::vector<objinfo> &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<float> bboxes_iou(OBJTRACK objtracker, std::vector<objinfo> dets, int iouType=0);
|
|
int bboxes_iou(std::shared_ptr<OBJTRACK> objtracker, std::vector<objinfo> dets, std::vector<float> &ious, int iouType=0);
|
|
//int bboxes_list(OBJTRACK objtracker, std::vector<objinfo> dets, std::vector<float>& , int iouType = 0);
|
|
int bboxes_dists(std::shared_ptr<OBJTRACK> objtracker, std::vector<objinfo> dets, std::vector<float>& distances, int iouType);
|
|
int find_arg_min(std::vector<float> datas, int& idx, float& Mindata);
|
|
int find_arg_max(std::vector<float> datas, int &idx, float &Maxdata);
|
|
std::vector<int> get_color(int cls);
|
|
bool InVector(int idx, std::vector<uint8_t> 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<int> values={0,0,0});
|
|
|
|
//int add_TensorMat(std::shared_ptr<TensorMat> a, std::shared_ptr<TensorMat> b);
|
|
//int resize_TensorMat(std::shared_ptr<TensorMat> src, std::shared_ptr<TensorMat> 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<objinfo> &boxes, float thr, std::vector<objinfo> &result);
|
|
|
|
void makeRect(int& x1, int& y1, int& x2, int& y2, int srcW, int srcH);
|
|
|
|
#endif |