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

Value Error: not enough values to unpack #4

Open
maxhallhatesm3 opened this issue Sep 20, 2019 · 3 comments
Open

Value Error: not enough values to unpack #4

maxhallhatesm3 opened this issue Sep 20, 2019 · 3 comments

Comments

@maxhallhatesm3
Copy link

Python 3 / OSX

$ python3 unproject_text/unproject_text.py samples/hd/IMG_1234.jpg
Traceback (most recent call last):
File "unproject_text/unproject_text.py", line 503, in
main()
File "unproject_text/unproject_text.py", line 490, in main
contours, hierarchy = get_contours(img)
File "unproject_text/unproject_text.py", line 135, in get_contours
cv2.CHAIN_APPROX_NONE)
ValueError: not enough values to unpack (expected 3, got 2)

@reddytocode
Copy link

reddytocode commented Sep 20, 2019

in the 135 line
change this
_, contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
to this

contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

it's because in a previous version of opencv that function used to return 3 values, now it returns just 2 values

@shenxiancf12
Copy link

in the 135 line change this _, contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) to this

contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

it's because in a previous version of opencv that function used to return 3 values, now it returns just 2 values

Still error as:
Traceback (most recent call last):
File "unproject_text.py", line 503, in
main()
File "unproject_text.py", line 495, in main
SRH = skew_detect(img, contours, RH)
File "unproject_text.py", line 467, in skew_detect
res = scipy.optimize.minimize_scalar(f, (-2.0, 0.0, 2.0))
File "\lib\site-packages\scipy\optimize_minimize.py", line 908, in minimize_scalar
return _minimize_scalar_brent(fun, bracket, args, **options)
File "\lib\site-packages\scipy\optimize_optimize.py", line 2606, in _minimize_scalar_brent
brent.optimize()
File "\lib\site-packages\scipy\optimize_optimize.py", line 2377, in optimize
xa, xb, xc, fa, fb, fc, funcalls = self.get_bracket_info()
File "\lib\site-packages\scipy\optimize_optimize.py", line 2361, in get_bracket_info
raise ValueError(
ValueError: Bracketing values (xa, xb, xc) do not fulfill this requirement: (f(xb) < f(xa)) and (f(xb) < f(xc))

It seems a little old project. Does this problem issue from the newest version of requiements (cv2 numpy scipy matplotlib) ?

@shenxiancf12
Copy link

in the 135 line change this _, contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) to this
contours, hierarchy = cv2.findContours(work, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
it's because in a previous version of opencv that function used to return 3 values, now it returns just 2 values

Still error as: Traceback (most recent call last): File "unproject_text.py", line 503, in main() File "unproject_text.py", line 495, in main SRH = skew_detect(img, contours, RH) File "unproject_text.py", line 467, in skew_detect res = scipy.optimize.minimize_scalar(f, (-2.0, 0.0, 2.0)) File "\lib\site-packages\scipy\optimize_minimize.py", line 908, in minimize_scalar return _minimize_scalar_brent(fun, bracket, args, **options) File "\lib\site-packages\scipy\optimize_optimize.py", line 2606, in _minimize_scalar_brent brent.optimize() File "\lib\site-packages\scipy\optimize_optimize.py", line 2377, in optimize xa, xb, xc, fa, fb, fc, funcalls = self.get_bracket_info() File "\lib\site-packages\scipy\optimize_optimize.py", line 2361, in get_bracket_info raise ValueError( ValueError: Bracketing values (xa, xb, xc) do not fulfill this requirement: (f(xb) < f(xa)) and (f(xb) < f(xc))

It seems a little old project. Does this problem issue from the newest version of requiements (cv2 numpy scipy matplotlib) ?

Ok, I find the original code only works on deskew0.jpg. What should I need to do for apply this project on my own picture.

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

3 participants