no matching function for call to 'drawContours' [closed]

asked 2018-05-14 04:23:03 -0600

Nimya gravatar image

updated 2020-02-27 21:20:09 -0600

supra56 gravatar image

Hi, i am a newbie in OpenCV world. My code snippet is shown below.

Mat CWaterFill::ContourFilter(Mat Img, int minSize)
{
    int maxValue = 255;
    CvMemStorage* m_storage;
    m_storage = cvCreateMemStorage(0);

    int m_region_count = 0;
    CvSeq *m_first_seq = NULL;
    CvSeq *m_prev_seq = NULL;
    CvSeq *m_seq = NULL;

    Mat ppp = Img;
    cvMorphologyEx(ppp, ppp, 0, 0, CV_MOP_OPEN, 1);
    cvMorphologyEx(ppp, ppp, 0, 0, CV_MOP_CLOSE, 1);

    cvClearMemStorage(m_storage);
    findContours(ppp, m_storage, &m_first_seq, sizeof(CvContour), CV_RETR_LIST);

    for (m_seq = m_first_seq; m_seq; m_seq = m_seq->h_next)
    {
        CvContour* cnt = (CvContour*)m_seq;
        if (cnt->rect.width * cnt->rect.height < minSize)
        {
            //delete small contour
            m_prev_seq = m_seq->h_prev;
            if (m_prev_seq)
            {
                m_prev_seq->h_next = m_seq->h_next;
                if (m_seq->h_next) m_seq->h_next->h_prev = m_prev_seq;
            }
            else
            {
                m_first_seq = m_seq->h_next;
                if (m_seq->h_next) m_seq->h_next->h_prev = NULL;
            }
        }

        else
        {
            m_region_count++;
        }
    }
    cvZero(ppp);
    drawContours(ppp, m_first_seq, CV_RGB(0, 0, maxValue), CV_RGB(0, 0, maxValue), 10, -1);

    Mat ipl = ppp;
    cv::Mat ppp1 = ipl;

    cvReleaseMemStorage(&m_storage);
    return ppp1;
}

When I run the code the following error shows :

14:44:39 * Incremental Build of configuration Release for project DisplayImage * make all Building file: ../Main.cpp Invoking: GCC C++ Compiler g++ -I/usr/local/Cellar/opencv/3.4.1_4/include -O3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"Main.d" -MT"Main.o" -o "Main.o" "../Main.cpp"

In file included from ../Main.cpp:2: ../WaterFill.h:11:13: warning: extra tokens at end of #pragma once directive [-Wextra-tokens] #pragma once; ^ //

../Main.cpp:50:2: error: no matching function for call to 'findContours' findContours(pp, m_storage, &m_first_seq, sizeof(CvContour), CV_RETR_LIST); ^~~~~~~~~~~~

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/imgproc.hpp:3899:19: note: candidate function not viable: no known conversion from 'CvMemStorage *' to 'const cv::_OutputArray' for 2nd argument

CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours, ^

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/imgproc.hpp:3904:17: note: candidate function not viable: no known conversion from 'CvMemStorage *' to 'const cv::_OutputArray' for 2nd argument

CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours, ^

../Main.cpp:90:2: error: no matching function for call to 'findContours' findContours(pp, m_storage, &m_first_seq, sizeof(CvContour), CV_RETR_LIST); ^~~~~~~~~~~~

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/imgproc.hpp:3899:19: note: candidate function not viable: no known conversion from 'CvMemStorage *' to 'const cv::_OutputArray' for 2nd argument

CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours, ^

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/imgproc.hpp:3904:17: note: candidate function not viable: no known conversion from 'CvMemStorage *' to 'const cv::_OutputArray' for 2nd argument

CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours, ^ ../Main.cpp:91:31: error: no viable conversion from 'cv::Mat' to 'const CvArr *' (aka 'const void *')

    cv::Mat mpp = cv::cvarrToMat(pp);

                                 ^~

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/core/mat.hpp:1629:28: note: candidate template ignored: could not match 'vector<type-parameter-0-0, allocator<type-parameter-0-0=""> >' against 'const void *' template<typename _tp=""> operator std::vector<_Tp>() const;

                       ^

/usr/local/Cellar/opencv/3.4.1_4/include/opencv2/core/mat.hpp:1630:35: note: candidate template ignored: could not match 'Vec<type-parameter-0-0, cn="">' against 'const void *' template<typename _tp,="" int="" n=""> operator Vec<_Tp, n>() const; ^

/usr/local/Cellar/opencv ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by berak
close date 2018-05-14 05:53:28.503685

Comments

1

Your code is obsolete : you are using opencv 3.4.1 with a source code compatible with opencv 2.x and x<7 ?

What do you want to do ?

PS i deleted duplicate post.

LBerger gravatar imageLBerger ( 2018-05-14 04:38:48 -0600 )edit
1

@Nimya -- please do not try with old opencv1.0 c-api code.

please have a look at current tutorials , and use c++

berak gravatar imageberak ( 2018-05-14 05:56:25 -0600 )edit
1

Thank You sir, I have gone through it

Nimya gravatar imageNimya ( 2018-05-15 04:37:22 -0600 )edit