How can I replace my calls to cvGetReal2D with cvmGet ?

asked 2013-02-05 16:05:56 -0500

emptypixel gravatar image

updated 2013-02-05 16:20:45 -0500

How can I replace my calls to cvGetReal2D with cvmGet ?

I have functions like

bool someFunction(CvPoint2D32f location, IplImage &image)
{
  // code
  z = cvGetReal2D(image, location.y, location.x);
  // code
}

I am trying to replace cvGetReal2D with cvmGet because I read that it is faster - but I am a very beginner in OpenCV (I am modifying code written by other people).

Will I have to create an entire CvMat every time, for every single point ? In that case, since I can't change the fact that I am passing an IplImage... the change will make the code slower, right ?

CvMat* imageCopy = cvCreateMat(image.width, image.height, image.depth);

(I have seen also constants like CV_32FC1 - but I don't know how to choose)

Then, do I copy it ?

cvCopy(image, imageCopy);    // I hope this would copy the values

Will it work on multi-channel matrix ? Do I have to ask how many channels, and iterate on them ?

edit retag flag offensive close merge delete