From 8e50fa307c1a3c7dfbb4bf208cae061df5efcf62 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng <58363586+Zheng-Bicheng@users.noreply.github.com> Date: Sat, 25 Feb 2023 12:49:38 +0800 Subject: [PATCH] [Bug Fix] Fixed the segment error during the visualization of the detection model (#1420) fixed detection bug --- fastdeploy/vision/visualize/detection.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fastdeploy/vision/visualize/detection.cc b/fastdeploy/vision/visualize/detection.cc index d03c9da43..bd7fe34a9 100644 --- a/fastdeploy/vision/visualize/detection.cc +++ b/fastdeploy/vision/visualize/detection.cc @@ -22,6 +22,9 @@ namespace vision { cv::Mat VisDetection(const cv::Mat& im, const DetectionResult& result, float score_threshold, int line_size, float font_size) { + if (result.boxes.empty()) { + return im; + } if (result.contain_masks) { FDASSERT(result.boxes.size() == result.masks.size(), "The size of masks must be equal to the size of boxes, but now " @@ -106,6 +109,9 @@ cv::Mat VisDetection(const cv::Mat& im, const DetectionResult& result, cv::Mat VisDetection(const cv::Mat& im, const DetectionResult& result, const std::vector& labels, float score_threshold, int line_size, float font_size) { + if (result.boxes.empty()) { + return im; + } if (result.contain_masks) { FDASSERT(result.boxes.size() == result.masks.size(), "The size of masks must be equal to the size of boxes, but now " @@ -203,6 +209,9 @@ cv::Mat Visualize::VisDetection(const cv::Mat& im, const DetectionResult& result, float score_threshold, int line_size, float font_size) { + if (result.boxes.empty()) { + return im; + } FDWARNING << "DEPRECATED: fastdeploy::vision::Visualize::VisDetection is " "deprecated, please use fastdeploy::vision:VisDetection " "function instead."