Finger count and convexity defects providing wrong value

asked 2016-02-15 10:35:20 -0600

Vivek_Elango gravatar image

I have retrieved convexity defects and after referring to some questions asked here, I figured out that Convexity defect contains data in 4s, i.e., [startIndex, endIndex, farthestPoint, depth].

So I retrieved the all these values and drew circles at the points (except depth). Following is the code which I used to do that.

    for (int j = 0; j < convexDefect.toList().size(); j = j+4) {

        if(farPoint.y < a){

            MODELConvexityDefects convexityDefects = new MODELConvexityDefects();





    // Draws all the points from defect data
    MODELConvexityDefects convexityDefects;

    for (int i = 0; i < convexityData.size(); i++) {

        convexityDefects = new MODELConvexityDefects();
        convexityDefects = convexityData.get(i);

                    // Green, convexityDefects.getStartIndex(), 6, new Scalar(0,154,0));
                    // Orange, convexityDefects.getEndIndex(), 6, new Scalar(0,154,246)); 
                    // Red, convexityDefects.getFarthestPoint(), 6, new Scalar(0,0,255));

The output I got is not really desirable one. Please tell me what am I doing wrong here.


If you notice I'm not able to get the farthest point correctly and the thumb is completely neglected.

edit retag flag offensive close merge delete


What is MODELConvexityDefects?

FooBar gravatar imageFooBar ( 2016-02-15 11:01:37 -0600 )edit

Something similar here. have you got last opencv version?

LBerger gravatar imageLBerger ( 2016-02-15 11:03:08 -0600 )edit

Oh no I'm using 2.4.11 @LBerger

Vivek_Elango gravatar imageVivek_Elango ( 2016-02-15 11:05:41 -0600 )edit

@FooBar, MODELConvexityDefects is a custom getter and setter class.

Vivek_Elango gravatar imageVivek_Elango ( 2016-02-15 11:06:24 -0600 )edit