Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"not enough values to unpack" #1

Open
chrisbuckleycode opened this issue Jun 6, 2020 · 1 comment
Open

"not enough values to unpack" #1

chrisbuckleycode opened this issue Jun 6, 2020 · 1 comment

Comments

@chrisbuckleycode
Copy link

chrisbuckleycode commented Jun 6, 2020

Does this work for current python3 and module versions?

I got the following output when running it. My mp4 is in 720p and the subtitles fall within the default box values:

Traceback (most recent call last):
File "./jyutping.py", line 167, in
main()
File "./jyutping.py", line 146, in main
text = extractor.extract(frame)
File "/home/user/python/add-jyutping-master/extract.py", line 47, in extract
self.cleaned = self.clean_image(img)
File "/home/user/python/add-jyutping-master/extract.py", line 112, in clean_image
return self.clean_after_crop(cropped)
File "/home/user/python/add-jyutping-master/extract.py", line 175, in clean_after_crop
img = super().clean_after_crop(cropped)
File "/home/user/python/add-jyutping-master/extract.py", line 145, in clean_after_crop
img = remove_small_islands(img)
File "/home/user/python/add-jyutping-master/extract.py", line 310, in remove_small_islands
im2, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

The file I used was downloaded from YouTube. You can try yourself using y2mate site, I tried multiple videos from the YouTube TVB News channel.

@910JQK
Copy link
Owner

910JQK commented Jun 18, 2020

This problem occurs because of an API change of OpenCV. The function findContours used to return 3 values but returns 2 values now (first value was removed). But it isn't a big problem because the removed first value is not used in the code.

You can try to change code such as

im2, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
_, contours, hierarchy = cv2.findContours(self.thresholded, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

into

contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours, hierarchy = cv2.findContours(self.thresholded, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants