openCV中Point2f的结构是什么?

skm*_*skm 12 opencv

我很困惑什么Point2f回报.我有,vector<Point2f> corner;那么行和列的坐标是什么?它会跟随:

int row_coordinate = corner[i].x;
int col_coordinate = corner[i].y;
Run Code Online (Sandbox Code Playgroud)

但如果我采取上述惯例,我会遇到分段错误.如果我这样做的话

int row_coordinate = corner[i].y;
int col_coordinate = corner[i].x;
Run Code Online (Sandbox Code Playgroud)

然后我得到了结果,但它似乎与OpenCV文档相反.请告诉我哪一个是正确的.如果你提供一些文档链接(我已经尝试搜索了很多)会非常好.

aze*_*r89 8

如果我是对的,我认为你对OpenCV的坐标系很困惑.

因为我总是使用x作为宽度,y作为高度,在我的程序中,我使用OpenCV,如下所示:

// make an image with height 100 and width 200   
cv::Mat img = cv::Mat::zeros(100, 200, CV_8UC1);

int width = img.cols;
int height = img.rows;

cv::Point2f pt(10, 20);

// How do I get a pixel at x = 10 and y = 20 ?
int px = img.at<uchar>(pt.y, pt.x); // yep, it's inverted
Run Code Online (Sandbox Code Playgroud)

这是什么意思?OpenCV corrdinate系统基于行然后是列.如果你想获得(x,y)的像素,使用(y,x)访问它