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, &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;ltotal;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));
//a bad inference same case
}
if(elbow.x<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.
No comments:
Post a Comment