I have just used canny edge detection to detect a rectangle in an image. I would like to get the four corners of the rectangle
Asked
Active
Viewed 4,254 times
3
-
Please see my answer here: [http://stackoverflow.com/questions/7263621/how-to-find-corners-on-a-image-using-opencv/7263794#7263794][1] [1]: http://stackoverflow.com/questions/7263621/how-to-find-corners-on-a-image-using-opencv/7263794#7263794 – Throwback1986 Dec 06 '13 at 04:52
-
@Throwback1986 Can you please explain step 7. I do not fully understand it. – Jack welch Dec 06 '13 at 05:20
2 Answers
1
Please see my answer here: How to find corners on a Image using OpenCv
As for step 7: cvApproxPoly returns a CvSeq*. This link explains it well. As shown here, a CvSeq struct contains a total member that contains the number of elements in the sequence. In the case of a true quadrilateral, total should equal 4. If the quadrilateral is a square (or rectangle), angles between adjacent vertices should be ~90 degrees.

Community
- 1
- 1

Throwback1986
- 5,887
- 1
- 30
- 22
-
Thanks for the help. I have a question. I am using c++ to perform this operation.What is the equivalent way of finding the CVseq result in c++.How do I get that value from approxPolyDp(); – Jack welch Dec 06 '13 at 08:28
0
findContours will give you the outline points

berak
- 39,159
- 9
- 91
- 89
-
-
[apprxPolyDP](http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#void%20approxPolyDP(InputArray%20curve,%20OutputArray%20approxCurve,%20double%20epsilon,%20bool%20closed)) with a high value for epsilon should reduce it to a rect – berak Dec 05 '13 at 20:39