0
我跳原始图像的像素创建一个新的Mat
,但我得到这个错误:opencv的 - 麻烦其他矩阵创建矩阵(malloc.c:2451:SYSMALLOC:断言)
PRM algorithm: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
我的代码是:
int width = round(img.cols/M);
int height = round(img.rows/M);
cv::Mat res(height, width, CV_8U);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
res.at<cv::Vec3b>(i, j)[0] = img.at<cv::Vec3b>(i * M, j * M)[0];
res.at<cv::Vec3b>(i, j)[1] = img.at<cv::Vec3b>(i * M, j * M)[1];
res.at<cv::Vec3b>(i, j)[2] = img.at<cv::Vec3b>(i * M, j * M)[2];
}
}
return res;
我也使用uchar* ptr = img.ptr<uchar>(i)
和ptr[j]
所以它可以直接访问数据试过,但我收到同样的错误。
我正在寻找,并尝试了一些“解决方案”,如sYSMALLOc: Assertion Failed error in opencv,但麻烦不断出现。
哦!谢谢,昨天我发现了第一个错误,但第二个错误......我觉得有点“愚蠢”,哈哈。再次感谢! – Bardo91