Ask Your Question

Revision history [back]

pyramid_segmentation.py crashes with any different input image

I want to get pyramid_segmentation.py working - essentially because it has such a cool name. It works on the fruit image shipped with python-opencv (2.1.0-7). But when I stitch in the name of a PNG file, on both Ubuntu and Win7 I get this merriment:

 $ python pyramid_segmentation.py 
 OpenCV Error: Assertion failed ((icvPyrSegmentation8uC3R( src_data, src_step, dst_data, dst_step,  src_size, CV_GAUSSIAN_5x5, comp, storage, level, thresh1, thresh2 )) >= 0) in cvPyrSegmentation,  file /build/buildd/opencv-2.1.0/src/cv/cvpyrsegmentation.cpp, line 1872
 Traceback (most recent call last):
  File "pyramid_segmentation.py", line 41, in <module>
    PyrSegmentation(img0).run()
  File "pyramid_segmentation.py", line 34, in run
    self.on_segment()
  File "pyramid_segmentation.py", line 30, in on_segment
    self.level, self.thresh1+1, self.thresh2+1)
 cv.error: (icvPyrSegmentation8uC3R( src_data, src_step, dst_data, dst_step, src_size,  CV_GAUSSIAN_5x5, comp, storage, level, thresh1, thresh2 )) >= 0

Anyone know how to fix that?