Ask Your Question

Revision history [back]

How can I replace my calls to cvGetReal2D with cvmGet ?

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.rows, image.cols, 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 ?

How can I replace my calls to cvGetReal2D with cvmGet ?

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.rows, image.cols, 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 ?