# 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:

1. So how does cvconvexity defect get it's defect.start?
2. 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, &contours, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));

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

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

if((*(defect.start)).y>(*(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));
}

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

}


• Please ask if something is unclear. Thank you. – Roney Island Jun 7 '12 at 10:05
• just to know: how are you getting this image? – nkint Jun 19 '12 at 9:44

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 & 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...

• But I can't assume that. Thanks Anyways. But there's got to be a method by which cvConvexityDefect calculates it's starting point. – Roney Island Jun 7 '12 at 16:28