How to find the external points of a square/rectangle contour?

I have found some contours. Then by using approxPolyDP i found the contours with four conoturs. I know want to find the four points on that square and make a bounding box on those points so I can make perspective transformation on separate image. I cannot find the four points. I have tried to find max and min of contours[j][k].x to find max value and min value. I have also tried to use a bounding box but that just makes a square around the contour and I lose the edges. I hope someone can help.


use a debugger. perhaps use gdb, or use visual studio. look at all the variables in your program, as it runs.

So you are telling me that looping through the contours to find the max/min points are the correct method of finding the coordinate points making up of the contours?

you ran approxPolyDP. how many points are in the resulting contour?

1 Like

I was working within contours. I should have worked within approxpolydp vector. Thanks for the clarification.