java tests: split into packages, tests for VideoCapture implemented
This commit is contained in:
parent
5649f35757
commit
72cc69e431
@ -10,4 +10,9 @@
|
|||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||||
<uses-library android:name="android.test.runner" />
|
<uses-library android:name="android.test.runner" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -11,44 +11,44 @@ import org.opencv.highgui;
|
|||||||
|
|
||||||
public class OpenCVTestCase extends TestCase {
|
public class OpenCVTestCase extends TestCase {
|
||||||
|
|
||||||
static int matSize = 10;
|
protected static int matSize = 10;
|
||||||
|
|
||||||
static Mat dst;
|
protected static Mat dst;
|
||||||
|
|
||||||
//Naming notation: <channels info>_[depth]_[dimensions]_value
|
//Naming notation: <channels info>_[depth]_[dimensions]_value
|
||||||
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
||||||
// grayRnd - single channel 8U 2d Mat filled with random numbers
|
// grayRnd - single channel 8U 2d Mat filled with random numbers
|
||||||
// gray0_32f_1d - refactor ;)
|
// gray0_32f_1d - refactor ;)
|
||||||
|
|
||||||
static Mat gray0;
|
protected static Mat gray0;
|
||||||
static Mat gray1;
|
protected static Mat gray1;
|
||||||
static Mat gray2;
|
protected static Mat gray2;
|
||||||
static Mat gray3;
|
protected static Mat gray3;
|
||||||
static Mat gray9;
|
protected static Mat gray9;
|
||||||
static Mat gray127;
|
protected static Mat gray127;
|
||||||
static Mat gray128;
|
protected static Mat gray128;
|
||||||
static Mat gray255;
|
protected static Mat gray255;
|
||||||
static Mat grayRnd;
|
protected static Mat grayRnd;
|
||||||
|
|
||||||
static Mat gray256;
|
protected static Mat gray_16u_256;
|
||||||
|
|
||||||
static Mat gray0_32f;
|
protected static Mat gray0_32f;
|
||||||
static Mat gray1_32f;
|
protected static Mat gray1_32f;
|
||||||
static Mat gray3_32f;
|
protected static Mat gray3_32f;
|
||||||
static Mat gray9_32f;
|
protected static Mat gray9_32f;
|
||||||
static Mat gray255_32f;
|
protected static Mat gray255_32f;
|
||||||
static Mat grayE_32f;
|
protected static Mat grayE_32f;
|
||||||
static Mat grayRnd_32f;
|
protected static Mat grayRnd_32f;
|
||||||
|
|
||||||
static Mat gray0_32f_1d;
|
protected static Mat gray0_32f_1d;
|
||||||
|
|
||||||
static Mat gray0_64f;
|
protected static Mat gray0_64f;
|
||||||
static Mat gray0_64f_1d;
|
protected static Mat gray0_64f_1d;
|
||||||
|
|
||||||
static Mat rgba0;
|
protected static Mat rgba0;
|
||||||
static Mat rgba128;
|
protected static Mat rgba128;
|
||||||
|
|
||||||
static Mat rgbLena;
|
protected static Mat rgbLena;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
@ -66,7 +66,7 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
gray128 = new Mat(matSize, matSize, CvType.CV_8U); gray128.setTo(new Scalar(128.0));
|
gray128 = new Mat(matSize, matSize, CvType.CV_8U); gray128.setTo(new Scalar(128.0));
|
||||||
gray255 = new Mat(matSize, matSize, CvType.CV_8U); gray255.setTo(new Scalar(255.0));
|
gray255 = new Mat(matSize, matSize, CvType.CV_8U); gray255.setTo(new Scalar(255.0));
|
||||||
|
|
||||||
gray256 = new Mat(matSize, matSize, CvType.CV_16U); gray255.setTo(new Scalar(256));
|
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U); gray255.setTo(new Scalar(256));
|
||||||
|
|
||||||
Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0));
|
Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0));
|
||||||
Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256));
|
Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256));
|
||||||
|
@ -3,8 +3,8 @@ package org.opencv.test;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.opencv.test.core;
|
||||||
|
|
||||||
|
import org.opencv.core.FileStorage;
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
public class FileStorageTest extends OpenCVTestCase {
|
||||||
|
|
||||||
|
private FileStorage fs;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
|
||||||
|
fs = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test_1() {
|
||||||
|
super.test_1("CORE.FileStorage");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileStorage() {
|
||||||
|
fs = new FileStorage();
|
||||||
|
assertTrue(null != fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileStorageLong() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileStorageStringInt() {
|
||||||
|
fs = new FileStorage("test.yml", FileStorage.WRITE);
|
||||||
|
assertTrue(null != fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFileStorageStringIntString() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsOpened() {
|
||||||
|
fs = new FileStorage();
|
||||||
|
assertFalse(fs.isOpened());
|
||||||
|
|
||||||
|
fs = new FileStorage("test.yml", FileStorage.WRITE);
|
||||||
|
assertTrue(fs.isOpened());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOpenStringInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOpenStringIntString() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRelease() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package org.opencv.test;
|
package org.opencv.test.core;
|
||||||
|
|
||||||
import org.opencv.CvType;
|
import org.opencv.CvType;
|
||||||
import org.opencv.Mat;
|
import org.opencv.Mat;
|
||||||
import org.opencv.Scalar;
|
import org.opencv.Scalar;
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
public class MatTest extends OpenCVTestCase {
|
public class MatTest extends OpenCVTestCase {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.opencv.test;
|
package org.opencv.test.core;
|
||||||
|
|
||||||
import org.opencv.CvType;
|
import org.opencv.CvType;
|
||||||
import org.opencv.Mat;
|
import org.opencv.Mat;
|
||||||
@ -6,6 +6,9 @@ import org.opencv.Point;
|
|||||||
import org.opencv.Scalar;
|
import org.opencv.Scalar;
|
||||||
import org.opencv.core;
|
import org.opencv.core;
|
||||||
|
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
import org.opencv.test.OpenCVTestRunner;
|
||||||
|
|
||||||
public class coreTest extends OpenCVTestCase {
|
public class coreTest extends OpenCVTestCase {
|
||||||
|
|
||||||
public void test_1() {
|
public void test_1() {
|
||||||
@ -177,7 +180,7 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
core.convertScaleAbs(gray0, dst);
|
core.convertScaleAbs(gray0, dst);
|
||||||
assertMatEqual(gray0, dst);
|
assertMatEqual(gray0, dst);
|
||||||
|
|
||||||
core.convertScaleAbs(gray256, dst);
|
core.convertScaleAbs(gray_16u_256, dst);
|
||||||
assertMatEqual(gray255, dst);
|
assertMatEqual(gray255, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,12 +188,12 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
core.convertScaleAbs(gray0, dst, 2);
|
core.convertScaleAbs(gray0, dst, 2);
|
||||||
assertMatEqual(gray0, dst);
|
assertMatEqual(gray0, dst);
|
||||||
|
|
||||||
core.convertScaleAbs(gray256, dst, 1);
|
core.convertScaleAbs(gray_16u_256, dst, 1);
|
||||||
assertMatEqual(gray255, dst);
|
assertMatEqual(gray255, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConvertScaleAbsMatMatDoubleDouble() {
|
public void testConvertScaleAbsMatMatDoubleDouble() {
|
||||||
core.convertScaleAbs(gray256, dst, 2, 2);
|
core.convertScaleAbs(gray_16u_256, dst, 2, 2);
|
||||||
assertMatEqual(gray255, dst);
|
assertMatEqual(gray255, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,6 +786,7 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSolvePolyMatMat() {
|
public void testSolvePolyMatMat() {
|
||||||
|
fail("Not yet implemented");
|
||||||
// Mat coeffs = new Mat(4, 1, CvType.CV_32F);
|
// Mat coeffs = new Mat(4, 1, CvType.CV_32F);
|
||||||
// Mat standart = new Mat(3, 1, CvType.CV_32F);
|
// Mat standart = new Mat(3, 1, CvType.CV_32F);
|
||||||
// Mat roots = new Mat(3, 1, CvType.CV_32F);
|
// Mat roots = new Mat(3, 1, CvType.CV_32F);
|
||||||
@ -803,7 +807,6 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
// core.sort(roots, roots, CV_SORT_EVERY_ROW);
|
// core.sort(roots, roots, CV_SORT_EVERY_ROW);
|
||||||
// assertTrue(1 == core.countNonZero(coeffs));
|
// assertTrue(1 == core.countNonZero(coeffs));
|
||||||
//assertMatEqual(roots, standart);
|
//assertMatEqual(roots, standart);
|
||||||
fail("Not yet implemented");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSolvePolyMatMatInt() {
|
public void testSolvePolyMatMatInt() {
|
||||||
@ -827,6 +830,7 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSortIdx() {
|
public void testSortIdx() {
|
||||||
|
fail("Not yet implemented");
|
||||||
// Mat matrix = new Mat(matSize, matSize, Mat.CvType.CV_8UC1);
|
// Mat matrix = new Mat(matSize, matSize, Mat.CvType.CV_8UC1);
|
||||||
// matrix.setTo(0);
|
// matrix.setTo(0);
|
||||||
// Mat submatrix = matrix.submat(0, matrix.rows() / 2, 0, matrix.cols() / 2);
|
// Mat submatrix = matrix.submat(0, matrix.rows() / 2, 0, matrix.cols() / 2);
|
@ -0,0 +1,8 @@
|
|||||||
|
package org.opencv.test.features2d;
|
||||||
|
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
|
||||||
|
public class features2dTest extends OpenCVTestCase {
|
||||||
|
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
package org.opencv.test;
|
|
||||||
|
|
||||||
|
|
||||||
public class features2dTest extends OpenCVTestCase {
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,136 @@
|
|||||||
|
package org.opencv.test.highgui;
|
||||||
|
|
||||||
|
import org.opencv.highgui;
|
||||||
|
import org.opencv.highgui.VideoCapture;
|
||||||
|
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
import org.opencv.test.OpenCVTestRunner;
|
||||||
|
|
||||||
|
|
||||||
|
public class VideoCaptureTest extends OpenCVTestCase {
|
||||||
|
|
||||||
|
private VideoCapture capture;
|
||||||
|
private boolean isSucceed;
|
||||||
|
private boolean isOpened;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
|
||||||
|
capture = null;
|
||||||
|
isSucceed = false;
|
||||||
|
isOpened = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test_1() {
|
||||||
|
super.test_1("HIGHGUI.VideoCapture");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGet() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
double frameWidth = capture.get(highgui.CV_CAP_PROP_FRAME_WIDTH);
|
||||||
|
capture.release();
|
||||||
|
assertTrue(0 != frameWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGrab() {
|
||||||
|
capture = new VideoCapture();
|
||||||
|
isSucceed = capture.grab();
|
||||||
|
assertFalse(isSucceed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGrabFromRealCamera() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
isSucceed = capture.grab();
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isSucceed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsOpened() {
|
||||||
|
capture = new VideoCapture();
|
||||||
|
assertFalse(capture.isOpened());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsOpenedRealCamera() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
isOpened = capture.isOpened();
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isOpened);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOpenInt() {
|
||||||
|
capture = new VideoCapture();
|
||||||
|
capture.open(highgui.CV_CAP_ANDROID);
|
||||||
|
isOpened = capture.isOpened();
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isOpened);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOpenString() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRead() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
isSucceed = capture.read(dst);
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isSucceed);
|
||||||
|
assertFalse(dst.empty());
|
||||||
|
assertEquals(3, dst.channels());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRelease() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
capture.release();
|
||||||
|
assertFalse(capture.isOpened());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRetrieveMat() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
capture.grab();
|
||||||
|
isSucceed = capture.retrieve(dst);
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isSucceed);
|
||||||
|
assertFalse(dst.empty());
|
||||||
|
assertEquals(3, dst.channels());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRetrieveMatInt() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
capture.grab();
|
||||||
|
isSucceed = capture.retrieve(dst, 1);
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isSucceed);
|
||||||
|
assertFalse(dst.empty());
|
||||||
|
OpenCVTestRunner.Log(dst.toString());
|
||||||
|
assertEquals(1, dst.channels());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSet() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
capture.set(highgui.CV_CAP_PROP_FRAME_WIDTH, 640.0);
|
||||||
|
double frameWidth = capture.get(highgui.CV_CAP_PROP_FRAME_WIDTH);
|
||||||
|
capture.read(dst);
|
||||||
|
capture.release();
|
||||||
|
assertEquals(640.0, frameWidth);
|
||||||
|
assertEquals(640, dst.cols());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVideoCapture() {
|
||||||
|
capture = new VideoCapture();
|
||||||
|
assertTrue(null != capture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVideoCaptureInt() {
|
||||||
|
capture = new VideoCapture(highgui.CV_CAP_ANDROID);
|
||||||
|
assertTrue(null != capture);
|
||||||
|
isOpened = capture.isOpened();
|
||||||
|
capture.release();
|
||||||
|
assertTrue(isOpened);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVideoCaptureString() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package org.opencv.test;
|
package org.opencv.test.highgui;
|
||||||
|
|
||||||
import org.opencv.highgui;
|
import org.opencv.highgui;
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
import org.opencv.test.OpenCVTestRunner;
|
||||||
|
|
||||||
|
|
||||||
public class highguiTest extends OpenCVTestCase {
|
public class highguiTest extends OpenCVTestCase {
|
@ -1,7 +1,8 @@
|
|||||||
package org.opencv.test;
|
package org.opencv.test.imgproc;
|
||||||
|
|
||||||
import org.opencv.Size;
|
import org.opencv.Size;
|
||||||
import org.opencv.imgproc;
|
import org.opencv.imgproc;
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
|
||||||
public class imgprocTest extends OpenCVTestCase {
|
public class imgprocTest extends OpenCVTestCase {
|
@ -0,0 +1,8 @@
|
|||||||
|
package org.opencv.test.objdetect;
|
||||||
|
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
|
||||||
|
public class objdetectTest extends OpenCVTestCase {
|
||||||
|
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
package org.opencv.test;
|
|
||||||
|
|
||||||
|
|
||||||
public class objdetectTest extends OpenCVTestCase {
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,6 @@
|
|||||||
package org.opencv.test;
|
package org.opencv.test.video;
|
||||||
|
|
||||||
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
|
||||||
public class videoTest extends OpenCVTestCase {
|
public class videoTest extends OpenCVTestCase {
|
Loading…
x
Reference in New Issue
Block a user