Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
a29bfaa
An initial yolov8-obb support
Nuzhny007 Aug 9, 2024
2d9af8e
YOLOv8-obb works with TensorRT backend
Nuzhny007 Aug 11, 2024
a483120
Merge pull request #452 from Nuzhny007/master
Nuzhny007 Aug 11, 2024
c2cad09
First version with cuda 12.6, trt 10
Nuzhny007 Oct 2, 2024
b3bcfb3
TensorRT 10 is supported, YOLOv11, YOLOv11-obb and YOLOv11-seg detect…
Nuzhny007 Oct 2, 2024
87682db
Fix output layer index
Nuzhny007 Oct 2, 2024
58ce70d
Merge branch 'master' into master
Nuzhny007 Oct 2, 2024
31fb1a8
Merge pull request #454 from Nuzhny007/master
Nuzhny007 Oct 2, 2024
381756f
Fix build on old TensorRT
Nuzhny007 Nov 13, 2024
560b844
Merge pull request #455 from Nuzhny007/master
Nuzhny007 Nov 13, 2024
41e6de0
Sync with latest Darknet sources
Nuzhny007 Nov 16, 2024
b4a16ac
Merge pull request #456 from Nuzhny007/master
Nuzhny007 Nov 16, 2024
f5d869b
Fixed bug with resizing image to input
Nuzhny007 Nov 24, 2024
5652466
Merge pull request #457 from Nuzhny007/master
Nuzhny007 Nov 24, 2024
bd7ae44
Correct aspect ratio after frame to input resizing
Nuzhny007 Dec 10, 2024
1a2b809
Update RuCLIP library
Nuzhny007 Dec 10, 2024
a088e0c
Merge pull request #458 from Nuzhny007/master
Nuzhny007 Dec 10, 2024
8f279af
OpenCV 5.0 alpha support
Nuzhny007 Dec 25, 2024
c5682e1
Merge pull request #459 from Nuzhny007/master
Nuzhny007 Dec 25, 2024
1b9c6f4
Fixed build on Macbook M1
Nuzhny007 Jan 17, 2025
6eeddc9
Merge pull request #461 from Nuzhny007/master
Nuzhny007 Jan 17, 2025
b14a8df
Update README.md
Nuzhny007 Jan 20, 2025
9d69ad1
Update README.md
Nuzhny007 Jan 20, 2025
89ccb32
Fix build face and pedestrian detectors with OpenCV 5.0
Nuzhny007 Jan 29, 2025
6f0879d
Merge branch 'Smorodov:master' into master
Nuzhny007 Jan 29, 2025
515e8f3
Merge pull request #462 from Nuzhny007/master
Nuzhny007 Jan 29, 2025
7ff0c39
Remove dota names
Nuzhny007 Jan 29, 2025
72523e5
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Jan 29, 2025
ba13533
Remove using namespace cv
Nuzhny007 Jan 29, 2025
b1dd7c2
Support more YOLO in opencv_dnn backend
Nuzhny007 Jan 29, 2025
ce3a58c
Merge pull request #463 from Nuzhny007/master
Nuzhny007 Jan 29, 2025
0405573
Add NN weights to gitignore
Nuzhny007 Feb 4, 2025
8ddc812
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Feb 4, 2025
11f3002
Fix build for TensorRT 8,x but it works only with TensorRT 10.x
Nuzhny007 Feb 14, 2025
e2cb796
Merge pull request #464 from Nuzhny007/master
Nuzhny007 Feb 14, 2025
944d1bb
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Feb 16, 2025
0e768f3
YOLOv12 with TensorRT backend
Nuzhny007 Feb 24, 2025
a3c373d
Merge pull request #465 from Nuzhny007/master
Nuzhny007 Feb 24, 2025
e81efb0
Update ruCLIP
Nuzhny007 Feb 26, 2025
b3bffbe
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Feb 26, 2025
6d7aed1
Update CLIP
Nuzhny007 Feb 27, 2025
f243dcc
Remove external resizing
Nuzhny007 Feb 27, 2025
6d7a9c9
Merge pull request #466 from Nuzhny007/master
Nuzhny007 Feb 27, 2025
1bba750
Fix build with OpenCV 5.0
Nuzhny007 Mar 6, 2025
931d458
Merge pull request #468 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
813e0ce
Fix in CI/CD
Nuzhny007 Mar 6, 2025
0b6f5bd
Fix CodeQL warnings
Nuzhny007 Mar 6, 2025
bf49677
Merge pull request #469 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
cfd4677
Create c-cpp.yml
Nuzhny007 Mar 6, 2025
2a61a4a
Remove wrong file
Nuzhny007 Mar 6, 2025
22e8ba0
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Mar 6, 2025
b264e91
Merge pull request #470 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
4a0db01
Fix readme badges
Nuzhny007 Mar 6, 2025
befcfb0
Merge pull request #471 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
dbd7692
Update CodeQL to v2
Nuzhny007 Mar 6, 2025
d822f26
Merge pull request #472 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
4825232
Remove tests from workflow
Nuzhny007 Mar 6, 2025
800e180
Merge pull request #473 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
2b5eef5
Separate workflows
Nuzhny007 Mar 6, 2025
c0c112a
Update readme badges
Nuzhny007 Mar 6, 2025
c575098
Rename Ubuntu workflow
Nuzhny007 Mar 6, 2025
303d32b
Merge pull request #474 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
0243482
Fix readme
Nuzhny007 Mar 6, 2025
98174a0
Merge pull request #475 from Nuzhny007/master
Nuzhny007 Mar 6, 2025
47de83a
Update README.md
Nuzhny007 Mar 17, 2025
e52819f
First rf-detr implementation on TensorRT
Nuzhny007 Mar 26, 2025
1e9e6ac
RF-Detr works with TensorRT backend
Nuzhny007 Mar 26, 2025
82fbdcb
rf-detr with opencv_dnn
Nuzhny007 Mar 26, 2025
3a7e44f
Update Readme
Nuzhny007 Mar 26, 2025
c9050d6
Merge pull request #477 from Nuzhny007/master
Nuzhny007 Mar 26, 2025
efca7cd
Add contrast adjustment option with CLAHE
Nuzhny007 Mar 29, 2025
28271df
Add TensorRT D-FINE detector
Nuzhny007 Mar 31, 2025
e25a094
Fix opencv_dnn
Nuzhny007 Apr 1, 2025
ff9554c
Reduce label size
Nuzhny007 Apr 1, 2025
4996e1a
Merge pull request #478 from Nuzhny007/master
Nuzhny007 Apr 1, 2025
8dfb5db
Add yolov5 onnx detector
Nuzhny007 Apr 1, 2025
2cb417b
Merge pull request #479 from Nuzhny007/master
Nuzhny007 Apr 1, 2025
a6e9f95
Fix some instance segmentation bugs
Nuzhny007 Apr 2, 2025
8cf6c98
Merge pull request #480 from Nuzhny007/master
Nuzhny007 Apr 2, 2025
274a884
Fix some warnings
Nuzhny007 Apr 3, 2025
6a35dd8
Add new video
Nuzhny007 Apr 3, 2025
b0b9e89
Merge pull request #481 from Nuzhny007/master
Nuzhny007 Apr 3, 2025
9153f01
Add more logs
Nuzhny007 Apr 11, 2025
2767927
Add more debug logs
Nuzhny007 Apr 11, 2025
11fb457
Decrease class index in D-FINE
Nuzhny007 Apr 11, 2025
91ece35
Fix OpenCV version
Nuzhny007 Apr 13, 2025
89fec55
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Apr 13, 2025
d256980
Merge pull request #484 from Nuzhny007/master
Nuzhny007 Apr 13, 2025
2be40ec
Update README.md
Nuzhny007 Apr 24, 2025
75b7f8c
Update README.md
Nuzhny007 Apr 24, 2025
092453e
Update README.md
Nuzhny007 Apr 25, 2025
886e81c
Update codeql-analysis.yml
Nuzhny007 Apr 25, 2025
5780a4b
Update Readme
Nuzhny007 Apr 30, 2025
5355286
Fix spelling
Nuzhny007 Apr 30, 2025
bf9435b
Merge pull request #485 from Nuzhny007/master
Nuzhny007 Apr 30, 2025
dec1276
Change default settings
Nuzhny007 Apr 30, 2025
213ad35
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Apr 30, 2025
78a8a8c
Add more debug logs for opencv_dnn backend
Nuzhny007 May 10, 2025
87cf459
Merge pull request #487 from Nuzhny007/master
Nuzhny007 May 10, 2025
e7b2cf1
Update README.md
Nuzhny007 May 13, 2025
5411cef
Remove old unused data
Nuzhny007 May 23, 2025
cb34b02
Merge pull request #488 from Nuzhny007/master
Nuzhny007 May 23, 2025
885b1f0
Add spdlog as main logger
Nuzhny007 Jun 22, 2025
80ddc25
Merge pull request #489 from Nuzhny007/master
Nuzhny007 Jun 22, 2025
5942871
New linear assignment algorithm - Jonker-Volgenant / LAPJV algorithm
Nuzhny007 Jun 24, 2025
71c0a30
Merge pull request #490 from Nuzhny007/master
Nuzhny007 Jun 24, 2025
2f3d0cd
Fix bug with batch size
Nuzhny007 Jul 3, 2025
924264d
Merge pull request #491 from Nuzhny007/master
Nuzhny007 Jul 3, 2025
27401eb
Time instead frames counter
Nuzhny007 Jul 8, 2025
8520b66
Build with time stamps
Nuzhny007 Jul 8, 2025
e4d6958
Time stamps used for tracking
Nuzhny007 Jul 9, 2025
28bc90e
Rewrite code for multiple input tensors
Nuzhny007 Aug 19, 2025
a4884dc
Merge remote-tracking branch 'origin/time_point'
Nuzhny007 Aug 19, 2025
3c92a04
Merge pull request #492 from Nuzhny007/master
Nuzhny007 Aug 19, 2025
2580fc8
Disable class index decreasing
Nuzhny007 Aug 20, 2025
e207cab
Update RuCLIP code from mainstream
Nuzhny007 Aug 20, 2025
fbab502
Merge pull request #493 from Nuzhny007/master
Nuzhny007 Aug 20, 2025
ee879d2
Fixed MotionDetector example
Nuzhny007 Aug 31, 2025
c044d4e
Merge pull request #494 from Nuzhny007/master
Nuzhny007 Aug 31, 2025
7e95350
Fix macos build
Nuzhny007 Aug 31, 2025
827b7fa
Merge pull request #495 from Nuzhny007/master
Nuzhny007 Aug 31, 2025
9bb918f
RF-DETR instance segmentation
Nuzhny007 Oct 8, 2025
9197f07
Merge pull request #497 from Nuzhny007/master
Nuzhny007 Oct 8, 2025
c7559bb
Add NMS to D-FINE
Nuzhny007 Oct 31, 2025
1e93466
Remove old-style non optimal tracking algorithms
Nuzhny007 Oct 31, 2025
09fd22d
Remove old detectors and cleanup code
Nuzhny007 Oct 31, 2025
438a6d3
Add YOLOv13 support for TensorRT and opencv_dnn
Nuzhny007 Oct 31, 2025
0611e5f
Remove old yolo weights
Nuzhny007 Oct 31, 2025
f1a50ca
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Oct 31, 2025
7948bc7
Merge pull request #499 from Nuzhny007/master
Nuzhny007 Oct 31, 2025
3864fc1
Add ByteTrack based on https://github.com/Vertical-Beach/ByteTrack-cpp
Nuzhny007 Nov 3, 2025
b682a1b
Merge pull request #500 from Nuzhny007/master
Nuzhny007 Nov 3, 2025
d175607
Update codeql-analysis.yml
Nuzhny007 Nov 3, 2025
a40953f
Merge pull request #501 from Nuzhny007/master
Nuzhny007 Nov 3, 2025
a6f5574
Update codeql-analysis.yml
Nuzhny007 Nov 3, 2025
6698a93
Merge pull request #502 from Nuzhny007/master
Nuzhny007 Nov 3, 2025
4c3a522
Fix install
Nuzhny007 Nov 21, 2025
eaa4fc5
Fix BYTETracker
Nuzhny007 Nov 21, 2025
18b3ceb
More debug options
Nuzhny007 Nov 21, 2025
b1eadff
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Nov 21, 2025
5ebafb5
Merge pull request #504 from Nuzhny007/master
Nuzhny007 Nov 21, 2025
3d95682
Add pop_back method to trajectory
Nuzhny007 Nov 22, 2025
55a24d8
Merge pull request #505 from Nuzhny007/master
Nuzhny007 Nov 22, 2025
cbda3a5
Add D-FINE seg model
Nuzhny007 Jan 1, 2026
9a65e3c
Remove hierarhy from segmentation
Nuzhny007 Jan 1, 2026
d35c32a
Remove OpenCV 3 support
Nuzhny007 Jan 1, 2026
db2f535
findContoursLinkRuns instead findContours
Nuzhny007 Jan 1, 2026
3cbecc6
Disable rotated rectangle from contour calculation in segmentation mo…
Nuzhny007 Jan 1, 2026
a5b952e
Merge pull request #506 from Nuzhny007/master
Nuzhny007 Jan 1, 2026
6b5ab80
RT-DETRv4 works
Nuzhny007 Jan 3, 2026
f12c17d
Merge pull request #507 from Nuzhny007/master
Nuzhny007 Jan 3, 2026
6ca6a58
Add yolov26
Nuzhny007 Jan 18, 2026
0c2c5ef
Add yolov26-obb
Nuzhny007 Jan 18, 2026
55ce5ce
Add yolov26-seg
Nuzhny007 Jan 18, 2026
c517cf5
Update README
Nuzhny007 Jan 18, 2026
a80f34e
Merge pull request #508 from Nuzhny007/master
Nuzhny007 Jan 18, 2026
cf60708
Fix include
Nuzhny007 Feb 9, 2026
75d1fd0
Merge pull request #509 from Nuzhny007/master
Nuzhny007 Feb 9, 2026
435c279
Fix debug build with CLIP
Nuzhny007 Mar 2, 2026
bc99eb9
Merge pull request #510 from Nuzhny007/master
Nuzhny007 Mar 2, 2026
71cdbf8
Try to add fp8 Precision
Nuzhny007 Apr 6, 2026
0e935b0
Change default params for very small objects
Nuzhny007 Apr 19, 2026
e92b287
Merge pull request #513 from Nuzhny007/master
Nuzhny007 Apr 19, 2026
6eb5532
Fixed some warnings
Nuzhny007 Apr 29, 2026
10ac1b6
Merge branch 'Smorodov:master' into master
Nuzhny007 Apr 29, 2026
0040c42
Merge pull request #514 from Nuzhny007/master
Nuzhny007 Apr 29, 2026
2a5550f
More debug logs
Nuzhny007 Apr 30, 2026
4014d08
Merge pull request #515 from Nuzhny007/master
Nuzhny007 Apr 30, 2026
0850342
Build with CUDA 13
Nuzhny007 Apr 30, 2026
d70b424
Merge branch 'master' of https://github.com/Nuzhny007/Multitarget-tra…
Nuzhny007 Apr 30, 2026
782baab
Merge pull request #516 from Nuzhny007/master
Nuzhny007 Apr 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![CodeQL](https://github.com/Smorodov/Multitarget-tracker/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Smorodov/Multitarget-tracker/actions/workflows/codeql-analysis.yml)

## Latest Features
- Instance segmentation model from RF-DETR detector works with TensorRT! Export pre-trained PyTorch models [here (roboflow/rf-detr)](https://github.com/roboflow/rf-detr) to ONNX format and run Multitarget-tracker with `-e=6` example
- New linear assignment algorithm - [Jonker-Volgenant / LAPJV algorithm](https://github.com/yongyanghz/LAPJV-algorithm-c) used in [scipy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linear_sum_assignment.html) as alternative for Hungarian allgorithm
- D-FINE detector works with TensorRT! Export pre-trained PyTorch models [here (Peterande/D-FINE)](https://github.com/Peterande/D-FINE) to ONNX format and run Multitarget-tracker with `-e=6` example
- RF-DETR detector works with TensorRT! Export pre-trained PyTorch models [here (roboflow/rf-detr)](https://github.com/roboflow/rf-detr) to ONNX format and run Multitarget-tracker with `-e=6` example
Expand All @@ -20,6 +21,8 @@
## Demo Videos

### Detection & Tracking

[![RF-DETR: detection vs instance segmentation](https://img.youtube.com/vi/oKy7jEKT83c/0.jpg)](https://youtu.be/oKy7jEKT83c)
[![Satellite planes detection and tracking with YOLOv11-obb](https://img.youtube.com/vi/gTpWnkMF7Lg/0.jpg)](https://youtu.be/gTpWnkMF7Lg)
[![4-in-1 latest SOTA detectors](https://img.youtube.com/vi/Pb_HnejRpY4/0.jpg)](https://youtu.be/Pb_HnejRpY4)
[![YOLOv8-obb detection with rotated boxes](https://img.youtube.com/vi/1e6ur57Fhzs/0.jpg)](https://youtu.be/1e6ur57Fhzs)
Expand Down
142 changes: 142 additions & 0 deletions data/settings_rfdetr_seg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
[detection]

#-----------------------------
# opencv_dnn = 12
# darknet_cudnn = 10
# tensorrt = 11
detector_backend = 11

#-----------------------------
# Target and backend for opencv_dnn detector
# DNN_TARGET_CPU
# DNN_TARGET_OPENCL
# DNN_TARGET_OPENCL_FP16
# DNN_TARGET_MYRIAD
# DNN_TARGET_CUDA
# DNN_TARGET_CUDA_FP16
ocv_dnn_target = DNN_TARGET_CPU

# DNN_BACKEND_DEFAULT
# DNN_BACKEND_HALIDE
# DNN_BACKEND_INFERENCE_ENGINE
# DNN_BACKEND_OPENCV
# DNN_BACKEND_VKCOM
# DNN_BACKEND_CUDA
# DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
# DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019
ocv_dnn_backend = DNN_BACKEND_OPENCV

#-----------------------------
nn_weights = C:/work/home/mtracker/Multitarget-tracker/data/coco/rfdetr_seg_coco.onnx
nn_config = C:/work/home/mtracker/Multitarget-tracker/data/coco/rfdetr_seg_coco.onnx
class_names = C:/work/home/mtracker/Multitarget-tracker/data/coco/coco_91.names

#-----------------------------
confidence_threshold = 0.5

max_crop_ratio = 0
max_batch = 1
gpu_id = 0

#-----------------------------
# YOLOV3
# YOLOV4
# YOLOV5
net_type = RFDETR_IS

#-----------------------------
# INT8
# FP16
# FP32
inference_precision = FP16


[tracking]

#-----------------------------
# DistCenters = 0 // Euclidean distance between centers, pixels
# DistRects = 1 // Euclidean distance between bounding rectangles, pixels
# DistJaccard = 2 // Intersection over Union, IoU, [0, 1]
# DistHist = 3 // Bhatacharia distance between histograms, [0, 1]

distance_type = 0

#-----------------------------
# KalmanLinear = 0
# KalmanUnscented = 1

kalman_type = 0

#-----------------------------
# FilterCenter = 0
# FilterRect = 1
# FilterRRect = 2

filter_goal = 0

#-----------------------------
# TrackNone = 0
# TrackKCF = 1
# TrackMIL = 2
# TrackMedianFlow = 3
# TrackGOTURN = 4
# TrackMOSSE = 5
# TrackCSRT = 6
# TrackDAT = 7
# TrackSTAPLE = 8
# TrackLDES = 9
# TrackDaSiamRPN = 10
# Used if filter_goal == FilterRect

lost_track_type = 0

#-----------------------------
# MatchHungrian = 0
# MatchBipart = 1

match_type = 0

#-----------------------------
# Use constant acceleration motion model:
# 0 - unused (stable)
# 1 - use acceleration in Kalman filter (experimental)
use_aceleration = 0

#-----------------------------
# Delta time for Kalman filter
delta_time = 0.4

#-----------------------------
# Accel noise magnitude for Kalman filter
accel_noise = 0.2

#-----------------------------
# Distance threshold between region and object on two frames
dist_thresh = 0.8

#-----------------------------
# If this value > 0 than will be used circle with this radius
# If this value <= 0 than will be used ellipse with size (3*vx, 3*vy), vx and vy - horizontal and vertical speed in pixelsa
min_area_radius_pix = -1

#-----------------------------
# Minimal area radius in ration for object size. Used if min_area_radius_pix < 0
min_area_radius_k = 0.8

#-----------------------------
# If the object do not assignment more than this seconds then it will be removed
max_lost_time = 2

#-----------------------------
# The maximum trajectory length
max_trace_len = 2

#-----------------------------
# Detection abandoned objects
detect_abandoned = 0
# After this time (in seconds) the object is considered abandoned
min_static_time = 5
# After this time (in seconds) the abandoned object will be removed
max_static_time = 25
# Speed in pixels. If speed of object is more that this value than object is non static
max_speed_for_static = 10
14 changes: 11 additions & 3 deletions src/Detector/BaseDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,25 @@ class BaseDetector
cv::Mat foreground(m_motionMap.size(), CV_8UC1, cv::Scalar(0, 0, 0));
for (const auto& region : m_regions)
{
if (region.m_boxMask.empty())
{
#if (CV_VERSION_MAJOR < 4)
cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), CV_FILLED);
cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), CV_FILLED);
#else
cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), cv::FILLED);
cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), cv::FILLED);
#endif
}
else
{
cv::Rect brect = Clamp(cv::Rect(region.m_brect.x, region.m_brect.y, region.m_boxMask.cols, region.m_boxMask.rows), foreground.size());
region.m_boxMask.copyTo(foreground(brect));
}
}
if (!m_ignoreMask.empty())
cv::bitwise_and(foreground, m_ignoreMask, foreground);
cv::normalize(foreground, m_normFor, 255, 0, cv::NORM_MINMAX, m_motionMap.type());

double alpha = 0.95;
double alpha = 0.9;
cv::addWeighted(m_motionMap, alpha, m_normFor, 1 - alpha, 0, m_motionMap);

const int chans = frame.channels();
Expand Down
69 changes: 69 additions & 0 deletions src/Detector/OCVDNNDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ bool OCVDNNDetector::Init(const config_t& config)
dictNetType["YOLOV11Mask"] = ModelType::YOLOV11Mask;
dictNetType["YOLOV12"] = ModelType::YOLOV12;
dictNetType["RFDETR"] = ModelType::RFDETR;
dictNetType["RFDETR_IS"] = ModelType::RFDETR_IS;
dictNetType["DFINE"] = ModelType::DFINE;

auto netType = dictNetType.find(net_type->second);
Expand Down Expand Up @@ -414,6 +415,10 @@ void OCVDNNDetector::DetectInCrop(const cv::UMat& colorFrame, const cv::Rect& cr
ParseRFDETR(crop, detections, tmpRegions);
break;

case ModelType::RFDETR_IS:
ParseRFDETR_IS(crop, detections, tmpRegions);
break;

case ModelType::DFINE:
ParseDFINE(crop, detections, tmpRegions);
break;
Expand Down Expand Up @@ -934,6 +939,70 @@ void OCVDNNDetector::ParseRFDETR(const cv::Rect& crop, std::vector<cv::Mat>& det
}
}

///
/// \brief OCVDNNDetector::ParseRFDETR_IS
/// \param crop
/// \param detections
/// \param tmpRegions
///
void OCVDNNDetector::ParseRFDETR_IS(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions)
{
int rows = detections[0].size[1];
int dimensionsDets = detections[0].size[2];
int dimensionsLabels = detections[1].size[2];

//0: name: input, size : 1x3x560x560
//1: name: dets, size : 1x300x4
//2: name: labels, size : 1x300x91

float* dets = (float*)detections[0].data;
float* labels = (float*)detections[1].data;

float x_factor = crop.width / static_cast<float>(m_inWidth);
float y_factor = crop.height / static_cast<float>(m_inHeight);

auto L2Conf = [](float v)
{
return 1.f / (1.f + std::exp(-v));
};

for (int i = 0; i < rows; ++i)
{
float maxClassScore = L2Conf(labels[0]);
size_t classId = 0;
for (size_t cli = 1; cli < static_cast<size_t>(dimensionsLabels); ++cli)
{
auto conf = L2Conf(labels[cli]);
if (maxClassScore < conf)
{
maxClassScore = conf;
classId = cli;
}
}
if (classId > 0)
--classId;

if (maxClassScore > m_confidenceThreshold)
{
float x = dets[0];
float y = dets[1];
float w = dets[2];
float h = dets[3];

int left = cvRound((x - 0.5f * w) * x_factor);
int top = cvRound((y - 0.5f * h) * y_factor);

int width = cvRound(w * x_factor);
int height = cvRound(h * y_factor);

if (m_classesWhiteList.empty() || m_classesWhiteList.find(T2T(classId)) != std::end(m_classesWhiteList))
tmpRegions.emplace_back(cv::Rect(left + crop.x, top + crop.y, width, height), T2T(classId), static_cast<float>(maxClassScore));
}
dets += dimensionsDets;
labels += dimensionsLabels;
}
}

///
/// \brief OCVDNNDetector::ParseDFINE
/// \param crop
Expand Down
2 changes: 2 additions & 0 deletions src/Detector/OCVDNNDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OCVDNNDetector final : public BaseDetector
YOLOV11Mask,
YOLOV12,
RFDETR,
RFDETR_IS,
DFINE
};

Expand Down Expand Up @@ -85,6 +86,7 @@ class OCVDNNDetector final : public BaseDetector
void ParseYOLOv5_8_11_obb(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions);
void ParseYOLOv5_8_11_seg(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions);
void ParseRFDETR(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions);
void ParseRFDETR_IS(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions);
void ParseDFINE(const cv::Rect& crop, std::vector<cv::Mat>& detections, regions_t& tmpRegions);
};

Expand Down
1 change: 1 addition & 0 deletions src/Detector/YoloTensorRTDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ bool YoloTensorRTDetector::Init(const config_t& config)
dictNetType["YOLOV11Mask"] = tensor_rt::YOLOV11Mask;
dictNetType["YOLOV12"] = tensor_rt::YOLOV12;
dictNetType["RFDETR"] = tensor_rt::RFDETR;
dictNetType["RFDETR_IS"] = tensor_rt::RFDETR_IS;
dictNetType["DFINE"] = tensor_rt::DFINE;

auto netType = dictNetType.find(net_type->second);
Expand Down
Loading