1
訪問OpenCV中5D矩陣的元素時遇到問題。我創建一個使用我的矩陣OpenCV:訪問5D矩陣的元素
int sizes[5] = { height_, width_, range_, range_, range_ };
Mat w_i_ = Mat(2 + channels, sizes, CV_16UC(channels), Scalar(0));
這裏= 3。然後我試圖使用循環來訪問和修改矩陣元素渠道:
for (UINT Y = 0; Y < height; ++Y) {
for (UINT X = 0; X < width; ++X) {
// a) Compute the homogeneous vector (wi,w)
Vec3b wi = image.at<Vec3b>(Y, X);
// b) Compute the downsampled coordinates
UINT y = round(Y/sigmaSpatial);
UINT x = round(X/sigmaSpatial);
Vec3b zeta = round((image.at<Vec3b>(Y, X) - min)/sigmaRange);
// round() here is overloaded for vectors
// c) Update the downsampled S×R space
int idx[5] = { y, x, zeta[0], zeta[1], zeta[2] };
w_i_.at<Vec3b>(idx) = wi;
}
}
我得到一個斷言失敗錯誤的產生墊:: at()當我運行代碼。具體來說,我得到的消息是:
OpenCV Error: Assertion failed (elemSize() == (((((DataType<_Tp>::type) & ((512 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> ((DataType<_Tp>::type) & ((1 << 3) - 1))*2) & 3))) in cv::Mat::at, file c:\opencv\build\include\opencv2\core\mat.inl.hpp, line 1003
我已經在網上搜索,但我似乎無法找到關於5D矩陣任何主題(類似主題證明沒有幫助)。
在此先感謝
您好,感謝您的評論。算法運行時,zeta值始終在範圍內。我也手動檢查了這些值,它們在範圍內。在第一個循環期間(zeta值{10,7,5}和w_i_的大小是{96,128,13,13,13}),錯誤被提出。 –