xingyizhou / ExtremeNet

Bottom-up Object Detection by Grouping Extreme and Center Points
BSD 3-Clause "New" or "Revised" License
1.03k stars 172 forks source link

Use `cv2.findContours` in different OpenCV versions #22

Closed ausk closed 5 years ago

ausk commented 5 years ago

The OpenCV changes cv2.findContours in different versions. In OpenCV 3:

findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy

In OpenCV 4:

findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy

To make the code work in all versions, we can just write like this:

contours = cv2.findContours(...)[-2]
xingyizhou commented 5 years ago

Thanks!