Why is my OpenCV convexity defect in Android getting an error?
I am a beginner android development and new to OpenCV. I have a project about gesture recognition in Android. I want to make a bulge defect on it. Before I get the convexity defect, I should have found the contour and convex hull. I've already done them. Now I make a bulge defect to get a defect in the hand and fingers. But something is wrong. When I generate my code with a bulge defect in my Android, it unfortunately stopped. I don't know if the convex defect function is wrong or if the way to get the defect value (MatOfInt4) in Point is wrong. Someone please help me. Thank. This is my code:
List<MatOfInt> hull = new ArrayList<MatOfInt>();
List<MatOfInt4> defect = new ArrayList<MatOfInt4>();
for(int i = 0; i < newContours.size(); i++)
{
hull.add(new MatOfInt());
Imgproc.convexHull(newContours.get(i), hull.get(i));
Imgproc.convexityDefects(newContours.get(i), hull.get(i), defect.get(i));
}
Point defectSP= new Point();
Point defectEP= new Point();
Point defectFP= new Point();
for(int i = 0; i < defect.size(); i++)
{
Point[] startP = new Point[newContours.get(i).rows()];
Point[] endP = new Point[newContours.get(i).rows()];
Point[] farP = new Point[newContours.get(i).rows()];
Point[] depthP = new Point[newContours.get(i).rows()];
for(int j = 0; j < defect.get(i).rows(); j++)
{
int distP = (int) defect.get(i).get(j, 3)[3];
if (distP > 20*256)
{
startId = (int) defect.get(i).get(j, 0)[0];
endId = (int) defect.get(i).get(j, 1)[1];
farId = (int) defect.get(i).get(j, 2)[2];
defectSP.x = startId;
defectSP.y = startId;
defectEP.x = endId;
defectEP.y = endId;
defectFP.x = farId;
defectFP.y = farId;
}
}
}
+3
source to share
No one has answered this question yet
Check out similar questions: