Ask Your Question
1

SLIC error

asked 2016-04-03 14:49:43 -0500

MrAI gravatar image

Enviorement: Win 8.1 Professional Visual Studio 2013 Professional 2013 Version 12.0.406929.00 Update 5 OpenCV: Opencv CUDA Contrib vc12 Debug Build 3.1.0

Error in: module: ximgproc -> Superpixels Ptr<superpixelslic> cv::ximgproc::createSuperpixelSLIC ( InputArray image, int algorithm = SLICO, int region_size = 10, float ruler = 10.0f )

image description

Description: I get this error every time, no matter what the input image type may be (png, jpg,..). Using imread with CV_LOAD_IMAGE_COLOR or CV_LOAD_IMAGE_GRAYSCALE, doesn't make a difference. I tried giving the function invalid parameters to see where does the error occur like setting the algorithm parameter to 300, and the assertion fails, as it should. Checked the Q&A here and looked for any error ticket on the github page to no prevail.

The suprising thing is, that the other 2 types of Superpixel segmentation algorithms, SEED and LSC, work just fine.

How could I resolve this error?

edit retag flag offensive close merge delete

Comments

Actually with that error we have only a single clue on what is going on. First guess, you are accessing a matrix/vector index that does not exist. How to avoid this?

  • Before processing an image, check if it is properly loaded by checking the .empty() property which should be false.
  • Make sure that dimensions of vectors and matrices cannot be exceeded by adding checks on the dimensions of your loops.

Could you try this first?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-04 03:25:14 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
4

answered 2016-04-04 03:48:49 -0500

berak gravatar image

updated 2016-04-04 04:15:01 -0500

^^ bug, i'd say.

#include <opencv2/opencv.hpp>
#include <opencv2/ximgproc.hpp>
using namespace cv;
using namespace cv::ximgproc;

int main(int argc, char **argv)
{
    Mat image = imread("im/lena.png"); //512x512
    Ptr<SuperpixelSLIC> slic = createSuperpixelSLIC(image, SLICO, 10, 10.0f) ;
    return 0;
}

breaks here , m_numlabels=2621, m_kseedsx.size()=2601

actually, it works, when choosing a larger region, like 12, but m_numlabels never matches the arraysizes there (either too long, -> crash, or too short -> leftovers)

edit flag offensive delete link more

Comments

1

Then a bug report should be posted right here ;)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-04 04:26:10 -0500 )edit
1

Thank you berak! I was hoping for a better outcome, but at least the culprint was found. Could you post the bug report? Since I couldn't compile OpenCV on my own, I can't really give as detailed of a description as you can.

MrAI gravatar imageMrAI ( 2016-04-04 06:04:23 -0500 )edit

sure, i'll post one, if you don#t want to, but ... how could you not compile opencv_contrib, and use SLIC ?, hehe..

berak gravatar imageberak ( 2016-04-04 06:29:32 -0500 )edit
2

Well after days of some next level wizardy, google smiled upon me and led me to the OpenCV NuGet package (linked in the original question), which has everything that OpenCV has to offer.

MrAI gravatar imageMrAI ( 2016-04-04 06:43:47 -0500 )edit
1

ah, i see. (that also explains, why you can't debug it)

berak gravatar imageberak ( 2016-04-04 07:24:52 -0500 )edit
1
berak gravatar imageberak ( 2016-04-06 03:22:16 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-04-03 14:49:43 -0500

Seen: 356 times

Last updated: Apr 04 '16