Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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] ;
    c = c+1;
}
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 there

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) which returns me a double[ ] but I'm looking for an int return value when I do hierarchy[i][j] in C++

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+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 therethese

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) which returns me a double[ ] but I'm looking for an int return value when I do hierarchy[i][j] in C++

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++