Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
979b0ae9
Commit
979b0ae9
authored
Nov 24, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7711 from alalek:fix_java_tests_2.4
parents
408e4a7c
da75d129
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
20 deletions
+115
-20
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+40
-3
Calib3dTest.java
...android_test/src/org/opencv/test/calib3d/Calib3dTest.java
+16
-3
CoreTest.java
.../java/android_test/src/org/opencv/test/core/CoreTest.java
+1
-1
MatTest.java
...s/java/android_test/src/org/opencv/test/core/MatTest.java
+2
-2
ImgprocTest.java
...android_test/src/org/opencv/test/imgproc/ImgprocTest.java
+4
-4
build.xml
modules/java/test/build.xml
+12
-4
OpenCVTestCase.java
modules/java/test/src/org/opencv/test/OpenCVTestCase.java
+40
-3
No files found.
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
979b0ae9
...
...
@@ -26,6 +26,11 @@ import org.opencv.highgui.Highgui;
import
android.util.Log
;
public
class
OpenCVTestCase
extends
TestCase
{
public
static
class
TestSkipException
extends
RuntimeException
{
public
TestSkipException
()
{}
}
//change to 'true' to unblock fail on fail("Not yet implemented")
public
static
final
boolean
passNYI
=
true
;
...
...
@@ -182,12 +187,40 @@ public class OpenCVTestCase extends TestCase {
protected
void
runTest
()
throws
Throwable
{
// Do nothing if the precondition does not hold.
if
(
isTestCaseEnabled
)
{
super
.
runTest
();
try
{
super
.
runTest
();
}
catch
(
TestSkipException
ex
)
{
Log
.
w
(
TAG
,
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
}
}
else
{
Log
.
e
(
TAG
,
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" disabled!"
);
}
}
public
void
runBare
()
throws
Throwable
{
Throwable
exception
=
null
;
try
{
setUp
();
}
catch
(
TestSkipException
ex
)
{
Log
.
w
(
TAG
,
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
return
;
}
try
{
runTest
();
}
catch
(
Throwable
running
)
{
exception
=
running
;
}
finally
{
try
{
tearDown
();
}
catch
(
Throwable
tearingDown
)
{
if
(
exception
==
null
)
exception
=
tearingDown
;
}
}
if
(
exception
!=
null
)
throw
exception
;
}
protected
Mat
getMat
(
int
type
,
double
...
vals
)
{
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
...
...
@@ -205,6 +238,10 @@ public class OpenCVTestCase extends TestCase {
TestCase
.
fail
(
msg
);
}
public
static
void
assertGE
(
double
v1
,
double
v2
)
{
assertTrue
(
"Failed: "
+
v1
+
" >= "
+
v2
,
v1
>=
v2
);
}
public
static
<
E
extends
Number
>
void
assertListEquals
(
List
<
E
>
list1
,
List
<
E
>
list2
)
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
throw
new
UnsupportedOperationException
();
...
...
@@ -419,10 +456,10 @@ public class OpenCVTestCase extends TestCase {
if
(
isEqualityMeasured
)
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
else
assertFalse
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that less than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
}
protected
static
String
readFile
(
String
path
)
{
...
...
modules/java/android_test/src/org/opencv/test/calib3d/Calib3dTest.java
View file @
979b0ae9
...
...
@@ -249,9 +249,22 @@ public class Calib3dTest extends OpenCVTestCase {
Mat
fm
=
Calib3d
.
findFundamentalMat
(
pts
,
pts
);
truth
=
new
Mat
(
3
,
3
,
CvType
.
CV_64F
);
truth
.
put
(
0
,
0
,
0
,
-
0.577
,
0.288
,
0.577
,
0
,
0.288
,
-
0.288
,
-
0.288
,
0
);
assertMatEqual
(
truth
,
fm
,
EPS
);
// Check definition of fundamental matrix:
// [p2; 1]T * F * [p1; 1] = 0
// (p2 == p1 in this testcase)
for
(
int
i
=
0
;
i
<
pts
.
rows
();
i
++)
{
Mat
pt
=
new
Mat
(
3
,
1
,
fm
.
type
());
pt
.
put
(
0
,
0
,
pts
.
get
(
i
,
0
)[
0
],
pts
.
get
(
i
,
0
)[
1
],
1
);
Mat
pt_t
=
pt
.
t
();
Mat
tmp
=
new
Mat
();
Mat
res
=
new
Mat
();
Core
.
gemm
(
pt_t
,
fm
,
1.0
,
new
Mat
(),
0.0
,
tmp
);
Core
.
gemm
(
tmp
,
pt
,
1.0
,
new
Mat
(),
0.0
,
res
);
assertTrue
(
Math
.
abs
(
res
.
get
(
0
,
0
)[
0
])
<=
1
e
-
6
);
}
}
public
void
testFindFundamentalMatListOfPointListOfPointInt
()
{
...
...
modules/java/android_test/src/org/opencv/test/core/CoreTest.java
View file @
979b0ae9
...
...
@@ -2052,7 +2052,7 @@ public class CoreTest extends OpenCVTestCase {
};
Mat
roots
=
new
Mat
();
assert
Equals
(
0.0
,
Core
.
solvePoly
(
coeffs
,
roots
));
assert
GE
(
1
e
-
6
,
Math
.
abs
(
Core
.
solvePoly
(
coeffs
,
roots
)
));
truth
=
new
Mat
(
3
,
1
,
CvType
.
CV_32FC2
)
{
{
...
...
modules/java/android_test/src/org/opencv/test/core/MatTest.java
View file @
979b0ae9
...
...
@@ -488,13 +488,13 @@ public class MatTest extends OpenCVTestCase {
public
void
testIsContinuous
()
{
assertTrue
(
gray0
.
isContinuous
());
Mat
subMat
=
gray0
.
submat
(
0
,
0
,
gray0
.
rows
()
/
2
,
gray0
.
cols
()
/
2
);
Mat
subMat
=
gray0
.
submat
(
0
,
gray0
.
rows
()
/
2
,
0
,
gray0
.
cols
()
/
2
);
assertFalse
(
subMat
.
isContinuous
());
}
public
void
testIsSubmatrix
()
{
assertFalse
(
gray0
.
isSubmatrix
());
Mat
subMat
=
gray0
.
submat
(
0
,
0
,
gray0
.
rows
()
/
2
,
gray0
.
cols
()
/
2
);
Mat
subMat
=
gray0
.
submat
(
0
,
gray0
.
rows
()
/
2
,
0
,
gray0
.
cols
()
/
2
);
assertTrue
(
subMat
.
isSubmatrix
());
}
...
...
modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java
View file @
979b0ae9
...
...
@@ -165,7 +165,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
arcLength
=
Imgproc
.
arcLength
(
curve
,
false
);
assertEquals
(
5.656854152679443
,
arcLength
);
assertEquals
(
5.656854152679443
,
arcLength
,
EPS
);
}
public
void
testBilateralFilterMatMatIntDoubleDouble
()
{
...
...
@@ -367,7 +367,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
distance
=
Imgproc
.
compareHist
(
H1
,
H2
,
Imgproc
.
CV_COMP_CORREL
);
assertEquals
(
1
.,
distance
);
assertEquals
(
1
.,
distance
,
EPS
);
}
public
void
testContourAreaMat
()
{
...
...
@@ -376,7 +376,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
area
=
Imgproc
.
contourArea
(
contour
);
assertEquals
(
45
.,
area
);
assertEquals
(
45
.,
area
,
EPS
);
}
public
void
testContourAreaMatBoolean
()
{
...
...
@@ -385,7 +385,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
area
=
Imgproc
.
contourArea
(
contour
,
true
);
assertEquals
(
45
.,
area
);
assertEquals
(
45
.,
area
,
EPS
);
// TODO_: write better test
}
...
...
modules/java/test/build.xml
View file @
979b0ae9
<project>
<property
file=
"ant-${opencv.build.type}.properties"
/>
<property
name=
"test.dir"
value=
"testResults"
/>
<property
name=
"build.dir"
value=
"build"
/>
<path
id=
"master-classpath"
>
<fileset
dir=
"lib"
>
...
...
@@ -12,7 +14,7 @@
<target
name=
"clean"
>
<delete
dir=
"build"
/>
<delete
dir=
"
testResults
"
/>
<delete
dir=
"
${test.dir}
"
/>
</target>
<target
name=
"compile"
>
...
...
@@ -34,8 +36,8 @@
</target>
<target
name=
"test"
>
<mkdir
dir=
"
testResults
"
/>
<junit
printsummary=
"true"
haltonfailure=
"false"
haltonerror=
"false"
showoutput=
"
fals
e"
logfailedtests=
"true"
maxmemory=
"256m"
>
<mkdir
dir=
"
${test.dir}
"
/>
<junit
printsummary=
"true"
haltonfailure=
"false"
haltonerror=
"false"
showoutput=
"
tru
e"
logfailedtests=
"true"
maxmemory=
"256m"
>
<sysproperty
key=
"java.library.path"
path=
"${opencv.lib.path}"
/>
<env
key=
"PATH"
path=
"${opencv.lib.path}"
/>
<classpath
refid=
"master-classpath"
/>
...
...
@@ -45,12 +47,18 @@
<formatter
type=
"xml"
/>
<batchtest
fork=
"yes"
todir=
"
testResults
"
>
<batchtest
fork=
"yes"
todir=
"
${test.dir}
"
>
<zipfileset
src=
"build/jar/opencv-test.jar"
includes=
"**/*.class"
excludes=
"**/OpenCVTest*"
>
<exclude
name=
"**/*$*.class"
/>
</zipfileset>
</batchtest>
</junit>
<junitreport
todir=
"${test.dir}"
>
<fileset
dir=
"${test.dir}"
>
<include
name=
"TEST-*.xml"
/>
</fileset>
<report
format=
"noframes"
todir=
"${test.dir}"
/>
</junitreport>
</target>
<target
name=
"build"
>
...
...
modules/java/test/src/org/opencv/test/OpenCVTestCase.java
View file @
979b0ae9
...
...
@@ -28,6 +28,11 @@ import org.opencv.features2d.KeyPoint;
import
org.opencv.highgui.Highgui
;
public
class
OpenCVTestCase
extends
TestCase
{
public
static
class
TestSkipException
extends
RuntimeException
{
public
TestSkipException
()
{}
}
//change to 'true' to unblock fail on fail("Not yet implemented")
public
static
final
boolean
passNYI
=
true
;
...
...
@@ -212,12 +217,40 @@ public class OpenCVTestCase extends TestCase {
protected
void
runTest
()
throws
Throwable
{
// Do nothing if the precondition does not hold.
if
(
isTestCaseEnabled
)
{
super
.
runTest
();
try
{
super
.
runTest
();
}
catch
(
TestSkipException
ex
)
{
OpenCVTestRunner
.
Log
(
TAG
+
" :: "
+
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
}
}
else
{
OpenCVTestRunner
.
Log
(
TAG
+
" :: "
+
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" disabled!"
);
}
}
public
void
runBare
()
throws
Throwable
{
Throwable
exception
=
null
;
try
{
setUp
();
}
catch
(
TestSkipException
ex
)
{
OpenCVTestRunner
.
Log
(
TAG
+
" :: "
+
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
return
;
}
try
{
runTest
();
}
catch
(
Throwable
running
)
{
exception
=
running
;
}
finally
{
try
{
tearDown
();
}
catch
(
Throwable
tearingDown
)
{
if
(
exception
==
null
)
exception
=
tearingDown
;
}
}
if
(
exception
!=
null
)
throw
exception
;
}
protected
Mat
getMat
(
int
type
,
double
...
vals
)
{
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
...
...
@@ -235,6 +268,10 @@ public class OpenCVTestCase extends TestCase {
TestCase
.
fail
(
msg
);
}
public
static
void
assertGE
(
double
v1
,
double
v2
)
{
assertTrue
(
"Failed: "
+
v1
+
" >= "
+
v2
,
v1
>=
v2
);
}
public
static
<
E
extends
Number
>
void
assertListEquals
(
List
<
E
>
list1
,
List
<
E
>
list2
)
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
throw
new
UnsupportedOperationException
();
...
...
@@ -449,10 +486,10 @@ public class OpenCVTestCase extends TestCase {
if
(
isEqualityMeasured
)
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
else
assertFalse
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that less than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
}
protected
static
String
readFile
(
String
path
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment