Skip to content

Commit 95ae0a0

Browse files
author
lsf
committed
lsf pc update
1 parent 7276196 commit 95ae0a0

File tree

613 files changed

+1323
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

613 files changed

+1323
-46
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set(CMAKE_BUILD_TYPE Debug)
55
#set(CMAKE_BUILD_TYPE Release)
66
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/workspace)
77
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/workspace)
8+
set(CMAKE_SKIP_BUILD_RPATH False)
9+
set(CMAKE_SKIP_RPATH False)
10+
set(CMAKE_BUILD_RPATH "/home/lsf/Third_party/TensorRT-8.6.1.6/lib")
811

912
file(GLOB_RECURSE CPPS
1013
${PROJECT_SOURCE_DIR}/apps/*.cpp

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@
2222

2323
## NEW
2424

25-
支持目标检测算法 RT-DETR !!!
25+
🚀支持单目标跟踪 OSTrack、LightTrack !!!单独的单目标跟踪仓库为 [github](https://github.com/l-sf/Track-trt)
2626

27-
28-
29-
## TODO
30-
31-
- [ ] STARK-lightning
32-
- [ ] OSTrack
33-
- [ ] yolov6
34-
- [ ] yolov8 ptq & qat
27+
🚀支持目标检测算法 RT-DETR !!!
3528

3629

3730

File renamed without changes.

apps/app_sot.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
#include <iostream>
3+
#include <fstream>
4+
#include <boost/format.hpp>
5+
#include "lighttrack/LightTrack.hpp"
6+
#include "ostrack/OSTrack.hpp"
7+
8+
using namespace std;
9+
10+
11+
inline static cv::Rect read_gt(std::string &gt_file) {
12+
std::string line;
13+
cv::Rect gt_box;
14+
std::ifstream fin(gt_file); //真实值文件
15+
getline(fin, line);
16+
if (!fin)
17+
std::cout << " Do not read groundtruth!!! " << std::endl;
18+
19+
std::stringstream line_ss = std::stringstream(line);
20+
if (line.find(',') != std::string::npos) {
21+
std::vector<std::string> data;
22+
std::string tmp;
23+
while (getline(line_ss, tmp, ','))
24+
data.push_back(tmp);
25+
gt_box.x = stoi(data[0]);
26+
gt_box.y = stoi(data[1]);
27+
gt_box.width = stoi(data[2]);
28+
gt_box.height = stoi(data[3]);
29+
} else
30+
line_ss >> gt_box.x >> gt_box.y >> gt_box.width >> gt_box.height;
31+
32+
return gt_box;
33+
}
34+
35+
36+
template<class T>
37+
void LaunchTrack(shared_ptr<T> tracker, int Mode, const string& path){
38+
39+
cv::VideoCapture cap;
40+
string display_name = "Track";
41+
42+
if (Mode == 0 || Mode == 1) {
43+
cv::Mat frame;
44+
cap.open(path);
45+
cap >> frame;
46+
cv::imshow(display_name, frame);
47+
cv::putText(frame, "Select target ROI and press ENTER", cv::Point2i(20, 30),
48+
cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(255,0,0), 1);
49+
cv::Rect init_bbox = cv::selectROI(display_name, frame);
50+
tracker->init(frame, init_bbox);
51+
cv::Rect bbox;
52+
cv::Mat img;
53+
while (true) {
54+
bool ret = cap.read(img);
55+
if (!ret) {
56+
cout << "----------Read failed!!!----------" << endl;
57+
return;
58+
}
59+
auto start = std::chrono::steady_clock::now();
60+
bbox = tracker->track(img);
61+
auto end = std::chrono::steady_clock::now();
62+
std::chrono::duration<double> elapsed = end - start;
63+
double time = 1000 * elapsed.count();
64+
printf("all infer time: %f ms\n", time);
65+
cv::rectangle(img, bbox, cv::Scalar(0,255,0), 2);
66+
cv::imshow(display_name, img);
67+
cv::waitKey(1);
68+
}
69+
}
70+
else if (Mode == 2) {
71+
string gt_path = "Woman/groundtruth_rect.txt";
72+
boost::format fmt(path.data()); //数据集图片
73+
cv::Mat frame;
74+
frame = cv::imread((fmt % 1).str(),1);
75+
cv::imshow(display_name, frame);
76+
cv::Rect init_bbox = read_gt(gt_path);
77+
tracker->init(frame, init_bbox);
78+
cv::Rect bbox;
79+
cv::Mat img;
80+
for (int i = 1; i < 597; ++i) {
81+
img = cv::imread((fmt % i).str(),1);
82+
auto start = std::chrono::steady_clock::now();
83+
bbox = tracker->track(img);
84+
auto end = std::chrono::steady_clock::now();
85+
std::chrono::duration<double> elapsed = end - start;
86+
double time = 1000 * elapsed.count();
87+
printf("all infer time: %f ms\n", time);
88+
cv::rectangle(img, bbox, cv::Scalar(0,255,0), 2);
89+
cv::imshow(display_name, img);
90+
cv::waitKey(1);
91+
}
92+
return;
93+
}
94+
else {
95+
printf("Mode错误,0:视频文件;1:摄像头;2:数据集");
96+
return;
97+
}
98+
}
99+
100+
101+
int infer_track(int Mode, const string& path){
102+
string z_path = "lighttrack-z.trt";
103+
string x_path = "lighttrack-x-head.trt";
104+
string engine_path = "ostrack-256.trt";
105+
106+
// auto tracker = LightTrack::create_tracker(z_path, x_path);
107+
auto tracker = OSTrack::create_tracker(engine_path);
108+
if(tracker == nullptr){
109+
printf("tracker is nullptr.\n");
110+
return -1;
111+
}
112+
113+
LaunchTrack(tracker, Mode, path);
114+
115+
return 0;
116+
}

0 commit comments

Comments
 (0)