fix: fix image duplicate loading in diagnose function
将cv2.imread从循环内移至循环前,避免对同一张图片重复加载
This commit is contained in:
+6
-6
@@ -50,16 +50,16 @@ class FaultDiagnoser:
|
|||||||
detections = self.detector.detect(image)
|
detections = self.detector.detect(image)
|
||||||
result['detections'] = detections
|
result['detections'] = detections
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
if isinstance(image, str):
|
||||||
|
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
|
||||||
|
else:
|
||||||
|
img = image
|
||||||
|
|
||||||
for det in detections:
|
for det in detections:
|
||||||
bbox = det['bbox']
|
bbox = det['bbox']
|
||||||
x1, y1, x2, y2 = map(int, bbox)
|
x1, y1, x2, y2 = map(int, bbox)
|
||||||
|
|
||||||
if isinstance(image, str):
|
|
||||||
import cv2
|
|
||||||
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
|
|
||||||
else:
|
|
||||||
img = image
|
|
||||||
|
|
||||||
roi = img[y1:y2, x1:x2]
|
roi = img[y1:y2, x1:x2]
|
||||||
temp_features = self.extractor.extract_from_roi(roi)
|
temp_features = self.extractor.extract_from_roi(roi)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user