I am confused about what does Point2f
returns. I have vector<Point2f> corner;
So, what would be the coordinate of rows and columns? Will it be following:
int row_coordinate = corner[i].x;
int col_coordinate = corner[i].y;
But I get a segmentation fault if I take the above-mentioned convention. And if I do it like
int row_coordinate = corner[i].y;
int col_coordinate = corner[i].x;
then I get the results but then it seems to be opposite to the OpenCV documentation. Kindly tell me which one is correct. Would be very nice if you provide some documentation link (which I have already tried to search a lot).
If I'm correct, I assume you're confused with the coordinate system of OpenCV.
Since I always use x as width and y as height, in my program, I use OpenCV like this:
// 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
What does it mean? OpenCV corrdinate system is based on rows and then columns. If you want to get pixels at (x, y) access it using (y, x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With