what is the starting point of a contour as given by cvConvexityDefect() function in OpenCV i have to distinguish between palm and elbow in my contour(I'm using cvconvexitydefect for that purpose). Here's the image:



I'm taking contour of left image.

the 2 topmost points in right image are shoulder(detected by other method)

bottom left 2 are darker than bottom right 2 (to distinguish between left and right hand)

using the code defect.start is darker than defect.end(but for left hand defect.start is palm while for right hand defect.start is elbow)

I have 2 questions:


So how does cvconvexity defect get it's defect.start?
In any case how to differentiate palm from elbow?


To be clear i thought that i could make out the palm from elbow just by thinking that start might be upper most point of a contour or leftmost point of that but it ain't so.

here's the relevant part of code:

cvFindContours( HeadLess1, mem, &amp;contours, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));

for(ptr=contours;ptr!=0;ptr=ptr-&gt;h_next){
    tem=cvConvexHull2(ptr,0,1,0);
    tem=cvConvexityDefects(ptr,tem,mem);
    CvConvexityDefect defect,cd;
    defect.depth=0;

    for(int l=0;l&lt;tem-&gt;total;l++){
        cd=*(CvConvexityDefect*)cvGetSeqElem(tem,l);
        if(cd.depth&gt;defect.depth)defect=cd;
    }

    if((*(defect.start)).y&gt;(*(defect.end)).y){
        elbow=(*(defect.start));palm=(*(defect.end));
        //a bad inference for the case when palm is above elbow
    } else { 
        elbow=(*(defect.end));palm=(*(defect.start));
        //a bad inference same case
    }

    if(elbow.x&lt;320)
    {
        q=100;
    }
    else
    {
        q=200;
    }

    cvCircle(HeadLess1,*(defect.start),10,cvScalarAll(q),CV_FILLED);
    cvCircle(HeadLess1, *(defect.end), 10, cvScalarAll(q+50), CV_FILLED);

}


Headless1 one is my image. Thanks in advance.
If you can obtain coordinates for the points you show in the right hand image, and you know the points relating to the shoulders, could you presume that the palms were further from the shoulder than the elbow is?

If you assume this to be true, then you simply need to find the distance from the shoulder to the elbow &amp; palm and call the point with the larger distance the palm.

Of course, you could bend your arm in such a way that the palm would be closer to the elbow, so perhaps this isn't an ideal method...