Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding Points in Contours
    primarykey
    data
    text
    <p>So here is the code that i used to detect the <b>contours</b>:</p> <pre class="lang-cpp prettyprint-override"><code>IplImage* DetectAndDrawQuads(IplImage* img) { CvSeq* contours; CvSeq* result; CvMemStorage *storage = cvCreateMemStorage(0); IplImage* ret = cvCreateImage(cvGetSize(img), 8, 3); IplImage* temp = cvCreateImage(cvGetSize(img), 8, 1); cvCvtColor(img, temp, CV_BGR2GRAY); cvFindContours(temp, storage, &amp;contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0)); while(contours) { result = cvApproxPoly(contours, sizeof(CvContour), storage, CV_POLY_APPROX_DP, cvContourPerimeter(contours)*0.10, 0); //*0.2 if((result-&gt;total) == 4) { CvPoint *pt[4]; for(int i=0;i&lt;4;i++) pt[i] = (CvPoint*)cvGetSeqElem(result, i); cvLine(ret, *pt[0], *pt[1], cvScalar(255)); cvLine(ret, *pt[1], *pt[2], cvScalar(255)); cvLine(ret, *pt[2], *pt[3], cvScalar(255)); cvLine(ret, *pt[3], *pt[0], cvScalar(255)); } contours = contours-&gt;h_next; } cvReleaseImage(&amp;temp); cvReleaseMemStorage(&amp;storage); return ret; } int main() { IplImage* img = cvLoadImage("D:\\Database\\eye2.jpg"); IplImage* contourDrawn = 0; cvNamedWindow("original"); cvShowImage("original", img); contourDrawn = DetectAndDrawQuads(img); cvNamedWindow("contours"); cvShowImage("contours", contourDrawn); cvWaitKey(0); return 0; } </code></pre> <p>And this is the <b><i>Pic</b></i> that I used to test the program: <a href="http://i.stack.imgur.com/6FrMQ.jpg" rel="nofollow">Input</a></p> <p>I am trying to get the contours as a preliminary step in finding the facial expression of an inputted face. And this is the <b><i>Result</b></i> when i tried to run the program (<b>Original</b> [left] and <b>Output</b> [right]): <a href="http://i.stack.imgur.com/zQbzQ.jpg" rel="nofollow">Result</a></p> <p>As you can see there seems to be some noise left in the binary image (Which I actually preprocessed before it is being inputted in my find contours program (the codes above)). </p> <h2>My Question is:</h2> <p><br> <br></p> <ol> <li>How to find the points in the contours (e.g, top, bottom, center, leftmost, and rightmost --> essential points to make geometrical calculations to determine facial expression). </li> </ol> <p>Thank you very much if you will help me. So far, this is the best output i could generate regarding finding contours. Also if you can help me extract the contours more accurately then that will be very much appreciated. Thank you. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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