Yolo-Detection/upbot_SORT/include/sort_test/utils.h

69 lines
1.6 KiB
C
Raw Normal View History

2024-11-21 14:16:10 +08:00
#pragma once
#include <iostream>
#include <numeric>
#include <opencv2/opencv.hpp>
/**
* @brief draw_label <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param input_image <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
* @param label <EFBFBD><EFBFBD>ǩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param left <EFBFBD><EFBFBD>ǩ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param top <EFBFBD><EFBFBD>ǩ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void draw_label(cv::Mat& input_image, std::string label, int left, int top);
/**
* @brief get_center <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param detections <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
std::vector<cv::Point> get_center(std::vector<cv::Rect> detections);
/**
* @brief get_center <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param p1 <EFBFBD><EFBFBD>1
* @param p2 <EFBFBD><EFBFBD>2
*/
float get_distance(cv::Point p1, cv::Point p2);
/**
* @brief get_center <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param p1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
* @param p2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
*/
float get_center_distance(std::vector<float> bbox1, std::vector<float> bbox2);
/**
* @brief convert_bbox_to_z <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[x1,y1,x2,y2]<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽת<EFBFBD><EFBFBD>Ϊ[x,y,s,r]<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
* @param bbox <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
std::vector<float> convert_bbox_to_z(std::vector<int> bbox);
/**
* @brief convert_x_to_bbox <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[x,y,s,r]<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽת<EFBFBD><EFBFBD>Ϊ[x1,y1,x2,y2]<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
* @param x <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
std::vector<float> convert_x_to_bbox(std::vector<float> x);
/**
* @brief iou <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>iou
* @param box1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
* @param box2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
*/
float iou(std::vector<float> box1, std::vector<float> box2);
/**
* @brief associate_detections_to_tracks <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><EFBFBD>ٽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param detections <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param trackers <EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><EFBFBD><EFBFBD>
* @param iou_threshold iou<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
std::tuple<std::vector<std::pair<int, int>>, std::vector<int>, std::vector<int>>
associate_detections_to_tracks(std::vector<cv::Rect> detections, std::vector<std::vector<int>> trackers, float iou_threshold = 0.3);