我想獲得3個通道的墊子,這樣的東西的偶數行/的cols:的OpenCV獲得墊
A = 1 0 1 0 1 0
1 0 1 0 1 0
1 0 1 0 1 0
result = 1 1 1
1 1 1
如何我能做到這一點使用OpenCV的?
在此先感謝。
編輯:
這裏是我使用的代碼:
Mat img_object = imread(patternImageName);
Mat a;
for (int index = 0,j = 0; index < img_object.rows; index = index + 2, j++)
{
a.row(j) = img_object.row(index);
}
但它拋出以下異常:
OpenCV Error: Assertion failed (m.dims >= 2) in Mat, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/matrix.cpp, line 269
terminate called after throwing an instance of 'cv::Exception'
j的效用是什麼?以及爲什麼我們將0添加到A.row(i)? – Maystro
不知道+0,我把它從別的東西上扯下來。 J在代碼更新中反映出來。這是爲索引destMat的行,因爲你不想增加2 – GPPK
編輯的問題 – Maystro