由于代码太长,附上部分代码,问题是函数执行完返回就出现异常
//主程序代码
int k = 2;
int attempts = 3;
vector<Point2d> initializeClusterCenter(k);
vector<vector<Point>> fittingPointSet(k);
vector<vector<Point>> divisionPointSet;
divisionPointSet = pMinAreaRect(srcImg, points, showImg);
initializeClusterCenter = meanValueClassify(divisionPointSet, k);
fittingPointSet = MaxMinDisFun(points, initializeClusterCenter, attempts, k);
//函数代码
vector<vector<Point>> MaxMinDisFun(vector<Point> points, vector<Point2d> initializeClusterCenter, int attempts, int clusterNum)
{
assert(attempts >= 0);
assert(clusterNum > 0);
vector<vector<Point>> cluster_pointSet(clusterNum);//聚类中心对应的点集
constexpr float epsilon = 1;
int dataNum = points.size(); //输入的样本数
vector<Point2d> mean_values(clusterNum);
vector<Point2d> former_clusterCenter(clusterNum);//上一步迭代的聚类中心
vector<Point2d> latter_clusterCenter(clusterNum);//当前的聚类中心
......