I am re asking this question with a better explanation.
I have obtained the four points of a rectangle that I wish to perform a warp perspective transformation on. I have successfully achieved a transform on one of my images as I manually selected the points and assigned their location for the transform.
cv::Point2f src_vertices[4];
src_vertices[0] = corners[3];
src_vertices[1] = corners[1];
src_vertices[2] = corners[0];
src_vertices[3] = corners[2];
Point2f dst_vertices[4];
dst_vertices[0] = Point(0, 0);
dst_vertices[1] = Point(box.boundingRect().width-1, 0);
dst_vertices[2] = Point(0, box.boundingRect().height-1);
dst_vertices[3] = Point(box.boundingRect().width-1, box.boundingRect().height-1);
As you can see I assigned the corners to the transformation vertices manually.
As I wish to use this code on multiple slightly different images I would like a more accurate way of assigning the corners.
All the images will look similar to this:
The corners for this image are as follows: Top left - (1106, 331), Top right- (810, 747), Bottom left- (825, 187), Bottom right- (510, 537)
I have found the max and min x and y values as follows:
float X, Y;
float maxX= 0;
float minX = 10000;
float maxY= 0;
float minY = 10000;
for(int i=0; i< 4; i++){
if( corners[i].x > maxX){
maxX = corners[i].x;
}
if( corners[i].x < minX){
minX = corners[i].x;
}
if( corners[i].y > maxY){
maxY = corners[i].y;
}
if( corners[i].y < minY){
minY = corners[i].y;
}
}
This gives me:
maxX - 1106, minX - 510, maxY - 747, minY - 187.
I would like to know how to recombine the max and min values to their respective values so I can use the points to perform the transform. I am quite new to opencv so sorry if this is very obvious.
xvalue. - villasv