Ask Your Question

abhilash1in's profile - activity

2016-07-19 09:18:26 -0600 received badge  Enthusiast
2016-07-15 06:54:50 -0600 received badge  Editor (source)
2016-07-15 06:53:42 -0600 asked a question Converting c++ to java

I have the following code in C++

vector<Vec4i> hierarchy;
//some code here

findContours( edges, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
//some code here

while(hierarchy[k][2] != -1)
{
    k = hierarchy[k][2] ;    // k is an integer
    c = c+1;                      // c in an integer
}
if(hierarchy[k][2] != -1)
    c = c+1;

I'm trying to convert it to Java. I've achieved the following so far:

Mat hierarchy = new Mat();
//some code here

Imgproc.findContours(edges,contours,hierarchy,Imgproc.RETR_TREE,Imgproc.CHAIN_APPROX_SIMPLE);
//some code here

I'm facing a problem with converting lines like these

while(hierarchy[k][2] != -1)

where I'm accessing some

hierarchy[i][j]

How do I do this in Java? I can see that I can do a Mat.get(int row,int col) in Java which returns me a double[ ] but I'm looking for an int return value when I do hierarchy[i][j] in C++

2016-07-14 17:54:49 -0600 commented answer Rotating Android Camera to Portrait

This is resulting in performance degradation. The camera preview is not realtime and lags by an unacceptable margin

2016-07-14 12:51:24 -0600 received badge  Supporter (source)