DHEIVER commited on
Commit
3810c3c
·
1 Parent(s): 3ddee97

Update obstruction_detector.py

Browse files
Files changed (1) hide show
  1. obstruction_detector.py +5 -4
obstruction_detector.py CHANGED
@@ -1,6 +1,7 @@
1
  import cv2 as cv
2
  import numpy as np
3
  from scipy.signal import find_peaks
 
4
 
5
  class ObstructionDetector:
6
  def __init__(self, threshold=500):
@@ -33,9 +34,9 @@ class ObstructionDetector:
33
  peaks, _ = find_peaks(smoothed_histogram.flatten(), height=self.threshold)
34
  return peaks
35
 
36
- def detect_obstruction(self, img_path):
37
- # Load the image
38
- img = cv.imread(img_path)
39
 
40
  # Preprocess the image
41
  preprocessed_img = self.preprocess_image(img)
@@ -51,4 +52,4 @@ class ObstructionDetector:
51
  else:
52
  report = "A imagem contém obstrução significativa | possui múltiplas distribuições de densidade claramente distintas."
53
 
54
- return report
 
1
  import cv2 as cv
2
  import numpy as np
3
  from scipy.signal import find_peaks
4
+ from PIL import Image # Import PIL
5
 
6
  class ObstructionDetector:
7
  def __init__(self, threshold=500):
 
34
  peaks, _ = find_peaks(smoothed_histogram.flatten(), height=self.threshold)
35
  return peaks
36
 
37
+ def detect_obstruction(self, pil_image): # Accept PIL image directly
38
+ # Convert PIL image to NumPy array
39
+ img = np.array(pil_image)
40
 
41
  # Preprocess the image
42
  preprocessed_img = self.preprocess_image(img)
 
52
  else:
53
  report = "A imagem contém obstrução significativa | possui múltiplas distribuições de densidade claramente distintas."
54
 
55
+ return report