Merge pull request #10050 from floe/android-studio-3.3.1
Add Android Mat constructor with support for native buffer (#10050)
This commit is contained in:
committed by
Alexander Alekhin
parent
c6fb99357c
commit
2e772510ea
@@ -1,6 +1,7 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvException;
|
||||
@@ -1001,4 +1002,16 @@ public class MatTest extends OpenCVTestCase {
|
||||
assertMatEqual(truth, dst);
|
||||
}
|
||||
|
||||
public void testMatFromByteBuffer() {
|
||||
ByteBuffer bbuf = ByteBuffer.allocateDirect(64*64);
|
||||
bbuf.putInt(0x01010101);
|
||||
Mat m = new Mat(64,64,CvType.CV_8UC1,bbuf);
|
||||
assertEquals(4, Core.countNonZero(m));
|
||||
Core.add(m, new Scalar(1), m);
|
||||
assertEquals(4096, Core.countNonZero(m));
|
||||
m.release();
|
||||
assertEquals(2, bbuf.get(0));
|
||||
assertEquals(1, bbuf.get(4095));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user