diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-08-11 16:46:47 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-08-11 18:49:36 +0800 |
commit | d2db70880e6159413932f747eb82df3e925852c1 (patch) | |
tree | e626a4edb7f69f5ae21b4191315779beb515c6bc /tests | |
parent | 142402d57c1689c1342d096c976b9b0826f8ce1a (diff) | |
download | LegacyCamera-d2db70880e6159413932f747eb82df3e925852c1.zip LegacyCamera-d2db70880e6159413932f747eb82df3e925852c1.tar.gz LegacyCamera-d2db70880e6159413932f747eb82df3e925852c1.tar.bz2 |
Use matrix to transform the location of faces.
bug:5141019
Change-Id: Id4bb82cee5fd788689fb18bb199504d963c5d3a2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/camera/unittest/CameraTest.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/src/com/android/camera/unittest/CameraTest.java b/tests/src/com/android/camera/unittest/CameraTest.java index b0aa13b..1e17635 100644 --- a/tests/src/com/android/camera/unittest/CameraTest.java +++ b/tests/src/com/android/camera/unittest/CameraTest.java @@ -17,8 +17,11 @@ package com.android.camera.unittest; import com.android.camera.Camera; +import com.android.camera.Util; +import android.graphics.Matrix; import android.graphics.Rect; +import android.graphics.RectF; import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; @@ -56,4 +59,40 @@ public class CameraTest extends TestCase { Camera.convertToFocusArea(860, 620, 100, 100, 960, 720, rect); assertEquals(new Rect(792, 722, 1000, 1000), rect); } + + public void testPrepareMatrix() { + Matrix matrix = new Matrix(); + float[] points; + int[] expected; + + Util.prepareMatrix(matrix, false, 0, 800, 480); + points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250}; + expected = new int[] {0, 0, 400, 240, 800, 480, 400, 480, 100, 300}; + matrix.mapPoints(points); + assertEquals(expected, points); + + Util.prepareMatrix(matrix, false, 90, 800, 480); + points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250}; + expected = new int[] {800, 0, 400, 240, 0, 480, 0, 240, 300, 60}; + matrix.mapPoints(points); + assertEquals(expected, points); + + Util.prepareMatrix(matrix, false, 180, 800, 480); + points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250}; + expected = new int[] {800, 480, 400, 240, 0, 0, 400, 0, 700, 180}; + matrix.mapPoints(points); + assertEquals(expected, points); + + Util.prepareMatrix(matrix, true, 180, 800, 480); + points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250}; + expected = new int[] {0, 480, 400, 240, 800, 0, 400, 0, 100, 180}; + matrix.mapPoints(points); + assertEquals(expected, points); + } + + private void assertEquals(int expected[], float[] actual) { + for (int i = 0; i < expected.length; i++) { + assertEquals("Array index " + i + " mismatch", expected[i], Math.round(actual[i])); + } + } } |