问题
I tried to find contours for image, but it gives an error.
My code is:
import cv2
import numpy as np
img = cv2.imread('star.jpg',0)
ret,thresh = cv2.threshold(img,127,255,0)
contours,hierarchy = cv2.findContours(thresh, 1, 2)
error is:
Traceback (most recent call last): File "C:\Python27\OpenCVContore.py", line 5, in <module> contours,hierarchy,thresh = cv2.findContours(thresh, 1, 2) error: ........\opencv\modules\core\src\matrix.cpp:236: error: (-215) step[dims-1] == (size_t)CV_ELEM_SIZE(flags) in function cv::Mat::create
I am using Python 2.7
OpenCV 2.4.7,2.4.11
Any help is appreciated.
回答1:
Solved this problem by updating my python version to 3.4 and opencv version 3. But cannot find real solutions for this. Why python 2.x versions not fully support for openCV
来源:https://stackoverflow.com/questions/32922944/error-when-using-cv2-findcontours