Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvFindContours is faster than cv::findcontours

Hi, I'm using 2.4.8 opencv in a VS application and I have just updated source code changing old C functions with new C++ functions. In particular I have verified that cv::findcontours is slower than cvFindContours. Is it possible? Is this gap solved with newer versions?

regards Andrea

cvFindContours is faster than cv::findcontours

Hi, I'm using 2.4.8 opencv in a VS application and I have just updated source code changing old C functions with new C++ functions. In particular I have verified that cv::findcontours is slower than cvFindContours. Is it possible? Is this gap solved with newer versions?

regards Andrea

cvFindContours is faster than cv::findcontours

Hi, I'm using 2.4.8 2.4.13 opencv in a VS application and I have just updated source code changing old C functions with new C++ functions. In particular I have verified that cv::findcontours is slower than cvFindContours. cvFindContours.

For example I have tried with that code:

for( i=0; i<10000; i++ ) {
    cvThreshold(gray, tmp, 225, 255, CV_THRESH_BINARY);
    cvFindContours(tmp, storage, &contours, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

    cvInitTreeNodeIterator(&iterator, contours, 2);
    while( src_cc= (CvSeq*)cvNextTreeNode(&iterator) ) {
        for( approxParam=1.5; approxParam<=10.0; approxParam+=0.5 )
            dst_cc = cvApproxPoly(src_cc, sizeof(CvContour), temp_storage, CV_POLY_APPROX_DP, approxParam);
    }
}

vs

for( i=0; i<10000; i++ )
{
    cv::threshold(mat_gray, mat_tmp, 225, 255, CV_THRESH_BINARY);
    cv::findContours(mat_tmp, mat_contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

    for( ic=0; ic<mat_contours.size(); ic++ ) {
        for( approxParam=1.5; approxParam<=10.0; approxParam+=0.5 )
            cv::approxPolyDP(mat_contours[ic], dst_contour, approxParam, true);
    }
}

C++ source has a RELEASE execution time nearly 1 second greater than C source. Is it possible? Is this gap solved with newer versions?it only C++ overhead? I have used an opencv sample image (baboon.jpg) and C source needs thereabouts 4 seconds while C++ source 5 seconds

regards Andrea