OpenCV中二维坐标顺序

OpenCV的二维图像中,通过rows、cols、x、y四个属性来表示大小或位置,容易混淆。

rows代表的是行,cols代表的是列。

x在cols上,y在rows上。(容易混淆)

应注意的构造函数

矩阵

Mat img(int rows,int cols,int type);//先行(宽)后列(高)

矩形

Rect rect(int x,int y,int width, int height);//先横坐标后纵坐标,width对应cols,height对应rows

Point p(int x,int y);//先横坐标后纵坐标

尺寸

Size size(int width,int height);//先宽(行)后高(列)

at<>()函数

img.at<type>(y,x);//先纵坐标后横坐标

img.at<type>(Point(x,y));//参数为点则先横坐标后纵坐标·

猜你喜欢

转载自blog.csdn.net/weixin_51447314/article/details/114151838