some tests for highgui java added
This commit is contained in:
parent
5596c792bc
commit
1649c8f6d0
@ -1,14 +1,22 @@
|
||||
package org.opencv.test;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.opencv.Mat;
|
||||
import org.opencv.core;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.util.Log;
|
||||
|
||||
public class OpenCVTestCase extends AndroidTestCase {
|
||||
|
||||
static String TAG = "OpenCV_JavaAPI_Tests";
|
||||
static String LENA = "/data/data/org.opencv.test/files/lena.jpg";
|
||||
|
||||
static int matSize = 10;
|
||||
|
||||
static Mat gray0;
|
||||
@ -42,6 +50,11 @@ public class OpenCVTestCase extends AndroidTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
// Log.e(TAG, "setUp");
|
||||
super.setUp();
|
||||
|
||||
//Naming notation: channels_[type]_[dimension]_value
|
||||
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
||||
// grayRnd - single channel 8U 2d Mat filled with random numbers
|
||||
// gray0_32f_1d - refactor ;)
|
||||
|
||||
gray0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray0.setTo(0.0);
|
||||
gray1 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray1.setTo(1.0);
|
||||
@ -67,11 +80,22 @@ public class OpenCVTestCase extends AndroidTestCase {
|
||||
gray0_64f_1d = new Mat(1, matSize, Mat.CvType.CV_64FC1); gray0_64f_1d.setTo(0.0);
|
||||
|
||||
rgba0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba0.setTo(0, 0, 0, 0);
|
||||
rgba128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba128.setTo(128, 128, 128, 128);
|
||||
rgba128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba128.setTo(128, 128, 128, 128);
|
||||
|
||||
try {
|
||||
Bitmap mBitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.lena);
|
||||
FileOutputStream fos = this.getContext().openFileOutput("lena.jpg", Context.MODE_WORLD_READABLE);
|
||||
mBitmap.compress(CompressFormat.JPEG, 100, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "Tried to write lena.jpg, but: " + e.toString());
|
||||
}
|
||||
|
||||
dst_gray = new Mat(0, 0, Mat.CvType.CV_8UC1);
|
||||
dst_gray = new Mat();
|
||||
assertTrue(dst_gray.empty());
|
||||
dst_gray_32f = new Mat(0, 0, Mat.CvType.CV_32FC1);
|
||||
dst_gray_32f = new Mat();
|
||||
assertTrue(dst_gray_32f.empty());
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
public void testMahalanobis() {
|
||||
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1);
|
||||
Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1);
|
||||
core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL
|
||||
core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL instead of magic numbers
|
||||
covar.inv();
|
||||
|
||||
Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols());
|
||||
@ -110,7 +110,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1);
|
||||
Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1);
|
||||
|
||||
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL
|
||||
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL instead of magic numbers
|
||||
assertMatEqual(gray0_32f, covar);
|
||||
assertMatEqual(gray0_32f_1d, mean);
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_64FC1);
|
||||
Mat mean = new Mat(1, matSize, Mat.CvType.CV_64FC1);
|
||||
|
||||
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1); //FIXME: CV_COVAR_NORMAL
|
||||
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1); //FIXME: CV_COVAR_NORMAL instead of magic numbers
|
||||
assertMatEqual(gray0_64f, covar);
|
||||
assertMatEqual(gray0_64f_1d, mean);
|
||||
}
|
||||
@ -133,7 +133,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testCheckHardwareSupport() {
|
||||
boolean hasFeauture = core.checkHardwareSupport(0); //FIXME: do we need this function?
|
||||
//FIXME: do we need this function?
|
||||
boolean hasFeauture = core.checkHardwareSupport(0);
|
||||
assertEquals(false, hasFeauture);
|
||||
}
|
||||
|
||||
@ -414,7 +415,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testMulSpectrumsMatMatMatInt() {
|
||||
//TODO: complex math. See the dct function test.
|
||||
//TODO: nice example
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -498,7 +499,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testPerspectiveTransform() {
|
||||
//XXX: kirill stopped here
|
||||
//TODO: nice example
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -571,6 +572,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testSetUseOptimized() {
|
||||
//FIXME: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -627,6 +629,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testUseOptimized() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,92 @@
|
||||
package org.opencv.test;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.opencv.Mat;
|
||||
import org.opencv.highgui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class highguiTest extends OpenCVTestCase {
|
||||
|
||||
public void testDestroyAllWindows() {
|
||||
//XXX: do not export this function
|
||||
fail("Do not export this function");
|
||||
}
|
||||
|
||||
public void testDestroyWindow() {
|
||||
//XXX: do not export this function
|
||||
fail("Do not export this function");
|
||||
}
|
||||
|
||||
public void testGetTrackbarPos() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testGetWindowProperty() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testImdecode() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testImreadStringInt() {
|
||||
dst_gray = highgui.imread(LENA, 0);
|
||||
assertTrue(!dst_gray.empty());
|
||||
assertEquals(1, dst_gray.channels());
|
||||
}
|
||||
|
||||
public void testImreadString() {
|
||||
dst_gray = highgui.imread(LENA);
|
||||
assertTrue(!dst_gray.empty());
|
||||
assertEquals(3, dst_gray.channels());
|
||||
}
|
||||
|
||||
public void testImshow() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testNamedWindowStringInt() {
|
||||
//XXX: do not export this function
|
||||
fail("Do not export this function");
|
||||
}
|
||||
|
||||
public void testNamedWindowString() {
|
||||
//XXX: do not export this function
|
||||
fail("Do not export this function");
|
||||
}
|
||||
|
||||
public void testSetTrackbarPos() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testSetWindowProperty() {
|
||||
//XXX: do we need this function?
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testStartWindowThread() {
|
||||
fail("Not yet implemented");
|
||||
//XXX: do not export this function
|
||||
fail("Do not export this function");
|
||||
}
|
||||
|
||||
public void testWaitKeyInt() {
|
||||
//XXX: we need this function if only imshow will be implemented
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testWaitKey() {
|
||||
//XXX: we need this function if only imshow will be implemented
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user