In the two-dimensional image of OpenCV, the size or position is expressed by the four attributes of rows, cols, x, and y, which is easy to be confused.
Rows represent rows, and cols represent columns.
x is on cols and y is on rows. (Easy to confuse)
Note the constructor
matrix
Mat img(int rows,int cols,int type);//先行(宽)后列(高)
rectangle
Rect rect(int x,int y,int width, int height);//先横坐标后纵坐标,width对应cols,height对应rows
point
Point p(int x,int y);//先横坐标后纵坐标
size
Size size(int width,int height);//先宽(行)后高(列)
at<>() function
img.at<type>(y,x);//先纵坐标后横坐标
img.at<type>(Point(x,y));//参数为点则先横坐标后纵坐标
·