FindContour does not get all contour

asked 2018-06-08 09:20:05 -0500

garbalawal gravatar image

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/ELmszUKALYv... this my result : https://photos.app.goo.gl/q4Sbu2Nt0gu...

Thanks for your help

edit retag flag offensive close merge delete

Comments

hi, can you try again to upload your images here, not to an external site ?

berak gravatar imageberak ( 2018-06-08 09:25:33 -0500 )edit

Are you sure that contours are not founded? You got so many contours that there is some aliasing effect in outputmat

LBerger gravatar imageLBerger ( 2018-06-08 14:02:41 -0500 )edit

@berak the image is to big for the site. i already tried. @LBerger, do you try the code in your installation? does it work?

garbalawal gravatar imagegarbalawal ( 2018-06-08 15:22:48 -0500 )edit

I didn't try your code. I tried my code with your imge

LBerger gravatar imageLBerger ( 2018-06-08 15:34:42 -0500 )edit

@LBerger do you get all contour? how did you do?

garbalawal gravatar imagegarbalawal ( 2018-06-08 15:59:05 -0500 )edit