阅读背景:

如何在OpenCV中找到最大矩形的坐标?

来源:互联网 

I have the following code:

我有以下代码:

    findContours( src, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE );

    Mat drawing = Mat::zeros( src.size(), CV_8UC3 );

    double largest_area = 0;

    for( int i = 0; i < contours.size(); i++) {  // get the largest contour
        area = fabs( contourArea( contours[i] ) );
        if( area >= largest_area ){
            largest_area = area;
            largest_contours.clear(); 
            largest_contours.push_back( contours[i] );
        }
    }

    if( largest_area >= 3000 ){   // draw the largest contour if exceeded minimum largest area 
        drawContours( drawing, largest_contours, -1, Scalar(0,0,255), 2 );
    }
    find



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: