Skip to content

Bug in SelectiveSearchSegmentation #705

@mixmixmix

Description

@mixmixmix

Hello:

On some images (not particularly small or big) selective segmentation algorithm crashes on any strategy (switchToSelectiveSearchFast(),switchToSingleStrategy(), switchToSelectiveSearchQuality()) with

OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/mix/tmp/opencv/modules/core/src/matrix.cpp, line 516
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/mix/tmp/opencv/modules/core/src/matrix.cpp:516: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat


Program received signal SIGABRT, Aborted.

It is on the line 569:

#10 0x00007ffff2be2536 in cv::ximgproc::segmentation::SelectiveSearchSegmentationStrategyTextureImpl::setImage (this=0x868800, img_=..., regions_=..., 
    sizes_=..., image_id=0) at /home/mix/tmp/opencv_contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp:569
569                         tmp_gradiant = tmp_rot(Rect((bbox.width - img.cols) / 2, (bbox.height - img.rows) / 2, img.cols, img.rows));
(gdb) p bbox
$8 = {x = 12, y = -106, width = 319, height = 320}
(gdb) p img
$9 = {flags = 1124024336, dims = 2, rows = 107, cols = 342, 

Relevant backtrace:

#7  0x00007fffee2eb89d in cv::error (_code=-215, _err=..., _func=0x7fffeea94750 <cv::Mat::Mat(cv::Mat const&, cv::Rect_<int> const&)::__func__> "Mat", 
    _file=0x7fffeea92b10 "/home/mix/tmp/opencv/modules/core/src/matrix.cpp", _line=516) at /home/mix/tmp/opencv/modules/core/src/system.cpp:658
#8  0x00007fffee33d87c in cv::Mat::Mat (this=0x7fffffffcd60, m=..., roi=...) at /home/mix/tmp/opencv/modules/core/src/matrix.cpp:516
#9  0x00000000004105f4 in cv::Mat::operator() (this=0x7fffffffc4d0, roi=...) at /opt/opencv-3.1.0-dbg/include/opencv2/core/mat.inl.hpp:702
#10 0x00007ffff2be2536 in cv::ximgproc::segmentation::SelectiveSearchSegmentationStrategyTextureImpl::setImage (this=0x868800, img_=..., regions_=..., 
    sizes_=..., image_id=0) at /home/mix/tmp/opencv_contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp:569
#11 0x00007ffff2be0431 in cv::ximgproc::segmentation::SelectiveSearchSegmentationStrategyMultipleImpl::setImage (this=0x86a230, img_=..., regions_=..., 
    sizes_=..., image_id=0) at /home/mix/tmp/opencv_contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp:288
#12 0x00007ffff2be68b5 in cv::ximgproc::segmentation::SelectiveSearchSegmentationImpl::hierarchicalGrouping (this=0x6fb920, img=..., s=..., img_regions=..., 
    is_neighbour=..., sizes_=..., nb_segs=@0x7fffffffda4c: 41, bounding_rects=std::vector of length 41, capacity 41 = {...}, 
    regions=std::vector of length 0, capacity 0, image_id=0) at /home/mix/tmp/opencv_contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp:986
#13 0x00007ffff2be634f in cv::ximgproc::segmentation::SelectiveSearchSegmentationImpl::process (this=0x6fb920, rects=std::vector of length 0, capacity 4096)
    at /home/mix/tmp/opencv_contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp:950
#14 0x000000000040f8db in main (argc=7, argv=0x7fffffffe858) at /home/mix/repositories/prepimgs/source/main.cpp:105

Clearly we try to create a Matrix with negative size. I'm using code copied from selectivesearchsegmentation_demo.cpp.
Best,
M

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions