Accessing elements of a cv::Mat with at(i, j). Is it (x,y) or (row,col)?

OpenCV, like many other libraries, treat matrix access in row-major order. That means every access is defined as (row, column). Note that if you’re working with x and y coordinates of an image, this becomes (y, x), if y is your vertical axis.

Most matrix libraries are the same in that regards, the access is (row, col) as well in, for example, Matlab or Eigen (a C++ matrix library).

Where these applications and libraries do differ however is how the data is actually stored in memory. OpenCV stores the data in row-major order in memory (i.e. the rows come first), while for example Matlab stores the data in column-major order in memory. But if you’re just a user of these libraries, and accessing the data via a (row, col) accessor, you’ll never actually see this difference in memory storage order.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)