dchaplinsky / unshred

Experiments on darpa shredder challenge tasks using python & opencv.
MIT License
39 stars 6 forks source link

test example won't work #16

Open psihonavt opened 9 years ago

psihonavt commented 9 years ago

As notes stated: Run it on test file: python split.py ../src/puzzle.tif

  1. There is no such file, I was trying with ../src/puzzle.tif:
Processing file ../src/puzzle_small.tif
OpenCV Error: Sizes of input arguments do not match (The lower bounary is neither an array of the same size and same type as src, nor a scalar) in inRange, file /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp, line 2527
Traceback (most recent call last):
  File "split.py", line 162, in <module>
    sheet.export_results_as_html()
  File "split.py", line 103, in export_results_as_html
    img_with_overlay = self.overlay_contours()
  File "split.py", line 92, in overlay_contours
    contours = map(lambda x: x.contour, self.get_shreds())
  File "split.py", line 135, in get_shreds
    return self.sheet.get_shreds(self.feature_extractors, self.sheet_name)
  File "/home/akoval/projects/unshred/unshred/sheet.py", line 93, in get_shreds
    contours, _ = cv2.findContours(self._foreground_mask,
  File "/home/akoval/projects/unshred/unshred/sheet.py", line 242, in _foreground_mask
    self._fg_mask = self._find_foreground_mask()
  File "/home/akoval/projects/unshred/unshred/sheet.py", line 211, in _find_foreground_mask
    mask = cv2.bitwise_or(mask, cv2.inRange(hsv, rng[0], rng[1]))
cv2.error: /build/buildd/opencv-2.4.2+dfsg/modules/core/src/arithm.cpp:2527: error: (-209) The lower bounary is neither an array of the same size and same type as src, nor a scalar in function inRange

So, problem in this guy cv2.inRange(hsv, rng[0], rng[1]). According to documentation src (hsv in our case) should be the same size as upper/lower boundaries (rng[0], rng[1]). But hsv is multidimensional array while ranges are not.

dchaplinsky commented 9 years ago

Works just fine on my local instance.

Can you post version of OpenCV lib here?

psihonavt commented 9 years ago
>>> import cv2
>>> cv2.__version__
'2.4.2'
dchaplinsky commented 9 years ago

2.4.9 is required. Try to update your version and let me know if this helped.

dchaplinsky commented 9 years ago

Updated README.md. Thanks for pointing it.