File size: 650 Bytes
749745d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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