Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find corner coordinates of Image contour in Opencv and C
    text
    copied!<p>I have to find corner points of an image so that I can crop it in rectangular shape.I have already found the contour and used approxpoly() function on it.Now how to find the corner Co-ordinates of the contour ? Here is my C code-></p> <pre><code>#include &lt;cv.h&gt; #include &lt;highgui.h&gt; int main(int argc, char** argv) { IplImage *img,*gray; if((img = cvLoadImage("save.jpg", 1)) == NULL) { printf("A Img open error\n"); } gray=cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 ); cvCvtColor(img,gray,CV_BGR2GRAY); IplImage* out_median = cvCreateImage(cvGetSize(gray),IPL_DEPTH_8U,1); cvSmooth( gray,out_median,CV_MEDIAN,3); IplImage* out_threshold = cvCreateImage( cvGetSize(out_median), out_median-&gt;depth, 1); cvThreshold(out_median,out_threshold,1,255,CV_THRESH_BINARY); CvMemStorage* storage = cvCreateMemStorage(); CvSeq* first_contour = NULL; cvFindContours(out_threshold,storage,&amp;first_contour,sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE); CvSeq* approx_polygon = NULL; approx_polygon=cvApproxPoly(first_contour,sizeof(CvContour),storage,CV_POLY_APPROX_DP,0.01*cvArcLength(first_contour,CV_WHOLE_SEQ, 1),0); //cvDrawContours(out_threshold,approx_polygon,cvScalarAll(255),cvScalarAll(255),100); //cvShowImage("Contours", out_threshold ); //cvSaveImage("save_approxpoly_contour.jpg",out_threshold); cvWaitKey(0); return 0; </code></pre> <p>}</p> <p>This my Contour Image after applying the Approxpoly() <img src="https://i.stack.imgur.com/DGGxX.jpg" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload