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
I tried - I get an exception...
Will it work on multi-channel matrix ? Do I have to ask how many channels, and iterate on them ?
convert the IplImage to Mat using:
Then you can use
cvmGetCV_32FC1can be chosen like :I hope you are using OpenCV 2.4x
include these to use cv::Mat
to use cvarrtoMat: