unproject_text icon indicating copy to clipboard operation
unproject_text copied to clipboard

"ValueError: Not a bracketing interval." on some images

Open liorazi opened this issue 6 years ago • 5 comments

Tried to run the program on some images, for some it worked, but on many I get this error:

python3 unproject_text.py lp8.png

abs_area_cutoff = 18.7572 got 6 contours with 1 small. got bounding rect -281 163 583 58 got bounding rect -305 186 586 12 got bounding rect 263 197 3 1 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 468, in skew_detect res = scipy.optimize.minimize_scalar(f, (-2.0, 0.0, 2.0)) File "/usr/local/lib/python3.6/site-packages/scipy/optimize/_minimize.py", line 653, in minimize_scalar return _minimize_scalar_brent(fun, bracket, args, **options) File "/usr/local/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 2108, in _minimize_scalar_brent brent.optimize() File "/usr/local/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 1892, in optimize xa, xb, xc, fa, fb, fc, funcalls = self.get_bracket_info() File "/usr/local/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 1880, in get_bracket_info raise ValueError("Not a bracketing interval.") ValueError: Not a bracketing interval.

The image I tried was: https://liorazi.github.io/lp8.png

liorazi avatar Oct 26 '18 20:10 liorazi

Reproduced, not sure if version incompatibility

python unproject_text.py dg-1.png abs_area_cutoff = 130.48 got 254 contours with 0 small. got bounding rect 453 731 12 1 got bounding rect 380 772 11 2 got bounding rect 382 772 4 1 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 468, in skew_detect res = scipy.optimize.minimize_scalar(f, (-2.0, 0.0, 2.0)) File "/usr/local/lib/python2.7/site-packages/scipy/optimize/_minimize.py", line 773, in minimize_scalar return _minimize_scalar_brent(fun, bracket, args, **options) File "/usr/local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 2108, in _minimize_scalar_brent brent.optimize() File "/usr/local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 1892, in optimize xa, xb, xc, fa, fb, fc, funcalls = self.get_bracket_info() File "/usr/local/lib/python2.7/site-packages/scipy/optimize/optimize.py", line 1880, in get_bracket_info raise ValueError("Not a bracketing interval.") ValueError: Not a bracketing interval.

krishna81m avatar Nov 14 '18 19:11 krishna81m

Anyone found any solution to this error. I am getting the same error.

saikat-sarkar avatar Mar 05 '19 09:03 saikat-sarkar

I got the same error. Has someone got any ideas?

root@ad9f76f47988:/var/www/deskew# python unproject_text.py deskew0.jpg
Traceback (most recent call last):
  File "unproject_text.py", line 503, in <module>
    main()
  File "unproject_text.py", line 490, in main
    contours, hierarchy = get_contours(img)
  File "unproject_text.py", line 135, in get_contours
    cv2.CHAIN_APPROX_NONE)
ValueError: need more than 2 values to unpack

IonutQo2 avatar Apr 21 '19 17:04 IonutQo2

I got the same error. Has someone got any ideas?

root@ad9f76f47988:/var/www/deskew# python unproject_text.py deskew0.jpg
Traceback (most recent call last):
  File "unproject_text.py", line 503, in <module>
    main()
  File "unproject_text.py", line 490, in main
    contours, hierarchy = get_contours(img)
  File "unproject_text.py", line 135, in get_contours
    cv2.CHAIN_APPROX_NONE)
ValueError: need more than 2 values to unpack

you can fix this by gng to line 134 and removing the _. plus this is not the same error as everybody else.

adithya-sama avatar Nov 16 '19 15:11 adithya-sama

Bracket value is an optional parameter for these optimizers. So you could remove the second parameter (-2.0, 0.0, 2.0) on line 468, and it will work. But I'm not sure how good the result would be without this bracket value, haven't tested it a lot yet.

dipanshunagar avatar Jun 17 '20 14:06 dipanshunagar