关于c++:OpenCV中二维坐标顺序

11次阅读

共计 367 个字符,预计需要花费 1 分钟才能阅读完成。

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));// 参数为点则先横坐标后纵坐标·

正文完
 0