cv2.findContours error: (-215) step[dims-1] == (size_t)CV_ELEM_SIZE(flags) in function cv::Mat::create

asked 2015-10-03 06:59:57 -0600

gokulRaja gravatar image

updated 2015-10-03 07:02:41 -0600

i tried to find contours for image it make error

i using python 2.7 openCV 2.4.7,2.4.11

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

please help me .. thank you opencv users

edit retag flag offensive close merge delete

Comments

wait, contours,hierarchy,thresh = cv2.findContours(...) is for opencv3 ! for 2.4.x, use: contours,hierarchy = cv2.findContours()

http://docs.opencv.org/modules/imgpro...

berak gravatar imageberak ( 2015-10-03 07:07:12 -0600 )edit

i tried with other examples error continued

gokulRaja gravatar imagegokulRaja ( 2015-10-03 07:42:52 -0600 )edit

Couldn't be the problem in that img is empty because imread failed?

LorenaGdL gravatar imageLorenaGdL ( 2015-10-03 13:45:03 -0600 )edit