-1

I have a ValueError in python OpenCV at Google Colaboratory: not enough values to unpack (expected 3, got 2). In addition, I'm making some program that detects the contours of the water and gives coordinates. How I can fix this problem as soon as possible?

import cv2
import numpy as np
from google.colab import drive

drive.mount('/content/drive')
img = cv2.imread('/content/drive/MyDrive/lake1.jpg')

imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

ret, imthres = cv2.threshold(imgray, 127, 255, cv2.THRESH_BINARY_INV)

im2, contour, hierarchy = cv2.findContours(imthres, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) # here's the ValueError.
htl1111
  • 3
  • 1
  • 1
    Does this answer your question? [too many values to unpack calling cv2.findContours](https://stackoverflow.com/questions/43960257/too-many-values-to-unpack-calling-cv2-findcontours) – beaker Aug 01 '21 at 14:26

1 Answers1

0

As you can see here findContours only returns the contours and the hierarchy, but not the image itself, as in

contour, hierarchy = cv2.findContours(imthres, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

That's what this error message means.

Dreana
  • 573
  • 4
  • 16