这是我的代码:
import cv2
import numpy as np
import imutils
import argparse
cap = cv2.VideoCapture(0)
while True :
_,frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_blue = np.array([150,104,90])
upper_blue = np.array ([176,161,157])
mask = cv2.inRange(hsv, lower_blue, upper_blue)
cv2.imshow ("frame", frame)
cv2.imshow("mask", mask)
_, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
cv2.drawContours(frame, contours)
key = cv2.waitKey(1)
if key ==27 :
break
cap.release()
cv2.destroyAllWindows()
运行上述代码后,显示此错误:
Traceback (most recent call last): File "D:/1Kuliah/Kegiatan Kuliah/Roboboat/ROBONATION JADI!!/kkctbn/coba.py", line 20, in _, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
ValueError: not enough values to unpack (expected 3, got 2)
我想问题出在等高线的值上,但我无法解决,请帮助我
您可以修改调用
cv2.findContours
的行:相关问题 更多 >
编程相关推荐