これがデバッグ情報です。
HEAP[opencv_CoTraining2.exe]: Heap block at 0AD15168 modified at 0AD15594 past requested size of 424
Windows has triggered a breakpoint in opencv_CoTraining2.exe.
This may be due to a corruption of the heap, which indicates a bug in opencv_CoTraining2.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while opencv_CoTraining2.exe has focus.
The output window may have more diagnostic information.
ここに私のコードがあります:
void GetKCent(Mat& mat)
{
double** tmp=(double**)calloc(mat.rows,sizeof(double*));
double f[128];
memset(f,0,sizeof(f));
double max=0;
for (int i=0;i<mat.rows;i++)
{
tmp[i]=(double*)calloc(mat.cols,sizeof(double));
for (int j=0;j<mat.cols;j++)
{
tmp[i][j]=mat.at<float>(i,j);
if (tmp[i][j]>max) max=tmp[i][j];
}
}
for (int i=0;i<mat.cols;i++) for (int j=0;j<mat.rows;j++) tmp[j][i]/=max;
k_means(tmp,mat.rows,128,K_CLUSTER,KMEANSDIS,kcent);
for (int i=0;i<K_CLUSTER;i++) for (int j=0;j<128;j++) kcent[i][j]*=max;
for (int i=0;i<mat.rows;i++)free(tmp[i]);
free(tmp);
}
この行で発生した障害は、
for (int i=0;i<mat.rows;i++)free(tmp[i]);
関数 k_means() は最初のパラメーターを変更しません。誰が私を助けることができます?
PS k_means() の定義は次のとおりです
int k_means(double **data, int n, int m, int k, double t, double **centroids)
これが _double** kcent_ です
kcent=(double**)calloc(K_CLUSTER,sizeof(double*));
for (int i=0;i<K_CLUSTER;i++) kcent[i]=(double*)calloc(128,sizeof(double));
この部分は正しいと思います。