Ask Your Question

Vivek_Elango's profile - activity

2016-02-15 11:06:24 -0600 commented question Finger count and convexity defects providing wrong value

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

2016-02-15 11:05:41 -0600 commented question Finger count and convexity defects providing wrong value

Oh no I'm using 2.4.11 @LBerger

2016-02-15 10:35:20 -0600 asked a question Finger count and convexity defects providing wrong value

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();

             convexityDefects.setStartIndex(contours.get(boundPos).toList()
             .get(convexDefect.toList().get(j)));

            convexityDefects.setEndIndex(contours.get(boundPos).toList()
            .get(convexDefect.toList().get(j+1)));

            convexityDefects.setFarthestPoint(contours.get(boundPos).toList()
            .get(convexDefect.toList().get(j+2)));

            convexityData.add(convexityDefects);
            }
    }

    // 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 
        Core.circle(modifiedFrame, convexityDefects.getStartIndex(), 6, new Scalar(0,154,0));
                    // Orange 
        Core.circle(modifiedFrame, convexityDefects.getEndIndex(), 6, new Scalar(0,154,246)); 
                    // Red
        Core.circle(modifiedFrame, 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.

Output:

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

2016-02-04 12:09:54 -0600 received badge  Enthusiast
2016-01-21 08:53:50 -0600 commented answer opencv-2.4.4 in java.library.path error

This really did solve my problem, probably something we wouldn't really notice. Good catch

2016-01-21 08:44:21 -0600 received badge  Supporter (source)