(_,contours,hierarchy)=cv2.findContours(yellow, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
The code here throws an error saying that I am missing the third value but it already has three values
yellow = 1.
cv2.RETR_TREE = 2.
cv2.CHAIN_APROX_SIMPLE = 3.
and I don't know what to do.
I define yellow as
yellow = cv2.inRange(hsv, yellow_lower, yellow_upper)
and both yellow_lower and yellow_upper are defined...
Can anybody help? Thanks in advance
答案 0 :(得分:0)
您相信将返回三个值(第一个值将被丢弃):
_, contours, hierarchy = cv2.findContours(yellow, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
诊断告诉您只有两个返回。 因此,接受它们两者:
contours, hierarchy = cv2.findContours(yellow, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
您似乎正在使用主版本号为2的downrev cv2库。 在3.x版本中,签名被更改为将图像作为第三个返回值。