OpenCV Rect x和y代表(column,row)或(row,column)
OpenCV Rect x and y represent (column,row) or (row,column)
我想用 0 值替换图像 (Mat) 的矩形部分。我的图像有 1000 行和 1500 列。我想在 (890,1340) 处屏蔽宽度为 150、高度为 100 的补丁。为此,我使用以下代码片段:
cv::Rect patch;
patch.y = 890;
patch.x = 1340;
patch.height = 100;
patch.width = 150;
image(patch) = 0;
但我收到以下错误:
OpenCV错误:输入参数的大小不匹配(操作既不是'array op array'(数组具有相同的大小和相同的通道数),也不是'array op scalar',也不是'scalar op array') 在 cv::arithm_op,文件 C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\arithm.cpp,第 659 行
我已经更改了 Rect patch 的 x 和 y 坐标,但仍然出现相同的错误。我在网上搜索过,但我对 Rect 参数仍然很困惑。
Rect x,y是代表(column,row)还是(row,column)?
Rect
x 代表列,y 代表行。这意味着 image.at(i,j) 使用 (i,j) 作为 (row,column) 但 Rect(x,y) 使用 (x,y) 作为 (column,row).
我想用 0 值替换图像 (Mat) 的矩形部分。我的图像有 1000 行和 1500 列。我想在 (890,1340) 处屏蔽宽度为 150、高度为 100 的补丁。为此,我使用以下代码片段:
cv::Rect patch;
patch.y = 890;
patch.x = 1340;
patch.height = 100;
patch.width = 150;
image(patch) = 0;
但我收到以下错误:
OpenCV错误:输入参数的大小不匹配(操作既不是'array op array'(数组具有相同的大小和相同的通道数),也不是'array op scalar',也不是'scalar op array') 在 cv::arithm_op,文件 C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\arithm.cpp,第 659 行
我已经更改了 Rect patch 的 x 和 y 坐标,但仍然出现相同的错误。我在网上搜索过,但我对 Rect 参数仍然很困惑。
Rect x,y是代表(column,row)还是(row,column)?
Rect
x 代表列,y 代表行。这意味着 image.at(i,j) 使用 (i,j) 作为 (row,column) 但 Rect(x,y) 使用 (x,y) 作为 (column,row).