Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculation of coordinates of point on a scaled Mat image in OpenCv

If I have a Mat image object (OpenCV) whose size is 960*720, on which I have calculated the coordinates of a Point object, and then I scale this Mat image, and its new size is 640*480, how can I find the new coordinates of the Point?

like image 686
user140888 Avatar asked Nov 13 '22 02:11

user140888


1 Answers

A point (x,y) in the original matrix will be mapped to (x',y') in the new matrix by

(x',y') = 2*(x,y)/3.

Reducing that to an OpenCV function we have:

cv::Point scale_point(cv::Point p) // p is location in 960*720 Mat
{
    return 2 * p / 3;   // return location in 640*480 Mat
}
like image 168
Bull Avatar answered Nov 15 '22 07:11

Bull