(cnts)
| 152 | return edged |
| 153 | |
| 154 | def grab_contours(cnts): |
| 155 | # if the length the contours tuple returned by cv2.findContours |
| 156 | # is '2' then we are using either OpenCV v2.4, v4-beta, or |
| 157 | # v4-official |
| 158 | if len(cnts) == 2: |
| 159 | cnts = cnts[0] |
| 160 | |
| 161 | # if the length of the contours tuple is '3' then we are using |
| 162 | # either OpenCV v3, v4-pre, or v4-alpha |
| 163 | elif len(cnts) == 3: |
| 164 | cnts = cnts[1] |
| 165 | |
| 166 | # otherwise OpenCV has changed their cv2.findContours return |
| 167 | # signature yet again and I have no idea WTH is going on |
| 168 | else: |
| 169 | raise Exception(("Contours tuple must have length 2 or 3, " |
| 170 | "otherwise OpenCV changed their cv2.findContours return " |
| 171 | "signature yet again. Refer to OpenCV's documentation " |
| 172 | "in that case")) |
| 173 | |
| 174 | # return the actual contours array |
| 175 | return cnts |
| 176 | |
| 177 | def is_cv2(or_better=False): |
| 178 | # grab the OpenCV major version number |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…