i know this is a simple math, but I stuck. i'm using c++ opencv for image processing. I have two rectangles, and bounding box inside both of it. the problem is to get coordinates of this bounding box in original full frame.
cv::Point2d rawTopLeft, rawBotRight; //x0,y0, x1,y1
auto rawWidth = rawBotRight.x - rawTopLeft.x;
auto rawHeight = rawBotRight.y - rawTopLeft.y;
/*
640 - is origin_width
400 - origin height
320 - small frame width
200 - small frame height
(x0,y0,x1,y1) - raw coordinates on small frame
*/
auto xScale = 640 / 320; //scales between small frame and big one
auto yScale = 400 / 200;
auto topLeft = cv::Point2d(rawTopLeft.x * xScale, rawTopLeft.y * yScale);
auto botRight = cv::Point2d(rawBotRight.x * xScale, rawBotRight.y * yScale);
I assume, that bounding box coordinates in original reference frame are topLeft.x, topLeft.y, botRight.x, botRight.y, but when I use cv::Rectangle(topLeft.x, topLeft.y, botRight.x - topLeft.x, botRight.y - topLeft.y) image shows wrong box. What am I doing wrong? Ty for advices.
Here is a picture explaining the problem:
