How do I draw Convexity Defect using OpenCV Android ???

I'm doing my final project about hand gesture recognition using OpenCV in Android. So far I did until Convex Hull. Now, I want to draw convexity defect on it and get the defect value from it. But I am stack. I found some references codes, but most of it written in C++ code. I have no idea how to convert them into Java android code. Anyone, Would you mind to help me by convert this code? this is the C++ code :

/// Draw convexityDefects
for( int i = 0; i< contours.size(); i++ )
{
size_t count = contours[i].size();
if( count <300 )
continue;

vector<Vec4i>::iterator d=convdefect[i].begin();
while( d!=convdefect[i].end() ) {
Vec4i& v=(*d);
int startidx=v; Point ptStart( contours[i][startidx] );
int endidx=v; Point ptEnd( contours[i][endidx] );
int faridx=v; Point ptFar( contours[i][faridx] );
float depth = v / 256;

line( drawing, ptStart, ptEnd, Scalar(0,255,0), 1 );
line( drawing, ptStart, ptFar, Scalar(0,255,0), 1 );
line( drawing, ptEnd, ptFar, Scalar(0,255,0), 1 );
circle( drawing, ptFar,   4, Scalar(0,255,0), 2 );
d++;
}
}

I would be glad if you can solve this for me, because it's for my final project. Thanks a lot.

edit retag close merge delete