【发布时间】:2017-05-28 07:39:07
【问题描述】:
如何通过 3 维矩阵进行索引? 我有这段代码,我知道循环内的字符串是错误的。有关以正确方式进行操作的任何建议。
Mat frame_;
cvtColor(frame, frame_, CV_BGR2HSV);
int size[3] = { capture_box_dim*capture_box_count, capture_box_dim, 3};
Mat ROI = Mat::zeros (3, size, frame_.type());
for (int i = 0; i < capture_box_count; i++)
{
for (int j = i*capture_box_dim, int k = box_pos_y[i], int l = 0, int t = box_pos_x[i];
j < i*capture_box_dim + capture_box_dim
&& k < box_pos_y[i] + capture_box_dim
&& l < capture_box_dim
&& t < box_pos_x[i] + capture_box_dim;
j++, k++, l++, t++)
{
ROI[j][l] = frame_[k][t];
}
}
【问题讨论】:
-
代码不完整,3D数组在哪里?
-
“循环内的字符串”是什么意思?我在您的代码中没有看到任何字符串类型的变量。
-
您的 for 循环看起来过于复杂。我会推荐一个更简单的布局。读起来很费劲。