So this is my code:
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()
After running the above code, this error was shown:
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)
I think the problem is on the value of contours but I can't fix it, please help me