使用struct与OpenCV的minEnclosingCircle

时间:2013-02-25 10:54:01

标签: pointers opencv colors structure

我一直在用OpenCV开发一个项目,用于在图像中分割彩球,而我正在使用一种结构,以便更容易通过圆心和半径。但每当我使用OpenCV中的“minEnclosingCircle”函数时,它就会给我一个核心转储。我已经把它缩小到了故障的位置,我认为它有以下几点:

typedef struct DataCircleSt {
vector<Point2f> center;
vector<float> radius;
} *DataCircle;

Mat removeBall( Mat img, vector<vector<Point> > contours )
{
DataCircle dc;

dc = calcDataCircle(contours);

for ( int i = 0; i < contours.size(); i++ )
{
    /*
    if ( dc->radius[i] > THRESHOLD )                    
        circle(img, dc->center[i], dc->radius[i], Scalar::all(0), thickness, linetype);
    */  
}

return img;
    }

DataCircle calcDataCircle( vector<vector<Point> > contours )
{   
DataCircle dc;

vector<vector<Point> > contours_poly( contours.size() );
dc->center.reserve(contours.size());
dc->radius.reserve(contours.size());

for( int i = 0; i < contours.size(); i++ )
{ 
    approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
    // Deze functie neemt de output van approxpoly en geeft zelf als output de 
    // radius en middenpunt van de cirkels  
    minEnclosingCircle( (Mat)contours_poly[i], dc->center[i], dc->radius[i] );  
}

//cout << endl << dc->radius[0] << endl;

return dc;
}

我做错了什么?

提前致谢

0 个答案:

没有答案