0

I saw this answer on superpixel segmentation here SLIC c++ segmentation

I want to know as to where can I find the new C++ api that was discussed there.

I actually got it from http://www.vlfeat.org/sandbox/download.html

This is my code:

#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
extern "C"{
#include<C:\\vlfeat\vl\slic.h>
#include"C:\\vlfeat\vl\slic.c"
}

using namespace cv;

int main()
{
    Mat img=imread("E:\\brush.jpg");
    Mat floatimg;
    img.convertTo(floatimg,CV_32FC3);
    Mat label(floatimg.size(),CV_32SC1);
    vl_slic_segment(label.ptr<vl_uint32>(),floatimg.ptr<float>(),floatimg.cols,floatimg.rows,floatimg.channels(),15,0.1,1);
    imshow("out", img);
    waitKey(0);
}

The problem I am currently facing is, that I get these errors:

Error   2   error C2440: '=' : cannot convert from 'void *' to 'float *'    c:\vlfeat\vl\slic.c 203
Error   3   error C2440: '=' : cannot convert from 'void *' to 'vl_uint32 *'    c:\vlfeat\vl\slic.c 204
Error   4   error C2440: '=' : cannot convert from 'void *' to 'float *'    c:\vlfeat\vl\slic.c 205
Error   8   error C2440: 'initializing' : cannot convert from 'void *' to 'vl_uint32 *' c:\vlfeat\vl\slic.c 341
Error   9   error C2440: 'initializing' : cannot convert from 'void *' to 'vl_uindex *' c:\vlfeat\vl\slic.c 342
11  IntelliSense: a value of type "void *" cannot be assigned to an entity of type "float *"    c:\vlfeat\vl\slic.c 203
12  IntelliSense: a value of type "void *" cannot be assigned to an entity of type "vl_uint32 *"    c:\vlfeat\vl\slic.c 204
13  IntelliSense: a value of type "void *" cannot be assigned to an entity of type "float *"    c:\vlfeat\vl\slic.c 205
14  IntelliSense: a value of type "void *" cannot be used to initialize an entity of type "vl_uint32 *" c:\vlfeat\vl\slic.c 341
15  IntelliSense: a value of type "void *" cannot be used to initialize an entity of type "vl_uindex *" c:\vlfeat\vl\slic.c 342
Community
  • 1
  • 1
Rakesh Ramesh
  • 53
  • 1
  • 8
  • If you're using vlfeat just for superpixels, you can probably use [OpenCV SEEDS superpixels](http://docs.opencv.org/3.0-beta/modules/ximgproc/doc/superpixels.html) – Miki Mar 17 '16 at 12:17
  • Check also [this](http://stackoverflow.com/questions/24403743/opencv-vlfeat-slic-function-call) – Miki Mar 17 '16 at 12:19
  • What is the header file under which it is present, can u explain it with a code? – Rakesh Ramesh Mar 17 '16 at 12:21
  • for an example on OpenCV SEEDS you can check [here](https://github.com/Itseez/opencv_contrib/blob/master/modules/ximgproc/samples/seeds.cpp) – Miki Mar 17 '16 at 12:22
  • oh... in OpenCV 3.1 there are also [superpixels ILSC and SLIC](http://docs.opencv.org/3.1.0/df/d6c/group__ximgproc__superpixel.html#gsc.tab=0) – Miki Mar 17 '16 at 12:27
  • Whenever I try to use ximgproc.h file it is giving me a "error LNK2019" error, I got to know that, this is caused because only the function definition is present in ximgproc.h but it is defined elsewhere. So now how do I solve this link problem? – Rakesh Ramesh Mar 18 '16 at 04:47
  • You need to recompile opencv with contrib modules – Miki Mar 18 '16 at 09:18
  • Thankyou so much for the help, segmentation using openCV finally worked. – Rakesh Ramesh Mar 20 '16 at 14:11

0 Answers0