Ask Your Question

Revision history [back]

Code from the tutorial doesn't work

import numpy as np import cv2

im = cv2.imread('test.jpg') imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(imgray,127,255,0) contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

When executing this code, I get an error: ValueError: too many values to unpack (expected 2) .

Is there a mistake in tutorial or am I doing something wrong?

click to hide/show revision 2
None

updated 2019-01-08 07:36:29 -0600

berak gravatar image

Code from the tutorial doesn't work

.

import numpy as np
import cv2

cv2

im = cv2.imread('test.jpg') imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(imgray,127,255,0) contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

When executing this code, I get an error: ValueError: too many values to unpack (expected 2) .

Is there a mistake in tutorial or am I doing something wrong? wrong?