Javacpp-presets: In OpenCV: How to let int[][] conert to Mat ?

Created on 12 Jul 2019  Â·  7Comments  Â·  Source: bytedeco/javacpp-presets

enhancement help wanted

All 7 comments

We have to do it manually with loops:
http://bytedeco.org/news/2014/12/23/third-release/
We can always add helper methods for that though.

@saudet Hi,this code is correct?

int[][] kk = {{0,0,0,0},{0,0,0,0},{0,0,0,0}}
PointerPointer pointer = new PointerPointer(3);
for(int i = 0; i < 3; i++){
     pointer.put(kk[i]);
}
 Mat pano = new Mat(row, col, CV_32SC1, pointer);

No, try to use indexers instead.

But 'Mat(int rows, int cols, int type, Pointer data) ' must need Pointer, what can I do ?

No, it doesn't.

Try something like this:

Mat pano = new Mat(row, col, CV_32SC1);
IntIndexer idx = mat.createIndexer();
for (int i = 0; i < kk.length; i++) {
    idx.put(i, kk[i]);
}

Thanks! It is ok!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kwatters picture kwatters  Â·  24Comments

oneengineer picture oneengineer  Â·  34Comments

blueberry picture blueberry  Â·  34Comments

archenroot picture archenroot  Â·  29Comments

mmanco picture mmanco  Â·  20Comments