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
88ef8c99
Commit
88ef8c99
authored
Nov 24, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7709 from alalek:fix_java_tests
parents
12e0bc0f
0bdea2b7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
11 deletions
+109
-11
CoreTest.java
modules/core/misc/java/test/CoreTest.java
+1
-1
arithm_core.hpp
modules/core/src/arithm_core.hpp
+16
-0
ImgprocTest.java
modules/imgproc/misc/java/test/ImgprocTest.java
+3
-3
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+44
-3
build.xml
modules/java/pure_test/build.xml
+1
-1
OpenCVTestCase.java
...es/java/pure_test/src/org/opencv/test/OpenCVTestCase.java
+44
-3
No files found.
modules/core/misc/java/test/CoreTest.java
View file @
88ef8c99
...
@@ -1777,7 +1777,7 @@ public class CoreTest extends OpenCVTestCase {
...
@@ -1777,7 +1777,7 @@ public class CoreTest extends OpenCVTestCase {
};
};
Mat
roots
=
new
Mat
();
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
)
{
truth
=
new
Mat
(
3
,
1
,
CvType
.
CV_32FC2
)
{
{
{
...
...
modules/core/src/arithm_core.hpp
View file @
88ef8c99
...
@@ -97,6 +97,22 @@ template<typename T> struct OpAbsDiff
...
@@ -97,6 +97,22 @@ template<typename T> struct OpAbsDiff
T
operator
()(
T
a
,
T
b
)
const
{
return
a
>
b
?
a
-
b
:
b
-
a
;
}
T
operator
()(
T
a
,
T
b
)
const
{
return
a
>
b
?
a
-
b
:
b
-
a
;
}
};
};
// specializations to prevent "-0" results
template
<>
struct
OpAbsDiff
<
float
>
{
typedef
float
type1
;
typedef
float
type2
;
typedef
float
rtype
;
float
operator
()(
float
a
,
float
b
)
const
{
return
std
::
abs
(
a
-
b
);
}
};
template
<>
struct
OpAbsDiff
<
double
>
{
typedef
double
type1
;
typedef
double
type2
;
typedef
double
rtype
;
double
operator
()(
double
a
,
double
b
)
const
{
return
std
::
abs
(
a
-
b
);
}
};
template
<
typename
T
>
struct
OpAnd
template
<
typename
T
>
struct
OpAnd
{
{
typedef
T
type1
;
typedef
T
type1
;
...
...
modules/imgproc/misc/java/test/ImgprocTest.java
View file @
88ef8c99
...
@@ -359,7 +359,7 @@ public class ImgprocTest extends OpenCVTestCase {
...
@@ -359,7 +359,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
distance
=
Imgproc
.
compareHist
(
H1
,
H2
,
Imgproc
.
CV_COMP_CORREL
);
double
distance
=
Imgproc
.
compareHist
(
H1
,
H2
,
Imgproc
.
CV_COMP_CORREL
);
assertEquals
(
1
.,
distance
);
assertEquals
(
1
.,
distance
,
EPS
);
}
}
public
void
testContourAreaMat
()
{
public
void
testContourAreaMat
()
{
...
@@ -368,7 +368,7 @@ public class ImgprocTest extends OpenCVTestCase {
...
@@ -368,7 +368,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
area
=
Imgproc
.
contourArea
(
contour
);
double
area
=
Imgproc
.
contourArea
(
contour
);
assertEquals
(
45
.,
area
);
assertEquals
(
45
.,
area
,
EPS
);
}
}
public
void
testContourAreaMatBoolean
()
{
public
void
testContourAreaMatBoolean
()
{
...
@@ -377,7 +377,7 @@ public class ImgprocTest extends OpenCVTestCase {
...
@@ -377,7 +377,7 @@ public class ImgprocTest extends OpenCVTestCase {
double
area
=
Imgproc
.
contourArea
(
contour
,
true
);
double
area
=
Imgproc
.
contourArea
(
contour
,
true
);
assertEquals
(
45
.,
area
);
assertEquals
(
45
.,
area
,
EPS
);
// TODO_: write better test
// TODO_: write better test
}
}
...
...
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
88ef8c99
...
@@ -29,6 +29,11 @@ import static junit.framework.Assert.assertFalse;
...
@@ -29,6 +29,11 @@ import static junit.framework.Assert.assertFalse;
import
static
junit
.
framework
.
Assert
.
assertTrue
;
import
static
junit
.
framework
.
Assert
.
assertTrue
;
public
class
OpenCVTestCase
extends
TestCase
{
public
class
OpenCVTestCase
extends
TestCase
{
public
static
class
TestSkipException
extends
RuntimeException
{
public
TestSkipException
()
{}
}
//change to 'true' to unblock fail on fail("Not yet implemented")
//change to 'true' to unblock fail on fail("Not yet implemented")
public
static
final
boolean
passNYI
=
true
;
public
static
final
boolean
passNYI
=
true
;
...
@@ -188,12 +193,40 @@ public class OpenCVTestCase extends TestCase {
...
@@ -188,12 +193,40 @@ public class OpenCVTestCase extends TestCase {
protected
void
runTest
()
throws
Throwable
{
protected
void
runTest
()
throws
Throwable
{
// Do nothing if the precondition does not hold.
// Do nothing if the precondition does not hold.
if
(
isTestCaseEnabled
)
{
if
(
isTestCaseEnabled
)
{
super
.
runTest
();
try
{
super
.
runTest
();
}
catch
(
TestSkipException
ex
)
{
Log
.
w
(
TAG
,
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
}
}
else
{
}
else
{
Log
.
e
(
TAG
,
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" disabled!"
);
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
)
protected
Mat
getMat
(
int
type
,
double
...
vals
)
{
{
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
...
@@ -211,6 +244,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -211,6 +244,10 @@ public class OpenCVTestCase extends TestCase {
TestCase
.
fail
(
msg
);
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
)
{
public
static
<
E
extends
Number
>
void
assertListEquals
(
List
<
E
>
list1
,
List
<
E
>
list2
)
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
...
@@ -425,10 +462,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -425,10 +462,10 @@ public class OpenCVTestCase extends TestCase {
if
(
isEqualityMeasured
)
if
(
isEqualityMeasured
)
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
else
else
assertFalse
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that less than "
+
eps
,
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
)
{
protected
static
String
readFile
(
String
path
)
{
...
@@ -497,6 +534,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -497,6 +534,10 @@ public class OpenCVTestCase extends TestCase {
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
if
(
cname
.
startsWith
(
XFEATURES2D
))
{
throw
new
TestSkipException
();
}
message
=
TAG
+
" :: "
+
"could not instantiate "
+
cname
+
"! Exception: "
+
ex
.
getMessage
();
message
=
TAG
+
" :: "
+
"could not instantiate "
+
cname
+
"! Exception: "
+
ex
.
getMessage
();
}
}
...
...
modules/java/pure_test/build.xml
View file @
88ef8c99
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
<target
name=
"test"
>
<target
name=
"test"
>
<mkdir
dir=
"${test.dir}"
/>
<mkdir
dir=
"${test.dir}"
/>
<junit
printsummary=
"true"
haltonfailure=
"false"
haltonerror=
"false"
showoutput=
"
fals
e"
logfailedtests=
"true"
maxmemory=
"256m"
>
<junit
printsummary=
"true"
haltonfailure=
"false"
haltonerror=
"false"
showoutput=
"
tru
e"
logfailedtests=
"true"
maxmemory=
"256m"
>
<sysproperty
key=
"java.library.path"
path=
"${opencv.lib.path}"
/>
<sysproperty
key=
"java.library.path"
path=
"${opencv.lib.path}"
/>
<env
key=
"PATH"
path=
"${opencv.lib.path}"
/>
<env
key=
"PATH"
path=
"${opencv.lib.path}"
/>
<classpath
refid=
"master-classpath"
/>
<classpath
refid=
"master-classpath"
/>
...
...
modules/java/pure_test/src/org/opencv/test/OpenCVTestCase.java
View file @
88ef8c99
...
@@ -27,6 +27,11 @@ import org.opencv.core.KeyPoint;
...
@@ -27,6 +27,11 @@ import org.opencv.core.KeyPoint;
import
org.opencv.imgcodecs.Imgcodecs
;
import
org.opencv.imgcodecs.Imgcodecs
;
public
class
OpenCVTestCase
extends
TestCase
{
public
class
OpenCVTestCase
extends
TestCase
{
public
static
class
TestSkipException
extends
RuntimeException
{
public
TestSkipException
()
{}
}
//change to 'true' to unblock fail on fail("Not yet implemented")
//change to 'true' to unblock fail on fail("Not yet implemented")
public
static
final
boolean
passNYI
=
true
;
public
static
final
boolean
passNYI
=
true
;
...
@@ -214,12 +219,40 @@ public class OpenCVTestCase extends TestCase {
...
@@ -214,12 +219,40 @@ public class OpenCVTestCase extends TestCase {
protected
void
runTest
()
throws
Throwable
{
protected
void
runTest
()
throws
Throwable
{
// Do nothing if the precondition does not hold.
// Do nothing if the precondition does not hold.
if
(
isTestCaseEnabled
)
{
if
(
isTestCaseEnabled
)
{
super
.
runTest
();
try
{
super
.
runTest
();
}
catch
(
TestSkipException
ex
)
{
OpenCVTestRunner
.
Log
(
TAG
+
" :: "
+
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" skipped!"
);
assertTrue
(
true
);
}
}
else
{
}
else
{
OpenCVTestRunner
.
Log
(
TAG
+
" :: "
+
"Test case \""
+
this
.
getClass
().
getName
()
+
"\" disabled!"
);
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
)
protected
Mat
getMat
(
int
type
,
double
...
vals
)
{
{
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
return
new
Mat
(
matSize
,
matSize
,
type
,
new
Scalar
(
vals
));
...
@@ -237,6 +270,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -237,6 +270,10 @@ public class OpenCVTestCase extends TestCase {
TestCase
.
fail
(
msg
);
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
)
{
public
static
<
E
extends
Number
>
void
assertListEquals
(
List
<
E
>
list1
,
List
<
E
>
list2
)
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
...
@@ -451,10 +488,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -451,10 +488,10 @@ public class OpenCVTestCase extends TestCase {
if
(
isEqualityMeasured
)
if
(
isEqualityMeasured
)
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
assertTrue
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that bigger than "
+
eps
,
Core
.
checkRange
(
diff
,
true
,
0.0
,
eps
)
);
maxDiff
<=
eps
);
else
else
assertFalse
(
"Max difference between expected and actiual Mats is "
+
maxDiff
+
", that less than "
+
eps
,
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
)
{
protected
static
String
readFile
(
String
path
)
{
...
@@ -523,6 +560,10 @@ public class OpenCVTestCase extends TestCase {
...
@@ -523,6 +560,10 @@ public class OpenCVTestCase extends TestCase {
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
if
(
cname
.
startsWith
(
XFEATURES2D
))
{
throw
new
TestSkipException
();
}
message
=
TAG
+
" :: "
+
"could not instantiate "
+
cname
+
"! Exception: "
+
ex
.
getMessage
();
message
=
TAG
+
" :: "
+
"could not instantiate "
+
cname
+
"! Exception: "
+
ex
.
getMessage
();
}
}
...
...
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