Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

java unknown exception when using Mat.put

I need to allocate rather large matrix using OpenCV 3.1.0. I'm running following code with -Djava.library.path=$MODULE_DIR$\opencv\310\windows\x64\ -Xmx8g arguments:

static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}

@Test
public void medium() throws IOException {
    float[] data = new float[13918*13240];
    Mat iMatrix = new Mat(13918, 13240, CvType.CV_32FC1);
    iMatrix.put(0, 0, data);
}

@Test
public void tooBig() throws IOException {
    float[] data = new float[13320*67294];
    Mat iMatrix = new Mat(13320, 67294, CvType.CV_32FC1);
    iMatrix.put(0, 0, data);
}

The first test works, since the seconds throws:

java.lang.Exception: unknown exception  
at org.opencv.core.Mat.nPutF(Native Method)  
at org.opencv.core.Mat.put(Mat.java:953)

Is it a OpenCV or native library usage limitation? Is there a workaround for such issue?

java unknown exception when using Mat.put

I need to allocate rather large matrix using OpenCV 3.1.0. I'm running following code with -Djava.library.path=$MODULE_DIR$\opencv\310\windows\x64\ -Xmx8g arguments: arguments:

public class MatTest extends BaseTest {

  static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}

 @Test
  public void tooBig() throws IOException {
    float[] data = new float[13320*67294];
    Mat iMatrix = new Mat(13320, 67294, CvType.CV_32FC1);
    iMatrix.put(0, 0, data); //exception here
  }

  @Test
  public void medium() throws IOException {
    float[] data = new float[13918*13240];
    Mat iMatrix = new Mat(13918, 13240, CvType.CV_32FC1);
    iMatrix.put(0, 0, data);
 }

@Test
public void tooBig() throws IOException {
    float[] data = new float[13320*67294];
    Mat iMatrix = new Mat(13320, 67294, CvType.CV_32FC1);
    iMatrix.put(0, 0, data);
}

The first test works, since the seconds throws:throws (line: iMatrix.put(0, 0, data))

java.lang.Exception: unknown exception  
exception

  at org.opencv.core.Mat.nPutF(Native Method)  
Method)
  at org.opencv.core.Mat.put(Mat.java:953)
  at my.app.MatTest.tooBig(MatTest.java:19)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)

Is it a OpenCV or native library usage limitation? Is there a workaround for such issue?

Edited: attached full code and stacktrace