Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 5b44b78

Browse files
committed
[REF]: Remove old opencv api compatability
1 parent ea83589 commit 5b44b78

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

camelot/image_processing.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,9 @@ def find_contours(vertical, horizontal):
219219
"""
220220
mask = vertical + horizontal
221221

222-
try:
223-
__, contours, __ = cv2.findContours(
224-
mask.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
225-
)
226-
except ValueError:
227-
# for opencv backward compatibility
228-
contours, __ = cv2.findContours(
229-
mask.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
230-
)
222+
contours, __ = cv2.findContours(
223+
mask.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
224+
)
231225
# sort in reverse based on contour area and use first 10 contours
232226
contours = sorted(contours, key=cv2.contourArea, reverse=True)[:10]
233227

@@ -267,15 +261,9 @@ def find_joints(contours, vertical, horizontal):
267261
for c in contours:
268262
x, y, w, h = c
269263
roi = joints[y : y + h, x : x + w]
270-
try:
271-
__, jc, __ = cv2.findContours(
272-
roi.astype(np.uint8), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE
273-
)
274-
except ValueError:
275-
# for opencv backward compatibility
276-
jc, __ = cv2.findContours(
277-
roi.astype(np.uint8), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE
278-
)
264+
jc, __ = cv2.findContours(
265+
roi.astype(np.uint8), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE
266+
)
279267
if len(jc) <= 4: # remove contours with less than 4 joints
280268
continue
281269
joint_coords = []

0 commit comments

Comments
 (0)