Ask Your Question
0

Problem with c++ and cv::resize

asked May 11 '13

Franrupa gravatar image

updated Dec 21 '15

Hi! Forgive the question. I am new to c + + and using opencv. I have a problem. I have the following code, and I think it should work.

  using cv;
....

      int CImageProcessor::DoProcess(IplImage** image) {
            CvMat c1;
            CvMat & imag4=c1;
            if(!image || !*image) return(EINVALID_PARAMETER);
            img=*image;
            dst_mat = cvGetMat(img, &stub, 0, 0);
            resize(dst_mat,imag4,0,0.75,0.75,INTER_LINEAR); 
            return(SUCCESS);
        }

But it shows me the following error.

image_processing.cpp: In member function int CImageProcessor::DoProcess(IplImage**)’:
image_processing.cpp:30: error: invalid initialization of reference of type cv::Mat&’ from expression of type CvMat
../opencv-2.x.x/include/opencv/cv.hpp:320: error: in passing argument 2 of void cv::resize(const cv::Mat&, cv::Mat&, cv::Size, double, double, int)’

What is my problem? I'm sorry, I think it will be a silly, but I've been days trying to make it work, and I get nothing. thanks

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered May 11 '13

berak gravatar image

updated May 11 '13

please try not to mix the old 1.0 (iPlImage/CvMat) and the newer 2.0 Api(cv::Mat).

in this case, call:

CvMat *dst = cvCreateMat(rows, cols, type); // you need to alloc space for the result
cvResize( src, dst, CV_INTER_LINEAR );  // see, you had it in the wrong order, too!

(but hard for me to see, which is your input, and which is the output img in your code.)

Preview: (hide)

Question Tools

Stats

Asked: May 11 '13

Seen: 5,061 times

Last updated: May 11 '13