# Coordinate transform from ROI in original image

Hello!

I have a little problem with som projection and geometry. I have an image where I detect a square. After the square detection, I crop the square from image. In the ROI I detect the point P(x,y) (see the image below).

My problem is that I know the coordinate of point P in the ROI, the coordinates of A,B,C,D, and rotation of ROI (RotatedRect::angle) but i want to get the coordinate of P in original image. Any advice could help.

Thanks!

EDIT :

For ROI crop I have this code

    vector< RotatedRect > rect(squares.size());

for (int i=0;i<squares.size();i++) // square.size() is the number of detected square(in some cases could be more squares in original image)
{
rect[i] = minAreaRect(Mat(squares[i]));
Mat M,rotated,cropped;
float angle = rect[i].angle;
Size rect_size = rect[i].size;

if (rect[i].angle<-45)
{
angle += 90;
swap(rect_size.width,rect_size.height);
}

M = getRotationMatrix2D(rect[i].center,angle,1.0);
warpAffine(cameraFeed,rotated,M,cameraFeed.size(),INTER_CUBIC);
getRectSubPix(rotated,rect_size,rect[i].center,cropped);
cropped.copyTo(SatelliteClass[i].m_matROIcropped);
SatelliteClass[i].m_vecRect = rect[i];
}

edit retag close merge delete