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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…