Spaces:
Sleeping
Sleeping
Update analisador_iridologico.py
Browse files- analisador_iridologico.py +26 -16
analisador_iridologico.py
CHANGED
@@ -172,6 +172,7 @@ def detectar_iris_pupila(imagem, mask_esclera):
|
|
172 |
mask_olho = cv2.bitwise_not(mask_esclera)
|
173 |
eye_region = cv2.bitwise_and(gray, gray, mask=mask_olho)
|
174 |
edges = cv2.Canny(eye_region, 30, 60)
|
|
|
175 |
iris_circles = cv2.HoughCircles(
|
176 |
edges,
|
177 |
cv2.HOUGH_GRADIENT,
|
@@ -183,15 +184,23 @@ def detectar_iris_pupila(imagem, mask_esclera):
|
|
183 |
maxRadius=150
|
184 |
)
|
185 |
|
186 |
-
if iris_circles
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
)
|
196 |
|
197 |
pupil_circles = cv2.HoughCircles(
|
@@ -200,18 +209,19 @@ def detectar_iris_pupila(imagem, mask_esclera):
|
|
200 |
dp=1,
|
201 |
minDist=50,
|
202 |
param1=50,
|
203 |
-
param2=25,
|
204 |
minRadius=20,
|
205 |
maxRadius=50
|
206 |
)
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
return (ix, iy, ir), (px, py, pr)
|
212 |
-
|
213 |
-
return None, None
|
214 |
|
|
|
|
|
|
|
|
|
215 |
def analisar_textura_setorial(imagem, iris_info, pupil_info):
|
216 |
if iris_info is None or pupil_info is None:
|
217 |
return {}
|
|
|
172 |
mask_olho = cv2.bitwise_not(mask_esclera)
|
173 |
eye_region = cv2.bitwise_and(gray, gray, mask=mask_olho)
|
174 |
edges = cv2.Canny(eye_region, 30, 60)
|
175 |
+
|
176 |
iris_circles = cv2.HoughCircles(
|
177 |
edges,
|
178 |
cv2.HOUGH_GRADIENT,
|
|
|
184 |
maxRadius=150
|
185 |
)
|
186 |
|
187 |
+
if iris_circles is None:
|
188 |
+
print("Nenhum círculo de íris detectado.")
|
189 |
+
return None, None
|
190 |
+
|
191 |
+
iris_circles = np.uint16(np.around(iris_circles))
|
192 |
+
ix, iy, ir = iris_circles[0][0]
|
193 |
+
mask_iris = np.zeros_like(gray)
|
194 |
+
cv2.circle(mask_iris, (ix, iy), 255, -1)
|
195 |
+
iris_region = cv2.bitwise_and(gray, gray, mask=mask_iris)
|
196 |
+
|
197 |
+
thresh = cv2.adaptiveThreshold(
|
198 |
+
iris_region,
|
199 |
+
255,
|
200 |
+
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
|
201 |
+
cv2.THRESH_BINARY_INV,
|
202 |
+
11,
|
203 |
+
2
|
204 |
)
|
205 |
|
206 |
pupil_circles = cv2.HoughCircles(
|
|
|
209 |
dp=1,
|
210 |
minDist=50,
|
211 |
param1=50,
|
212 |
+
param2=25,
|
213 |
minRadius=20,
|
214 |
maxRadius=50
|
215 |
)
|
216 |
|
217 |
+
if pupil_circles is None:
|
218 |
+
print("Nenhum círculo de pupila detectado.")
|
219 |
+
return (ix, iy, ir), None
|
|
|
|
|
|
|
220 |
|
221 |
+
pupil_circles = np.uint16(np.around(pupil_circles))
|
222 |
+
px, py, pr = pupil_circles[0][0]
|
223 |
+
return (ix, iy, ir), (px, py, pr)
|
224 |
+
|
225 |
def analisar_textura_setorial(imagem, iris_info, pupil_info):
|
226 |
if iris_info is None or pupil_info is None:
|
227 |
return {}
|