ronitsinha/speed-detector

error in cv2.findContours

Closed this issue · 3 comments

after little change:

speed-detector> diff mainRU.py main.py 
52,53c52
<       #cap = cv2.VideoCapture ('../08.00.mp4')
<       cap = cv2.VideoCapture (0)
---
>       cap = cv2.VideoCapture (BASE_URL + 'playlist.m3u8')

/speed-detector> python3 mainRU.py
Traceback (most recent call last):
File "mainRU.py", line 76, in
_, contours, hierarchy = cv2.findContours(dilation, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

Same here.

in
, contours, hierarchy = cv2.findContours(dilation, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
Just remove that '
' in the beginning

after little change:

speed-detector> diff mainRU.py main.py 
52,53c52
<       #cap = cv2.VideoCapture ('../08.00.mp4')
<       cap = cv2.VideoCapture (0)
---
>       cap = cv2.VideoCapture (BASE_URL + 'playlist.m3u8')

/speed-detector> python3 mainRU.py
Traceback (most recent call last):
File "mainRU.py", line 76, in
_, contours, hierarchy = cv2.findContours(dilation, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

Yes, opencv has changed findContours so that it now only outputs two values. For example:
contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)