From 9a5f6fe473d84db8feadfbe3b54695d66e69c1ec Mon Sep 17 00:00:00 2001 From: SkyLi Date: Fri, 27 Mar 2026 08:53:29 +0800 Subject: [PATCH] fix: fix multiple image duplicate loading issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - detect.py: detect_and_draw()中传给detect()的是已加载的img数组而非字符串路径 - usage_example.py: example3中复用gray_img数组而非重新加载 - analyze_temp_features.py: 复用已加载的gray_img数组进行检测 --- scripts/analyze_temp_features.py | 4 ++-- scripts/usage_example.py | 4 ++-- src/detect.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/analyze_temp_features.py b/scripts/analyze_temp_features.py index 712db90..ca52d7f 100644 --- a/scripts/analyze_temp_features.py +++ b/scripts/analyze_temp_features.py @@ -64,8 +64,8 @@ def analyze_validation_set( # 加载灰度图像(用于温度提取) gray_img = load_infrared_image(str(img_path)) - # 进行检测 - detections = detector.detect(str(img_path), conf=conf) + # 进行检测(复用已加载的图像) + detections = detector.detect(gray_img, conf=conf) for det in detections: bbox = det['bbox'] diff --git a/scripts/usage_example.py b/scripts/usage_example.py index 9bc135a..c3c2abb 100644 --- a/scripts/usage_example.py +++ b/scripts/usage_example.py @@ -54,8 +54,8 @@ def example3_temperature_extraction(): # 读取图像 gray_img = cv2.imread(SAMPLE_IMAGE, cv2.IMREAD_GRAYSCALE) - # 检测目标 - detections = detector.detect(SAMPLE_IMAGE) + # 检测目标(复用已加载的图像) + detections = detector.detect(gray_img) # 提取第一个检测框的温度特征 if detections: diff --git a/src/detect.py b/src/detect.py index 0b6e403..0458de2 100644 --- a/src/detect.py +++ b/src/detect.py @@ -92,7 +92,7 @@ class InfraredDetector: else: img = image.copy() - detections = self.detect(image, conf) + detections = self.detect(img, conf) for det in detections: x1, y1, x2, y2 = map(int, det['bbox'])