提交 63f8feb2 编写于 作者: K Kirill Kornyakov

java tests: added a chessboard image

上级 7ca50b2b
...@@ -49,6 +49,7 @@ public class OpenCVTestCase extends TestCase { ...@@ -49,6 +49,7 @@ public class OpenCVTestCase extends TestCase {
protected static Mat rgba128; protected static Mat rgba128;
protected static Mat rgbLena; protected static Mat rgbLena;
protected static Mat grayChess;
protected static Mat v1; protected static Mat v1;
protected static Mat v2; protected static Mat v2;
...@@ -92,6 +93,7 @@ public class OpenCVTestCase extends TestCase { ...@@ -92,6 +93,7 @@ public class OpenCVTestCase extends TestCase {
rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128)); rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128));
rgbLena = highgui.imread(OpenCVTestRunner.LENA_PATH); rgbLena = highgui.imread(OpenCVTestRunner.LENA_PATH);
grayChess = highgui.imread(OpenCVTestRunner.CHESS_PATH);
v1 = new Mat(1, 3, CvType.CV_32F); v1.put(0, 0, 1.0, 3.0, 2.0); v1 = new Mat(1, 3, CvType.CV_32F); v1.put(0, 0, 1.0, 3.0, 2.0);
v2 = new Mat(1, 3, CvType.CV_32F); v2.put(0, 0, 2.0, 1.0, 3.0); v2 = new Mat(1, 3, CvType.CV_32F); v2.put(0, 0, 2.0, 1.0, 3.0);
......
...@@ -20,17 +20,19 @@ import android.util.Log; ...@@ -20,17 +20,19 @@ import android.util.Log;
public class OpenCVTestRunner extends InstrumentationTestRunner { public class OpenCVTestRunner extends InstrumentationTestRunner {
public static String LENA_PATH = "/data/data/org.opencv.test/files/lena.jpg"; public static String LENA_PATH = "/data/data/org.opencv.test/files/lena.jpg";
public static String CHESS_PATH = "/data/data/org.opencv.test/files/chessboard.jpg";
private AndroidTestRunner androidTestRunner;
private static String TAG = "opencv_test_java"; private static String TAG = "opencv_test_java";
private AndroidTestRunner androidTestRunner;
static public void Log(String message) { static public void Log(String message) {
Log.e(TAG, message); Log.e(TAG, message);
} }
@Override @Override
public void onStart() { public void onStart() {
ExportLena(); ExportResourceImage("lena.jpg", R.drawable.lena);
ExportResourceImage("chessboard.jpg", R.drawable.chessboard);
//List<TestCase> testCases = androidTestRunner.getTestCases(); //List<TestCase> testCases = androidTestRunner.getTestCases();
//Collections.shuffle(testCases); //shuffle the tests order //Collections.shuffle(testCases); //shuffle the tests order
...@@ -44,16 +46,16 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { ...@@ -44,16 +46,16 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
return androidTestRunner; return androidTestRunner;
} }
private void ExportLena() { private void ExportResourceImage(String image, int rId) {
try { try {
Bitmap mBitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.lena); Bitmap mBitmap = BitmapFactory.decodeResource(this.getContext().getResources(), rId);
FileOutputStream fos = this.getContext().openFileOutput("lena.jpg", Context.MODE_WORLD_READABLE); FileOutputStream fos = this.getContext().openFileOutput(image, Context.MODE_WORLD_READABLE);
mBitmap.compress(CompressFormat.JPEG, 100, fos); mBitmap.compress(CompressFormat.JPEG, 100, fos);
fos.flush(); fos.flush();
fos.close(); fos.close();
} }
catch (Exception e) { catch (Exception e) {
Log("Tried to write lena.jpg, but: " + e.toString()); Log("Tried to write " + image + ", but: " + e.toString());
} }
} }
} }
package org.opencv.test.calib3d; package org.opencv.test.calib3d;
import org.opencv.Size;
import org.opencv.calib3d;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class calib3dTest extends OpenCVTestCase { public class calib3dTest extends OpenCVTestCase {
...@@ -93,11 +96,13 @@ public class calib3dTest extends OpenCVTestCase { ...@@ -93,11 +96,13 @@ public class calib3dTest extends OpenCVTestCase {
} }
public void testFindChessboardCornersMatSizeMat() { public void testFindChessboardCornersMatSizeMat() {
fail("Not yet implemented"); Size patternSize = new Size(9, 6);
calib3d.findChessboardCorners(grayChess, patternSize, dst);
assertTrue(!dst.empty());
} }
public void testFindChessboardCornersMatSizeMatInt() { public void testFindChessboardCornersMatSizeMatInt() {
fail("Not yet implemented"); fail("Not yet implemented");//CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK
} }
public void testFindFundamentalMatMatMat() { public void testFindFundamentalMatMatMat() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册