Search code examples
imageopencviplimage

Error converting IplImage** to IplImage*


IplImage *img;
img = (IplImage **)malloc(IMAGE_NUM * sizeof(IplImage *));

for(index=0; index<IMAGE_NUM; index++){
    sprintf(filename, "preproc/preproc%d.jpg", index);
    img = cvLoadImage(filename, 0);
}

Hi! This piece of code here produces the error: cannot convert ‘IplImage** {aka _IplImage*}’ to ‘IplImage {aka _IplImage*}’ in assignment. I am trying to load multiple images here. What am I doing wrong? Thanks!


Solution

  • You declare 'img' to be a pointer to IplImage and then you're trying to convert it into pointer to a pointer. (IplImage**) - This typecast is incorrect for this particular case since you're trying to assign IplImage** to a IplImage*.

    Declare img to be : IplImage **img;