I reinstall opencv today, and run my code I've written before. I got the error:
OpenCV Error: Assertion failed (_contours.empty() || (_contours.channels() == 2 && _contours.depth() == CV_32S)) in findContours, file /tmp/opencv-20170916-87764-1y5vj25/opencv-3.3.0/modules/imgproc/src/contours.cpp, line 1894 Traceback (most recent call last): File "pokedex.py", line 12, in (cnts, _) = cv2.findContours(gray, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE, (2,2)) cv2.error: /tmp/opencv-20170916-87764-1y5vj25/opencv-3.3.0/modules/imgproc/src/contours.cpp:1894: error: (-215) _contours.empty() || (_contours.channels() == 2 &&_contours.depth() == CV_32S) in function findContours
The code works fine with opencv2.4.13.3.
code:
image = cv2.imread("test.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) // `len(gray.shape)` is 2.
(cnts, _) = cv2.findContours(gray, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE, (2,2))