【发布时间】:2017-03-02 16:05:34
【问题描述】:
我想将图像中水平像素和垂直像素的总数存储在二维数组中。使用opencv在c ++中执行此操作的语法应该是什么?这是我在 C++ 中使用 opencv 库编写的代码。
using namespace std;
using namespace cv;
Mat image=imread("task1-1.png");
const int IDIM = image.rows; // horizontal size of the squares
const int JDIM = image.cols; // vertical size size of the squares
int squares[IDIM][JDIM];
它给了我一个错误说明:
数组边界在']'标记之前不是整数常量 int squares[IDIM][JDIM]; ^ 数组边界在 ']' 标记 int squares[IDIM][JDIM] 之前不是整数常量; ^
执行此操作的正确方法应该是什么?
【问题讨论】:
-
“^”标记两次都指向“]”标记。
-
不要。像其他人一样使用平面内存缓冲区。
-
为什么要使用二维数组,你已经有了
Mat。你真的需要它还是你认为你需要它? -
其实我需要获取障碍物中的所有节点,起点,终点,可移动区域,以便使用A*算法找到最短路径。
标签: c++ image-processing opencv3.0