mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
Add test for Java Mat.at
This commit is contained in:
parent
3b42e19505
commit
f1f9121bc7
@ -1285,4 +1285,31 @@ public class MatTest extends OpenCVTestCase {
|
||||
assertEquals(5, bbuf.get(63*80 + 63));
|
||||
}
|
||||
|
||||
public void testMatAt() {
|
||||
Mat uc1 = new Mat(2, 3, CvType.CV_8S) {
|
||||
{
|
||||
put(0, 0, 1, 2, 3);
|
||||
put(1, 0, 4, 5, 6);
|
||||
}
|
||||
};
|
||||
assertEquals((byte)1, uc1.at(Byte.class, 0, 0).getV().byteValue());
|
||||
assertEquals((byte)2, uc1.at(Byte.class, 0, 1).getV().byteValue());
|
||||
assertEquals((byte)3, uc1.at(Byte.class, 0, 2).getV().byteValue());
|
||||
assertEquals((byte)4, uc1.at(Byte.class, 1, 0).getV().byteValue());
|
||||
assertEquals((byte)5, uc1.at(Byte.class, 1, 1).getV().byteValue());
|
||||
assertEquals((byte)6, uc1.at(Byte.class, 1, 2).getV().byteValue());
|
||||
uc1.at(Byte.class, 0, 0).setV((byte)7);
|
||||
uc1.at(Byte.class, 0, 1).setV((byte)8);
|
||||
uc1.at(Byte.class, 0, 2).setV((byte)9);
|
||||
uc1.at(Byte.class, 1, 0).setV((byte)10);
|
||||
uc1.at(Byte.class, 1, 1).setV((byte)11);
|
||||
uc1.at(Byte.class, 1, 2).setV((byte)12);
|
||||
byte[] data = new byte[6];
|
||||
uc1.get(0, 0, data);
|
||||
assertArrayEquals(data, new byte[] {7, 8, 9, 10, 11, 12});
|
||||
Mat.Tuple3<Byte> bgr = rgbLena.at(Byte.class, 0, 0).getV3c();
|
||||
assertEquals(bgr.get_0().byteValue(), (byte)128);
|
||||
assertEquals(bgr.get_1().byteValue(), (byte)138);
|
||||
assertEquals(bgr.get_2().byteValue(), (byte)225);
|
||||
}
|
||||
}
|
||||
|
@ -312,6 +312,13 @@ public class OpenCVTestCase extends TestCase {
|
||||
//assertTrue(Math.abs(ar1[i].doubleValue() - ar2[i].doubleValue()) <= epsilon);
|
||||
}
|
||||
|
||||
public static void assertArrayEquals(byte[] ar1, byte[] ar2) {
|
||||
assertEquals(ar1.length, ar2.length);
|
||||
|
||||
for (int i = 0; i < ar1.length; i++)
|
||||
assertEquals(ar1[i], ar2[i]);
|
||||
}
|
||||
|
||||
public static void assertArrayEquals(short[] ar1, short[] ar2) {
|
||||
assertEquals(ar1.length, ar2.length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user