Ask Your Question
0

Hand center detection

asked 2012-07-24 05:13:51 -0600

seiko gravatar image

updated 2012-07-24 06:11:45 -0600

Andrey Pavlenko gravatar image

I am detecting the hand, using Defects but i need only the palm without fingers, the center of the palm without fingers. I wrote this piece of code:

int ht, //height left 
    hb, //height right
    wl, //width top
    wr; //width botton
bool ok = true;
label1.Text = label1.Text + ",";
for(int i = 10; i < skin.Height - 10; i += 10)
    for(int j = 10; j < skin.Width - 10; j+=10)
    {
        wl = wr = j;
        ht = hb = i;
        if(skin[i, j].MCvScalar.v0 == 0)
            ok = true;
            while(ok)
            {
                wl--;
                wr++;
                ht--;
                hb++;
                if( (wl <= 0 || wr >=skin.Height || ht <= 0 || hb >=skin.Width) || 
                    ( skin[j, ht].MCvScalar.v0 != 0 || skin[j, hb].MCvScalar.v0 != 0 ||
                      skin[wl, j].MCvScalar.v0 != 0 || skin[wr, j].MCvScalar.v0 != 0) )
                {
                    if(maxCircleRadius < (wr - wl) / 2)
                    {
                        maxCircleRadius = (wr - wl) / 2;
                        palmCenter.X = (wr + wl) / 2;
                        palmCenter.Y = (ht + hb) / 2;
                        currentFrame.Draw(new CircleF(new PointF(palmCenter.X, palmCenter.Y), 3), new Bgr(200, 125, 75), 2);
                        label1.Text = maxCircleRadius.ToString();
                    }
                    ok = false;
                }
            }
    }

but it takes around 0.5 sec for each image to detect the palm wich is way too much for me. Is there any other solution to detect the palm without fingers?

edit retag flag offensive close merge delete

Comments

The performance problem may be the drawing delay. Try removing the Draw() and label.Text calls and re-measure your app. You should also make sure you compile for Release.

sammy gravatar imagesammy ( 2012-07-24 06:23:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-07-24 06:43:28 -0600

Daniil Osokin gravatar image

Here is a tutorial Convex Hull, may be some approaches will useful. As in tutorial you can try to use findContours, and then fitEllipse to find centre of contour. Hope, this helps.

edit flag offensive delete link more

Comments

I know that way...but when you close/open the palm the center is not the same and i need a stable point, as much is possible.

seiko gravatar imageseiko ( 2012-07-31 02:22:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-07-24 05:13:51 -0600

Seen: 3,818 times

Last updated: Jul 24 '12