This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
forked from facebookresearch/maskrcnn-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add helper function 'cv2_utils.findContours' to maintain version comp…
…atibility (facebookresearch#354) fixes facebookresearch#339
- Loading branch information
1 parent
eb3b079
commit e140067
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Module for cv2 utility functions and maintaining version compatibility | ||
between 3.x and 4.x | ||
""" | ||
import cv2 | ||
|
||
|
||
def findContours(*args, **kwargs): | ||
""" | ||
Wraps cv2.findContours to maintain compatiblity between versions | ||
3 and 4 | ||
Returns: | ||
contours, hierarchy | ||
""" | ||
if cv2.__version__.startswith('4'): | ||
contours, hierarchy = cv2.findContours(*args, **kwargs) | ||
elif cv2.__version__.startswith('3'): | ||
_, contours, hierarchy = cv2.findContours(*args, **kwargs) | ||
else: | ||
raise AssertionError( | ||
'cv2 must be either version 3 or 4 to call this method') | ||
|
||
return contours, hierarchy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters