Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FindContour does not get all contour

Hello,

I'm working on one project and i'm dealing with big image 12000X28000 width x Height. In my project, i need to find contour, like this i can do some calculation to add or remove feature. But in some way OpenCV does not find all contour in my image this is my code and i'm using open cv 3.4.1 on C++ :

  void ApplyDetectVertical(Mat & InputMat, Mat & OutputMat)
{
    std::vector<std::vector<cv::Point>> vecContours;
    cv::Mat outBin;
    cv::threshold(
            InputMat,
            outBin,
            0,
            255,
            cv::THRESH_BINARY | cv::THRESH_OTSU);
    OutputMat = cv::Mat(outBin.size(), outBin.type(), Scalar(0));
    // Find contour 
    cv::findContours(outBin, vecContours, cv::RETR_LIST, cv::CHAIN_APPROX_SIMPLE);
    int nContourCount = vecContours.size();
    cv::Scalar color = cv::Scalar(255, 255, 255);
    // Find contour of interest
    for (size_t i = 0; i < nContourCount; ++i) {
        cv::drawContours(OutputMat,
            vecContours, i++,
            color,
            cv::FILLED
        /*cv::LINE_4*/);
    }

    imshow ("result", OutputMat);
}

this is my test image : https://photos.app.goo.gl/ELmszUKALYvAE7rq1 this my result : https://photos.app.goo.gl/q4Sbu2Nt0guNsV1j1

Thanks for your help