private static int[] MatToFloatArray1(Mat mat) {
org.bytedeco.javacpp.BytePointer matData = mat.data();
byte[] d = new byte[matData.capacity()];
return toIntArray(d);
}
private static int[] MatToFloatArray2(Mat mat) {
org.bytedeco.javacpp.BytePointer matData = mat.data();
IntBuffer intBuffer = matData.asBuffer().asIntBuffer();
return intBuffer.array();
}
private static int[] toIntArray(byte[] d) {
IntBuffer intBuf =
ByteBuffer.wrap(d)
.order(ByteOrder.BIG_ENDIAN)
.asIntBuffer();
int[] array = new int[intBuf.remaining()];
return array;
}
There's nothing that I know of for that in OpenCV, I'm afraid. We can use Mat.createBuffer() to access the raw data and use that with ND4J though.
Samuel
--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-proje...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
ByteBuffer buffer = resizedImage.<ByteBuffer>createBuffer();
byte[] byteArray = new byte[buffer.remaining()];
int[] intArray = toIntArray(d);
private static int[] toIntArray(byte[] d) {
IntBuffer intBuf = ByteBuffer.wrap(d)
.order(ByteOrder.BIG_ENDIAN)
.asIntBuffer();
int[] array = new int[intBuf.remaining()];
return array;
}
Arrays byteArray and intArray has all entries as 0.
Any possibility you can provide a help here ? Thanks.
You'll probably need to convert the bytes to ints here...