From f2c08973001ee2fe836709542934356575ade504 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Tue, 24 Feb 2026 18:59:26 +0300 Subject: [PATCH 1/6] First commit --- data/settings_yoloe_seg.ini | 141 ++++++++++++++++++ src/Detector/OCVDNNDetector.cpp | 32 ++++ src/Detector/OCVDNNDetector.h | 6 +- src/Detector/ONNXTensorRTDetector.cpp | 2 + src/Detector/tensorrt_onnx/YoloEONNX.hpp | 64 ++++++++ .../tensorrt_onnx/YoloEONNX_instance.hpp | 65 ++++++++ src/Detector/tensorrt_onnx/class_detector.cpp | 8 + src/Detector/tensorrt_onnx/class_detector.h | 4 +- 8 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 data/settings_yoloe_seg.ini create mode 100644 src/Detector/tensorrt_onnx/YoloEONNX.hpp create mode 100644 src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp diff --git a/data/settings_yoloe_seg.ini b/data/settings_yoloe_seg.ini new file mode 100644 index 00000000..361e4048 --- /dev/null +++ b/data/settings_yoloe_seg.ini @@ -0,0 +1,141 @@ +[detection] + +#----------------------------- +# opencv_dnn = 6 +# tensorrt = 5 +detector_backend = 5 + +#----------------------------- +# 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/yoloe-11m-seg.onnx +nn_config = C:/work/home/mtracker/Multitarget-tracker/data/yoloe-11m-seg.onnx +class_names = C:/work/home/mtracker/Multitarget-tracker/data/coco/coco.names + +#----------------------------- +confidence_threshold = 0.3 + +max_crop_ratio = 0 +max_batch = 1 +gpu_id = 0 + +#----------------------------- +# YOLOV3 +# YOLOV4 +# YOLOV5 +net_type = YOLOE + +#----------------------------- +# 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 diff --git a/src/Detector/OCVDNNDetector.cpp b/src/Detector/OCVDNNDetector.cpp index 82f4a23d..2c0f03a5 100644 --- a/src/Detector/OCVDNNDetector.cpp +++ b/src/Detector/OCVDNNDetector.cpp @@ -176,6 +176,8 @@ bool OCVDNNDetector::Init(const config_t& config) dictNetType["YOLOV26"] = ModelType::YOLOV26; dictNetType["YOLOV26_OBB"] = ModelType::YOLOV26_OBB; dictNetType["YOLOV26Mask"] = ModelType::YOLOV26Mask; + dictNetType["YOLOE"] = ModelType::YOLOE; + dictNetType["YOLOEMask"] = ModelType::YOLOEMask; auto netType = dictNetType.find(net_type->second); if (netType != dictNetType.end()) @@ -448,6 +450,14 @@ void OCVDNNDetector::DetectInCrop(const cv::UMat& colorFrame, const cv::Rect& cr ParseYOLOv26_seg(crop, detections, tmpRegions); break; + case ModelType::YOLOE: + ParseYOLOE(crop, detections, tmpRegions); + break; + + case ModelType::YOLOEMask: + ParseYOLOEMask(crop, detections, tmpRegions); + break; + default: ParseOldYOLO(crop, detections, tmpRegions); break; @@ -1225,3 +1235,25 @@ void OCVDNNDetector::ParseYOLOv26_seg(const cv::Rect& crop, std::vector } } } + +/// +/// \brief OCVDNNDetector::ParseYOLOE +/// \param crop +/// \param detections +/// \param tmpRegions +/// +void OCVDNNDetector::ParseYOLOE(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions) +{ + assert(0); +} + +/// +/// \brief OCVDNNDetector::ParseYOLOEMask +/// \param crop +/// \param detections +/// \param tmpRegions +/// +void OCVDNNDetector::ParseYOLOEMask(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions) +{ + assert(0); +} diff --git a/src/Detector/OCVDNNDetector.h b/src/Detector/OCVDNNDetector.h index 3a55dd67..a53bea11 100644 --- a/src/Detector/OCVDNNDetector.h +++ b/src/Detector/OCVDNNDetector.h @@ -56,7 +56,9 @@ class OCVDNNDetector final : public BaseDetector DFINE_IS, YOLOV26, YOLOV26_OBB, - YOLOV26Mask + YOLOV26Mask, + YOLOE, + YOLOEMask }; cv::dnn::Net m_net; @@ -97,6 +99,8 @@ class OCVDNNDetector final : public BaseDetector void ParseYOLOv26(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions); void ParseYOLOv26_obb(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions); void ParseYOLOv26_seg(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions); + void ParseYOLOE(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions); + void ParseYOLOEMask(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions); }; #endif diff --git a/src/Detector/ONNXTensorRTDetector.cpp b/src/Detector/ONNXTensorRTDetector.cpp index 9d28da54..fb82f323 100644 --- a/src/Detector/ONNXTensorRTDetector.cpp +++ b/src/Detector/ONNXTensorRTDetector.cpp @@ -105,6 +105,8 @@ bool ONNXTensorRTDetector::Init(const config_t& config) dictNetType["YOLOV26"] = tensor_rt::YOLOV26; dictNetType["YOLOV26_OBB"] = tensor_rt::YOLOV26_OBB; dictNetType["YOLOV26Mask"] = tensor_rt::YOLOV26Mask; + dictNetType["YOLOE"] = tensor_rt::YOLOE; + dictNetType["YOLOEMask"] = tensor_rt::YOLOEMask; auto netType = dictNetType.find(net_type->second); if (netType != dictNetType.end()) diff --git a/src/Detector/tensorrt_onnx/YoloEONNX.hpp b/src/Detector/tensorrt_onnx/YoloEONNX.hpp new file mode 100644 index 00000000..950ea152 --- /dev/null +++ b/src/Detector/tensorrt_onnx/YoloEONNX.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include "YoloONNX.hpp" + +/// +/// \brief The YOLOE_onnx class +/// +class YOLOE_onnx : public YoloONNX +{ +public: + YOLOE_onnx(std::vector& inputTensorNames, std::vector& outputTensorNames) + { + inputTensorNames.push_back("images"); + outputTensorNames.push_back("output0"); + } + +protected: + /// + /// \brief GetResult + /// \param output + /// \return + /// + std::vector GetResult(size_t imgIdx, int /*keep_topk*/, const std::vector& outputs, cv::Size frameSize) + { + std::vector resBoxes; + + //0: name: images, size: 1x3x640x640 + //1: name: output0, size: 1x300x6 + + const float fw = static_cast(frameSize.width) / static_cast(m_resizedROI.width); + const float fh = static_cast(frameSize.height) / static_cast(m_resizedROI.height); + + auto output = outputs[0]; + + size_t lenInd = 1; + size_t len = static_cast(m_outpuDims[0].d[lenInd]); + auto volume = len * m_outpuDims[0].d[2]; + output += volume * imgIdx; + //std::cout << "len = " << len << ", confThreshold = " << m_params.m_confThreshold << ", volume = " << volume << std::endl; + + for (size_t i = 0; i < len; ++i) + { + auto ind = i * m_outpuDims[0].d[2]; + + float classConf = output[ind + 4]; + int64_t classId = output[ind + 5]; + + if (classConf >= m_params.m_confThreshold) + { + float x = fw * (output[ind + 0] - m_resizedROI.x); + float y = fh * (output[ind + 1] - m_resizedROI.y); + float width = fw * (output[ind + 2] - output[ind + 0]); + float height = fh * (output[ind + 3] - output[ind + 1]); + + //std::cout << "ind = " << ind << ", output[0] = " << output[ind + 0] << ", output[1] = " << output[ind + 1] << ", output[2] = " << output[ind + 2] << ", output[3] = " << output[ind + 3] << std::endl; + //std::cout << "ind = " << ind << ", classConf = " << classConf << ", classId = " << classId << ", x = " << x << ", y = " << y << ", width = " << width << ", height = " << height << std::endl; + + resBoxes.emplace_back(classId, classConf, cv::Rect(cvRound(x), cvRound(y), cvRound(width), cvRound(height))); + } + } + + return resBoxes; + } +}; diff --git a/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp b/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp new file mode 100644 index 00000000..63cf66d7 --- /dev/null +++ b/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp @@ -0,0 +1,65 @@ +#pragma once + +#include "YoloONNX.hpp" + +/// +/// \brief The YOLOE_onnx class +/// +class YOLOE_instance_onnx : public YoloONNX +{ +public: + YOLOE_instance_onnx(std::vector& inputTensorNames, std::vector& outputTensorNames) + { + inputTensorNames.push_back("images"); + outputTensorNames.push_back("output0"); + outputTensorNames.push_back("output1"); + } + +protected: + /// + /// \brief GetResult + /// \param output + /// \return + /// + std::vector GetResult(size_t imgIdx, int /*keep_topk*/, const std::vector& outputs, cv::Size frameSize) + { + std::vector resBoxes; + + //0: name: images, size: 1x3x640x640 + //1: name: output0, size: 1x300x6 + + const float fw = static_cast(frameSize.width) / static_cast(m_resizedROI.width); + const float fh = static_cast(frameSize.height) / static_cast(m_resizedROI.height); + + auto output = outputs[0]; + + size_t lenInd = 1; + size_t len = static_cast(m_outpuDims[0].d[lenInd]); + auto volume = len * m_outpuDims[0].d[2]; + output += volume * imgIdx; + //std::cout << "len = " << len << ", confThreshold = " << m_params.m_confThreshold << ", volume = " << volume << std::endl; + + for (size_t i = 0; i < len; ++i) + { + auto ind = i * m_outpuDims[0].d[2]; + + float classConf = output[ind + 4]; + int64_t classId = output[ind + 5]; + + if (classConf >= m_params.m_confThreshold) + { + float x = fw * (output[ind + 0] - m_resizedROI.x); + float y = fh * (output[ind + 1] - m_resizedROI.y); + float width = fw * (output[ind + 2] - output[ind + 0]); + float height = fh * (output[ind + 3] - output[ind + 1]); + + //std::cout << "ind = " << ind << ", output[0] = " << output[ind + 0] << ", output[1] = " << output[ind + 1] << ", output[2] = " << output[ind + 2] << ", output[3] = " << output[ind + 3] << std::endl; + //std::cout << "ind = " << ind << ", classConf = " << classConf << ", classId = " << classId << ", x = " << x << ", y = " << y << ", width = " << width << ", height = " << height << std::endl; + + resBoxes.emplace_back(classId, classConf, cv::Rect(cvRound(x), cvRound(y), cvRound(width), cvRound(height))); + } + } + + return resBoxes; + } +}; diff --git a/src/Detector/tensorrt_onnx/class_detector.cpp b/src/Detector/tensorrt_onnx/class_detector.cpp index 70f2aa48..f4f2d592 100644 --- a/src/Detector/tensorrt_onnx/class_detector.cpp +++ b/src/Detector/tensorrt_onnx/class_detector.cpp @@ -22,6 +22,8 @@ #include "YoloONNXv26_bb.hpp" #include "YoloONNXv26_obb.hpp" #include "YoloONNXv26_instance.hpp" +#include "YoloEONNX.hpp" +#include "YoloEONNX_instance.hpp" namespace tensor_rt { @@ -115,6 +117,12 @@ namespace tensor_rt case ModelType::DFINE_IS: m_detector = std::make_unique(m_params.m_inputTensorNames, m_params.m_outputTensorNames); break; + case ModelType::YOLOE: + m_detector = std::make_unique(m_params.m_inputTensorNames, m_params.m_outputTensorNames); + break; + case ModelType::YOLOEMask: + m_detector = std::make_unique(m_params.m_inputTensorNames, m_params.m_outputTensorNames); + break; } // Threshold values diff --git a/src/Detector/tensorrt_onnx/class_detector.h b/src/Detector/tensorrt_onnx/class_detector.h index 29780685..8833a5d3 100644 --- a/src/Detector/tensorrt_onnx/class_detector.h +++ b/src/Detector/tensorrt_onnx/class_detector.h @@ -66,7 +66,9 @@ namespace tensor_rt DFINE_IS, YOLOV26, YOLOV26_OBB, - YOLOV26Mask + YOLOV26Mask, + YOLOE, + YOLOEMask }; /// From b96f5fa489af40de3887b28301c8c1e919b206a7 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Mon, 6 Apr 2026 22:05:57 +0300 Subject: [PATCH 2/6] Try to add fp8 Precision --- data/settings_yoloe_seg.ini | 2 +- data/settings_yolov26m.ini | 1 + src/Detector/ONNXTensorRTDetector.cpp | 1 + src/Detector/tensorrt_onnx/YoloONNX.cpp | 19 ++++++++++++----- src/Detector/tensorrt_onnx/YoloONNX.hpp | 1 + src/Detector/tensorrt_onnx/class_detector.cpp | 2 ++ src/Detector/tensorrt_onnx/class_detector.h | 3 ++- .../tensorrt_onnx/common/sampleInference.cpp | 21 +++++++++++++++++-- .../tensorrt_onnx/common/sampleUtils.cpp | 11 +++++++++- 9 files changed, 51 insertions(+), 10 deletions(-) diff --git a/data/settings_yoloe_seg.ini b/data/settings_yoloe_seg.ini index 361e4048..0fce832e 100644 --- a/data/settings_yoloe_seg.ini +++ b/data/settings_yoloe_seg.ini @@ -41,7 +41,7 @@ gpu_id = 0 # YOLOV3 # YOLOV4 # YOLOV5 -net_type = YOLOE +net_type = YOLOEMask #----------------------------- # INT8 diff --git a/data/settings_yolov26m.ini b/data/settings_yolov26m.ini index 625ce893..23dd24f4 100644 --- a/data/settings_yolov26m.ini +++ b/data/settings_yolov26m.ini @@ -47,6 +47,7 @@ net_type = YOLOV26 # INT8 # FP16 # FP32 +# FP8 inference_precision = FP16 diff --git a/src/Detector/ONNXTensorRTDetector.cpp b/src/Detector/ONNXTensorRTDetector.cpp index fb82f323..593bc29c 100644 --- a/src/Detector/ONNXTensorRTDetector.cpp +++ b/src/Detector/ONNXTensorRTDetector.cpp @@ -72,6 +72,7 @@ bool ONNXTensorRTDetector::Init(const config_t& config) dictPrecision["INT8"] = tensor_rt::INT8; dictPrecision["FP16"] = tensor_rt::FP16; dictPrecision["FP32"] = tensor_rt::FP32; + dictPrecision["FP8"] = tensor_rt::FP8; auto precision = dictPrecision.find(inference_precision->second); if (precision != dictPrecision.end()) m_localConfig.m_inferencePrecision = precision->second; diff --git a/src/Detector/tensorrt_onnx/YoloONNX.cpp b/src/Detector/tensorrt_onnx/YoloONNX.cpp index aa4d23a6..bec31df9 100644 --- a/src/Detector/tensorrt_onnx/YoloONNX.cpp +++ b/src/Detector/tensorrt_onnx/YoloONNX.cpp @@ -19,6 +19,7 @@ bool YoloONNX::Init(const SampleYoloParams& params) m_params = params; + sample::setReportableSeverity(sample::Logger::Severity::kINFO); initLibNvInferPlugins(&sample::gLogger.getTRTLogger(), ""); auto GetBindings = [&]() @@ -79,15 +80,16 @@ bool YoloONNX::Init(const SampleYoloParams& params) file.close(); } - nvinfer1::IRuntime* infer = nvinfer1::createInferRuntime(sample::gLogger); + m_inferRuntime = std::shared_ptr(nvinfer1::createInferRuntime(sample::gLogger)); if (m_params.m_dlaCore >= 0) - infer->setDLACore(m_params.m_dlaCore); + m_inferRuntime->setDLACore(m_params.m_dlaCore); - m_engine = std::shared_ptr(infer->deserializeCudaEngine(trtModelStream.data(), size), samplesCommon::InferDeleter()); + m_engine = std::shared_ptr(m_inferRuntime->deserializeCudaEngine(trtModelStream.data(), size), samplesCommon::InferDeleter()); #if (NV_TENSORRT_MAJOR < 8) - infer->destroy(); + m_inferRuntime->destroy(); + m_inferRuntime.reset(); #else - //delete infer; + //m_inferRuntime.reset(); #endif if (m_engine) @@ -233,6 +235,12 @@ bool YoloONNX::ConstructNetwork(YoloONNXUniquePtr& builder, { case tensor_rt::Precision::FP16: config->setFlag(nvinfer1::BuilderFlag::kFP16); + sample::gLogInfo << "config->setFlag(nvinfer1::BuilderFlag::kFP16)" << std::endl; + break; + + case tensor_rt::Precision::FP8: + config->setFlag(nvinfer1::BuilderFlag::kFP8); + sample::gLogInfo << "config->setFlag(nvinfer1::BuilderFlag::kFP8)" << std::endl; break; case tensor_rt::Precision::INT8: @@ -243,6 +251,7 @@ bool YoloONNX::ConstructNetwork(YoloONNXUniquePtr& builder, BatchStream calibrationStream(m_params.m_explicitBatchSize, m_params.m_nbCalBatches, m_params.m_calibrationBatches, m_params.m_dataDirs); calibrator.reset(new Int8EntropyCalibrator2(calibrationStream, 0, "Yolo", m_params.m_inputTensorNames[0].c_str())); config->setFlag(nvinfer1::BuilderFlag::kINT8); + sample::gLogInfo << "config->setFlag(nvinfer1::BuilderFlag::kINT8)" << std::endl; config->setInt8Calibrator(calibrator.get()); } break; diff --git a/src/Detector/tensorrt_onnx/YoloONNX.hpp b/src/Detector/tensorrt_onnx/YoloONNX.hpp index 2452f61d..cae188c5 100644 --- a/src/Detector/tensorrt_onnx/YoloONNX.hpp +++ b/src/Detector/tensorrt_onnx/YoloONNX.hpp @@ -86,6 +86,7 @@ class YoloONNX private: std::shared_ptr m_engine; //!< The TensorRT engine used to run the network + std::shared_ptr m_inferRuntime; cv::Mat m_resized; std::vector m_resizedBatch; diff --git a/src/Detector/tensorrt_onnx/class_detector.cpp b/src/Detector/tensorrt_onnx/class_detector.cpp index f4f2d592..cc98ce3c 100644 --- a/src/Detector/tensorrt_onnx/class_detector.cpp +++ b/src/Detector/tensorrt_onnx/class_detector.cpp @@ -142,6 +142,8 @@ namespace tensor_rt dictprecision[tensor_rt::INT8] = "kINT8"; dictprecision[tensor_rt::FP16] = "kHALF"; dictprecision[tensor_rt::FP32] = "kFLOAT"; + dictprecision[tensor_rt::FP8] = "kFP8"; + auto precision = dictprecision.find(m_params.m_precision); if (precision != dictprecision.end()) precisionStr = precision->second; diff --git a/src/Detector/tensorrt_onnx/class_detector.h b/src/Detector/tensorrt_onnx/class_detector.h index 8833a5d3..454abc36 100644 --- a/src/Detector/tensorrt_onnx/class_detector.h +++ b/src/Detector/tensorrt_onnx/class_detector.h @@ -78,7 +78,8 @@ namespace tensor_rt { INT8 = 0, FP16, - FP32 + FP32, + FP8 }; /// diff --git a/src/Detector/tensorrt_onnx/common/sampleInference.cpp b/src/Detector/tensorrt_onnx/common/sampleInference.cpp index f0470bf7..b131ca32 100644 --- a/src/Detector/tensorrt_onnx/common/sampleInference.cpp +++ b/src/Detector/tensorrt_onnx/common/sampleInference.cpp @@ -46,6 +46,7 @@ #include "sampleOptions.h" #include "sampleReporting.h" #include "sampleUtils.h" +#include using namespace nvinfer1; namespace sample { @@ -1320,7 +1321,15 @@ void Binding::fill() fillBuffer(buffer->getHostBuffer(), volume, 0, 255); break; } - case nvinfer1::DataType::kFP8: ASSERT(false && "FP8 is not supported"); + case nvinfer1::DataType::kFP8: + { +#if 0 + ASSERT(false && "FP8 is not supported"); +#else + fillBuffer<__nv_fp8_e4m3>(buffer->getHostBuffer(), volume, __nv_fp8_e4m3(- 1.0f), __nv_fp8_e4m3(1.0f)); +#endif + break; + } #if (NV_TENSORRT_MAJOR > 8) case nvinfer1::DataType::kINT4: ASSERT(false && "INT4 is not supported"); #endif @@ -1388,7 +1397,15 @@ void Binding::dump(std::ostream& os, Dims dims, Dims strides, int32_t vectorDim, break; } #endif - case nvinfer1::DataType::kFP8: ASSERT(false && "FP8 is not supported"); + case nvinfer1::DataType::kFP8: + { +#if 0 + ASSERT(false && "FP8 is not supported"); +#else + dumpBuffer<__nv_fp8_e4m3>(outputBuffer, separator, os, dims, strides, vectorDim, spv); +#endif + break; + } #if (NV_TENSORRT_MAJOR > 8) case nvinfer1::DataType::kINT4: ASSERT(false && "INT4 is not supported"); #endif diff --git a/src/Detector/tensorrt_onnx/common/sampleUtils.cpp b/src/Detector/tensorrt_onnx/common/sampleUtils.cpp index 8f172afe..89a128ee 100644 --- a/src/Detector/tensorrt_onnx/common/sampleUtils.cpp +++ b/src/Detector/tensorrt_onnx/common/sampleUtils.cpp @@ -18,6 +18,7 @@ #include "sampleUtils.h" #include "bfloat16.h" #include "half.h" +#include using namespace nvinfer1; @@ -433,6 +434,11 @@ void print(std::ostream& os, __half v) os << static_cast(v); } +void print(std::ostream& os, __nv_fp8_e4m3 v) +{ + os << static_cast(v); +} + template void dumpBuffer(void const* buffer, std::string const& separator, std::ostream& os, Dims const& dims, Dims const& strides, int32_t vectorDim, int32_t spv) @@ -482,6 +488,8 @@ template void dumpBuffer(void const* buffer, std::string const& separat Dims const& strides, int32_t vectorDim, int32_t spv); template void dumpBuffer(void const* buffer, std::string const& separator, std::ostream& os, Dims const& dims, Dims const& strides, int32_t vectorDim, int32_t spv); +template void dumpBuffer<__nv_fp8_e4m3>(void const* buffer, std::string const& separator, std::ostream& os, Dims const& dims, + Dims const& strides, int32_t vectorDim, int32_t spv); template void sparsify(T const* values, int64_t count, int32_t k, int32_t trs, std::vector& sparseWeights) @@ -566,7 +574,7 @@ void fillBuffer(void* buffer, int64_t volume, T min, T max) { T* typedBuffer = static_cast(buffer); std::default_random_engine engine; - std::uniform_real_distribution distribution(min, max); + std::uniform_real_distribution distribution((float)min, (float)max); auto generator = [&engine, &distribution]() { return static_cast(distribution(engine)); }; std::generate(typedBuffer, typedBuffer + volume, generator); } @@ -580,6 +588,7 @@ template void fillBuffer(void* buffer, int64_t volume, int8_t min, int8_ template void fillBuffer<__half>(void* buffer, int64_t volume, __half min, __half max); template void fillBuffer(void* buffer, int64_t volume, BFloat16 min, BFloat16 max); template void fillBuffer(void* buffer, int64_t volume, uint8_t min, uint8_t max); +template void fillBuffer<__nv_fp8_e4m3>(void* buffer, int64_t volume, __nv_fp8_e4m3 min, __nv_fp8_e4m3 max); bool matchStringWithOneWildcard(std::string const& pattern, std::string const& target) { From 787d1acd0af0d5b51dc0519454743eaab43090a3 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Thu, 30 Apr 2026 22:25:28 +0300 Subject: [PATCH 3/6] Build with CUDA 13 --- src/Detector/tensorrt_onnx/common/sampleDevice.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Detector/tensorrt_onnx/common/sampleDevice.cpp b/src/Detector/tensorrt_onnx/common/sampleDevice.cpp index 7964aeb5..1e7ee17a 100644 --- a/src/Detector/tensorrt_onnx/common/sampleDevice.cpp +++ b/src/Detector/tensorrt_onnx/common/sampleDevice.cpp @@ -107,8 +107,17 @@ void setCudaDevice(int32_t device, std::ostream& os) os << "Shared Memory per SM: " << (properties.sharedMemPerMultiprocessor >> 10) << " KiB" << std::endl; os << "Memory Bus Width: " << properties.memoryBusWidth << " bits" << " (ECC " << (properties.ECCEnabled != 0 ? "enabled" : "disabled") << ")" << std::endl; +#if (CUDA_VERSION < 13000) os << "Application Compute Clock Rate: " << properties.clockRate / 1000000.0F << " GHz" << std::endl; os << "Application Memory Clock Rate: " << properties.memoryClockRate / 1000000.0F << " GHz" << std::endl; +#else + int clockRateKHz = 0; + cudaDeviceGetAttribute(&clockRateKHz, cudaDevAttrClockRate, device); + int memoryClockRateKHz = 0; + cudaDeviceGetAttribute(&memoryClockRateKHz, cudaDevAttrMemoryClockRate, device); + os << "Application Compute Clock Rate: " << clockRateKHz / 1000000.0F << " GHz" << std::endl; + os << "Application Memory Clock Rate: " << memoryClockRateKHz / 1000000.0F << " GHz" << std::endl; +#endif os << std::endl; os << "Note: The application clock rates do not reflect the actual clock rates that the GPU is " << "currently running at." << std::endl; From 36c0e9fc8c937a438e3aeb531a706e19ba11ad73 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Wed, 15 Jul 2026 07:37:10 +0300 Subject: [PATCH 4/6] YOLOE works --- example/examples.h | 2 +- src/Detector/BaseDetector.h | 5 +- src/Detector/MotionDetector.cpp | 2 +- src/Detector/MotionDetector.h | 2 +- src/Detector/OCVDNNDetector.cpp | 76 ++++- .../tensorrt_onnx/YoloEONNX_instance.hpp | 289 ++++++++++++++++-- 6 files changed, 351 insertions(+), 25 deletions(-) diff --git a/example/examples.h b/example/examples.h index bc6db8a1..c58584e7 100644 --- a/example/examples.h +++ b/example/examples.h @@ -543,7 +543,7 @@ class ONNXTensorRTExample final : public VideoExample } } - //m_detector->CalcMotionMap(frame); + m_detector->CalcMotionMap(frame, true); } }; diff --git a/src/Detector/BaseDetector.h b/src/Detector/BaseDetector.h index bf8ae882..0625017c 100644 --- a/src/Detector/BaseDetector.h +++ b/src/Detector/BaseDetector.h @@ -159,7 +159,7 @@ class BaseDetector /// \brief CalcMotionMap /// \param frame /// - virtual void CalcMotionMap(cv::Mat& frame) + virtual void CalcMotionMap(cv::Mat& frame, bool drawOnlyMasks = true) { if (m_motionMap.size() != frame.size()) m_motionMap = cv::Mat(frame.size(), CV_32FC1, cv::Scalar(0, 0, 0)); @@ -169,7 +169,8 @@ class BaseDetector { if (region.m_boxMask.empty()) { - cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), cv::FILLED); + if (!drawOnlyMasks) + cv::ellipse(foreground, region.m_rrect, cv::Scalar(255, 255, 255), cv::FILLED); } else { diff --git a/src/Detector/MotionDetector.cpp b/src/Detector/MotionDetector.cpp index a97ad063..972db5f4 100644 --- a/src/Detector/MotionDetector.cpp +++ b/src/Detector/MotionDetector.cpp @@ -100,7 +100,7 @@ void MotionDetector::ResetModel(const cv::UMat& img, const cv::Rect& roiRect) /// \brief MotionDetector::CalcMotionMap /// \param frame /// -void MotionDetector::CalcMotionMap(cv::Mat& frame) +void MotionDetector::CalcMotionMap(cv::Mat& frame, bool /*drawOnlyMasks*/) { if (m_motionMap.size() != frame.size()) m_motionMap = cv::Mat(frame.size(), CV_32FC1, cv::Scalar(0, 0, 0)); diff --git a/src/Detector/MotionDetector.h b/src/Detector/MotionDetector.h index f61d4f0f..ad3d1921 100644 --- a/src/Detector/MotionDetector.h +++ b/src/Detector/MotionDetector.h @@ -22,7 +22,7 @@ class MotionDetector : public BaseDetector return true; } - void CalcMotionMap(cv::Mat& frame) override; + void CalcMotionMap(cv::Mat& frame, bool drawOnlyMasks) override; void ResetModel(const cv::UMat& img, const cv::Rect& roiRect) override; diff --git a/src/Detector/OCVDNNDetector.cpp b/src/Detector/OCVDNNDetector.cpp index 4f0ff88f..e8ea1634 100644 --- a/src/Detector/OCVDNNDetector.cpp +++ b/src/Detector/OCVDNNDetector.cpp @@ -1244,7 +1244,43 @@ void OCVDNNDetector::ParseYOLOv26_seg(const cv::Rect& crop, std::vector /// void OCVDNNDetector::ParseYOLOE(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions) { - assert(0); + float x_factor = crop.width / static_cast(m_inWidth); + float y_factor = crop.height / static_cast(m_inHeight); + + //0: name: images, size: 1x3x640x640 + //1: name: output0, size: 1x54x8400 + //2: name: output1, size: 1x32x160x160 + + int rows = detections[0].size[2]; + int dimensions = detections[0].size[1]; + + detections[0] = detections[0].reshape(1, dimensions); + cv::transpose(detections[0], detections[0]); + + float* data = (float*)detections[0].data; + + for (int i = 0; i < rows; ++i) + { + float* classes_scores = data + 4; + + cv::Mat scores(1, static_cast(m_classNames.size()), CV_32FC1, classes_scores); + cv::Point class_id; + double maxClassScore = 0; + cv::minMaxLoc(scores, 0, &maxClassScore, 0, &class_id); + + if (maxClassScore > m_confidenceThreshold) + { + float x = data[0] * x_factor + crop.x; + float y = data[1] * y_factor + crop.y; + float w = data[2] * x_factor; + float h = data[3] * y_factor; + //float angle = 180.f * data[4 + scores.cols] / M_PI; + + if (m_classesWhiteList.empty() || m_classesWhiteList.find(T2T(class_id.x)) != std::end(m_classesWhiteList)) + tmpRegions.emplace_back(cv::RotatedRect(cv::Point2f(x, y), cv::Size2f(w, h), 0), T2T(class_id.x), static_cast(maxClassScore)); + } + data += dimensions; + } } /// @@ -1255,5 +1291,41 @@ void OCVDNNDetector::ParseYOLOE(const cv::Rect& crop, std::vector& dete /// void OCVDNNDetector::ParseYOLOEMask(const cv::Rect& crop, std::vector& detections, regions_t& tmpRegions) { - assert(0); + float x_factor = crop.width / static_cast(m_inWidth); + float y_factor = crop.height / static_cast(m_inHeight); + + //0: name: images, size: 1x3x640x640 + //1: name: output0, size: 1x54x8400 + //2: name: output1, size: 1x32x160x160 + + int rows = detections[0].size[2]; + int dimensions = detections[0].size[1]; + + detections[0] = detections[0].reshape(1, dimensions); + cv::transpose(detections[0], detections[0]); + + float* data = (float*)detections[0].data; + + for (int i = 0; i < rows; ++i) + { + float* classes_scores = data + 4; + + cv::Mat scores(1, static_cast(m_classNames.size()), CV_32FC1, classes_scores); + cv::Point class_id; + double maxClassScore = 0; + cv::minMaxLoc(scores, 0, &maxClassScore, 0, &class_id); + + if (maxClassScore > m_confidenceThreshold) + { + float x = data[0] * x_factor + crop.x; + float y = data[1] * y_factor + crop.y; + float w = data[2] * x_factor; + float h = data[3] * y_factor; + //float angle = 180.f * data[4 + scores.cols] / M_PI; + + if (m_classesWhiteList.empty() || m_classesWhiteList.find(T2T(class_id.x)) != std::end(m_classesWhiteList)) + tmpRegions.emplace_back(cv::RotatedRect(cv::Point2f(x, y), cv::Size2f(w, h), 0), T2T(class_id.x), static_cast(maxClassScore)); + } + data += dimensions; + } } diff --git a/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp b/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp index 63cf66d7..d65820de 100644 --- a/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp +++ b/src/Detector/tensorrt_onnx/YoloEONNX_instance.hpp @@ -23,43 +23,296 @@ class YOLOE_instance_onnx : public YoloONNX /// std::vector GetResult(size_t imgIdx, int /*keep_topk*/, const std::vector& outputs, cv::Size frameSize) { - std::vector resBoxes; - //0: name: images, size: 1x3x640x640 - //1: name: output0, size: 1x300x6 + //1: name: output0, size: 1x54x8400 + //2: name: output1, size: 1x32x160x160 + + std::vector resBoxes; const float fw = static_cast(frameSize.width) / static_cast(m_resizedROI.width); const float fh = static_cast(frameSize.height) / static_cast(m_resizedROI.height); + size_t outInd = 0; + size_t segInd = 1; + auto output = outputs[0]; - size_t lenInd = 1; - size_t len = static_cast(m_outpuDims[0].d[lenInd]); - auto volume = len * m_outpuDims[0].d[2]; + int INPUT_W = static_cast(m_inputDims[0].d[3]); + int INPUT_H = static_cast(m_inputDims[0].d[2]); + cv::Rect frameRect(0, 0, INPUT_W, INPUT_H); + + //std::cout << "output[1] mem:\n"; + //auto output1 = outputs[1]; + //for (size_t ii = 0; ii < 100; ++ii) + //{ + // std::cout << ii << ": "; + // for (size_t jj = 0; jj < 20; ++jj) + // { + // std::cout << output1[ii * 20 + jj] << " "; + // } + // std::cout << ";" << std::endl; + //} + //std::cout << ";" << std::endl; + + //0: name: images, size: 1x3x640x640 + //1: name: output0, size: 1x116x8400 + //2: name: output1, size: 1x32x160x160 + // 25200 = 3x80x80 + 3x40x40 + 3x20x20 + // 116 = x, y, w, h, 80 classes, 32 seg ancors + // 80 * 8 = 640, 40 * 16 = 640, 20 * 32 = 640 + + size_t ncInd = 1; + size_t lenInd = 2; + int nc = static_cast(m_outpuDims[outInd].d[ncInd] - 4 - 32); + int dimensions = nc + 32 + 4; + size_t len = static_cast(m_outpuDims[outInd].d[lenInd]);// / m_params.explicitBatchSize; + //auto Volume = [](const nvinfer1::Dims& d) + //{ + // return std::accumulate(d.d, d.d + d.nbDims, 1, std::multiplies()); + //}; + auto volume = len * m_outpuDims[outInd].d[ncInd]; // Volume(m_outpuDims[0]); output += volume * imgIdx; - //std::cout << "len = " << len << ", confThreshold = " << m_params.m_confThreshold << ", volume = " << volume << std::endl; + //std::cout << "len = " << len << ", nc = " << nc << ", m_params.confThreshold = " << m_params.confThreshold << ", volume = " << volume << std::endl; + + cv::Mat rawMemory(1, dimensions * static_cast(len), CV_32FC1, output); + rawMemory = rawMemory.reshape(1, dimensions); + cv::transpose(rawMemory, rawMemory); + output = (float*)rawMemory.data; + + //std::cout << "output[0] mem:\n"; + //for (size_t ii = 0; ii < 100; ++ii) + //{ + // std::cout << ii << ": "; + // for (size_t jj = 0; jj < 20; ++jj) + // { + // std::cout << output[ii * 20 + jj] << " "; + // } + // std::cout << ";" << std::endl; + //} + //std::cout << ";" << std::endl; + +#if 1 + int segWidth = 160; + int segHeight = 160; + int segChannels = 32; + + if (outputs.size() > 1) + { + //std::cout << "output1 nbDims: " << m_outpuDims[segInd].nbDims << ", "; + //for (size_t i = 0; i < m_outpuDims[segInd].nbDims; ++i) + //{ + // std::cout << m_outpuDims[segInd].d[i]; + // if (i + 1 != m_outpuDims[segInd].nbDims) + // std::cout << "x"; + //} + //std::cout << std::endl; + //std::cout << "output nbDims: " << m_outpuDims[outInd].nbDims << ", "; + //for (size_t i = 0; i < m_outpuDims[outInd].nbDims; ++i) + //{ + // std::cout << m_outpuDims[outInd].d[i]; + // if (i + 1 != m_outpuDims[outInd].nbDims) + // std::cout << "x"; + //} + //std::cout << std::endl; + + segChannels = static_cast(m_outpuDims[segInd].d[1]); + segWidth = static_cast(m_outpuDims[segInd].d[2]); + segHeight = static_cast(m_outpuDims[segInd].d[3]); + } + cv::Mat maskProposals; + std::vector> picked_proposals; + int net_width = nc + 4 + segChannels; +#endif + + std::vector classIds; + std::vector confidences; + std::vector rectBoxes; + classIds.reserve(len); + confidences.reserve(len); + rectBoxes.reserve(len); for (size_t i = 0; i < len; ++i) { - auto ind = i * m_outpuDims[0].d[2]; + // Box + size_t k = i * (nc + 4 + 32); - float classConf = output[ind + 4]; - int64_t classId = output[ind + 5]; + int classId = -1; + float objectConf = 0.f; + for (int j = 0; j < nc; ++j) + { + const float classConf = output[k + 4 + j]; + if (classConf > objectConf) + { + classId = j; + objectConf = classConf; + } + } + + //if (objectConf > 0.1) + // std::cout << i << ": objectConf = " << objectConf << ", classId = " << classId << std::endl; + + //if (i == 0) + //{ + // std::cout << "without nms: mem" << i << ": "; + // for (size_t ii = 0; ii < 4; ++ii) + // { + // std::cout << output[k + ii] << " "; + // } + // std::cout << ";" << std::endl; + // for (size_t ii = 4; ii < nc + 4; ++ii) + // { + // std::cout << output[k + ii] << " "; + // } + // std::cout << ";" << std::endl; + // for (size_t ii = nc + 4; ii < nc + 4 + 32; ++ii) + // { + // std::cout << output[k + ii] << " "; + // } + // std::cout << ";" << std::endl; + //} - if (classConf >= m_params.m_confThreshold) + if (objectConf >= m_params.m_confThreshold) { - float x = fw * (output[ind + 0] - m_resizedROI.x); - float y = fh * (output[ind + 1] - m_resizedROI.y); - float width = fw * (output[ind + 2] - output[ind + 0]); - float height = fh * (output[ind + 3] - output[ind + 1]); + // (center x, center y, width, height) to (x, y, w, h) + float x = output[k] - output[k + 2] / 2; + float y = output[k + 1] - output[k + 3] / 2; + float width = output[k + 2]; + float height = output[k + 3]; - //std::cout << "ind = " << ind << ", output[0] = " << output[ind + 0] << ", output[1] = " << output[ind + 1] << ", output[2] = " << output[ind + 2] << ", output[3] = " << output[ind + 3] << std::endl; - //std::cout << "ind = " << ind << ", classConf = " << classConf << ", classId = " << classId << ", x = " << x << ", y = " << y << ", width = " << width << ", height = " << height << std::endl; + //auto ClampToFrame = [](float& v, float& size, int hi) -> int + //{ + // int res = 0; +// + // if (size < 1) + // size = 0; +// + // if (v < 0) + // { + // res = v; + // v = 0; + // return res; + // } + // else if (v + size > hi - 1) + // { + // res = v; + // v = hi - 1 - size; + // if (v < 0) + // { + // size += v; + // v = 0; + // } + // res -= v; + // return res; + // } + // return res; + //}; + //ClampToFrame(x, width, frameSize.width); + //ClampToFrame(y, height, frameSize.height); - resBoxes.emplace_back(classId, classConf, cv::Rect(cvRound(x), cvRound(y), cvRound(width), cvRound(height))); + if (width > 4 && height > 4) + { + classIds.push_back(classId); + confidences.push_back(objectConf); + rectBoxes.emplace_back(cvRound(x), cvRound(y), cvRound(width), cvRound(height)); + rectBoxes.back() = rectBoxes.back() & frameRect; + + std::vector temp_proto(output + k + 4 + nc, output + k + net_width); + picked_proposals.push_back(temp_proto); + } } } + //std::cout << "rectBoxes.size = " << rectBoxes.size() << std::endl; + + // Non-maximum suppression to eliminate redudant overlapping boxes + std::vector indices; + cv::dnn::NMSBoxes(rectBoxes, confidences, m_params.m_confThreshold, m_params.m_nmsThreshold, indices); + resBoxes.reserve(indices.size()); + + for (size_t bi = 0; bi < indices.size(); ++bi) + { + resBoxes.emplace_back(classIds[indices[bi]], confidences[indices[bi]], Clamp(rectBoxes[indices[bi]], frameSize)); + maskProposals.push_back(cv::Mat(picked_proposals[indices[bi]]).t()); + } + + if (!maskProposals.empty()) + { + // Mask processing + const float* pdata = outputs[1]; + std::vector maskFloat(pdata, pdata + segChannels * segWidth * segHeight); + + static constexpr float MASK_THRESHOLD = 0.5; + + cv::Mat mask_protos = cv::Mat(maskFloat); + cv::Mat protos = mask_protos.reshape(0, { segChannels, segWidth * segHeight }); + + cv::Mat matmulRes = (maskProposals * protos).t();//n*32 32*25600 + cv::Mat masks = matmulRes.reshape(static_cast(resBoxes.size()), { segWidth, segHeight }); + std::vector maskChannels; + split(masks, maskChannels); + for (size_t i = 0; i < resBoxes.size(); ++i) + { + cv::Mat dest; + cv::Mat mask; + //sigmoid + cv::exp(-maskChannels[i], dest); + dest = 1.0 / (1.0 + dest);//160*160 + + int padw = 0; + int padh = 0; + cv::Rect roi(int((float)padw / INPUT_W * segWidth), int((float)padh / INPUT_H * segHeight), int(segWidth - padw / 2), int(segHeight - padh / 2)); + dest = dest(roi); + + cv::resize(dest, mask, cv::Size(INPUT_W, INPUT_H), cv::INTER_NEAREST); + + resBoxes[i].m_boxMask = mask(resBoxes[i].m_brect) > MASK_THRESHOLD; + +#if 0 + static int globalObjInd = 0; + SaveMat(resBoxes[i].m_boxMask, std::to_string(globalObjInd++), ".png", "tmp", true); +#endif + +#if 1 + std::vector> contours; +#if ((CV_VERSION_MAJOR > 4) || ((CV_VERSION_MAJOR == 4) && (CV_VERSION_MINOR > 9))) + cv::findContoursLinkRuns(resBoxes[i].m_boxMask, contours); +#else + cv::findContours(resBoxes[i].m_boxMask, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE, cv::Point()); +#endif + for (const auto& contour : contours) + { + cv::Rect br = cv::boundingRect(contour); + + //std::cout << "contour br: " << br << std::endl; + + if (br.width >= 4 && + br.height >= 4) + { + int dx = resBoxes[i].m_brect.x; + int dy = resBoxes[i].m_brect.y; + + cv::RotatedRect rr = (contour.size() < 5) ? cv::minAreaRect(contour) : cv::fitEllipse(contour); + rr.center.x = (rr.center.x + dx - m_resizedROI.x) * fw; + rr.center.y = (rr.center.y + dy - m_resizedROI.y) * fw; + rr.size.width *= fw; + rr.size.height *= fh; + + br.x = cvRound((dx + br.x - m_resizedROI.x) * fw); + br.y = cvRound((dy + br.y - m_resizedROI.y) * fh); + br.width = cvRound(br.width * fw); + br.height = cvRound(br.height * fh); + + resBoxes[i].m_brect = br; + resBoxes[i].m_rrect = rr; + + //std::cout << "resBoxes[" << i << "] br: " << br << ", rr: (" << rr.size << " from " << rr.center << ", " << rr.angle << ")" << std::endl; + + break; + } + } +#endif + } + } return resBoxes; } }; From e61a11dcf07eacdccf44b83b04a84a4aeb1391f0 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Wed, 15 Jul 2026 08:23:23 +0300 Subject: [PATCH 5/6] More debug logs --- example/VideoExample.cpp | 7 ++++++- src/Detector/OCVDNNDetector.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/example/VideoExample.cpp b/example/VideoExample.cpp index 4c41e003..632f7db2 100644 --- a/example/VideoExample.cpp +++ b/example/VideoExample.cpp @@ -532,6 +532,9 @@ void VideoExample::DrawTrack(cv::Mat frame, const std::string& userLabel) { cv::Scalar color = track.m_isStatic ? cv::Scalar(255, 0, 255) : cv::Scalar(0, 255, 0); + cv::Rect brect = track.m_rrect.boundingRect(); + +#if 0 cv::Point2f rectPoints[4]; track.m_rrect.points(rectPoints); //std::cout << "track: rrect [" << track.m_rrect.size << " from " << track.m_rrect.center << ", " << track.m_rrect.angle << "]" << std::endl; @@ -539,6 +542,9 @@ void VideoExample::DrawTrack(cv::Mat frame, { cv::line(frame, rectPoints[i], rectPoints[(i+1) % 4], color); } +#else + cv::rectangle(frame, brect, color); +#endif #if 0 #if 0 @@ -607,7 +613,6 @@ void VideoExample::DrawTrack(cv::Mat frame, } } - cv::Rect brect = track.m_rrect.boundingRect(); std::stringstream label; label << track.m_ID.ID2Str(); if (track.m_type != bad_type) diff --git a/src/Detector/OCVDNNDetector.cpp b/src/Detector/OCVDNNDetector.cpp index e8ea1634..08d681db 100644 --- a/src/Detector/OCVDNNDetector.cpp +++ b/src/Detector/OCVDNNDetector.cpp @@ -385,6 +385,14 @@ void OCVDNNDetector::DetectInCrop(const cv::UMat& colorFrame, const cv::Rect& cr std::vector detections; m_net.forward(detections, m_outNames); //compute output +#if 0 + std::cout << "Out layers:\n"; + for (size_t i = 0; i < detections.size(); ++i) + { + std::cout << i << ": " << detections[i].size() << "\n"; + } +#endif + switch (m_netType) { case ModelType::YOLOV5: From 87b33f75e2865f4a38313a295b12b4043f46e3e9 Mon Sep 17 00:00:00 2001 From: Nuzhny007 Date: Wed, 15 Jul 2026 08:25:16 +0300 Subject: [PATCH 6/6] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b99a0cc4..88adfac7 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ ## Latest Features +- Add YOLOE detection support [THU-MIG/yoloe](https://github.com/THU-MIG/yoloe) - Add new SOTA: YOLOv26, YOLOv26-obb and YOLOv26-seg models from [ultralytics/ultralytics](https://github.com/ultralytics/ultralytics) - Add RT-DETRv4 (API similar D-FINE) detection model [RT-DETRs/RT-DETRv4](https://github.com/RT-DETRs/RT-DETRv4) - Add D-FINE seg detection model [ArgoHA/D-FINE-seg](https://github.com/ArgoHA/D-FINE-seg)