i have passed a lot of time searching on how to convert from cv::Mat or CvMat to CvArr but with no gain ,please help me in that,thanks.
If I recall correctly, CvMat IS a CvArr so you can just cast it into a CvArr, and the first bytes of the now CvArr tell the function that it is actually a CvMat: http://opencv.willowgarage.com/documentation/basic_structures.html#cvarr
Are you sure you want to convert it? sometimes there is equivalent function that use what you have. For example cvMorphologyEx
is using CvArr
but morphologyEx
is using cv::Mat
.
Mat img = imread("C:\MyPic.jpg",CV_LOAD_IMAGE_GRAYSCALE);
IplImage tmp=img;
cvErode(&tmp, &tmp, 0, 2);
Mat laser=&tmp;
imshow("Eroded",laser);
I converted cv::Mat
to CvArr
by this way. Instead of using tmp
directly use &tmp
.
convert first the image using the following:
IplImage* oldstyleimg = &matimg.operator IplImage()
I don t remember if it only create the header for the image or it makes a copy
When I need to do that I just use :
IplImage tmp = image;
With image a Mat variable.