how to convert from cv::Mat to CvArr?

后端 未结 5 1309
遇见更好的自我
遇见更好的自我 2021-01-18 07:35

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.

相关标签:
5条回答
  • 2021-01-18 07:39

    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

    0 讨论(0)
  • 2021-01-18 07:44

    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.

    0 讨论(0)
  • 2021-01-18 07:47
    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.

    0 讨论(0)
  • 2021-01-18 07:49

    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

    0 讨论(0)
  • 2021-01-18 07:58

    When I need to do that I just use :

    IplImage tmp = image;
    

    With image a Mat variable.

    0 讨论(0)
提交回复
热议问题