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
edead9a2
Commit
edead9a2
authored
Jul 30, 2011
by
Kirill Kornyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
java tests: added some new asserts, and new tests by Hussein Abdinoor
parent
c11a7184
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
37 deletions
+41
-37
ConvertersTest.java
...java/android_test/src/org/opencv/test/ConvertersTest.java
+4
-1
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+25
-4
coreTest.java
.../java/android_test/src/org/opencv/test/core/coreTest.java
+9
-26
StarDetectorTest.java
...test/src/org/opencv/test/features2d/StarDetectorTest.java
+3
-6
imgprocTest.java
...android_test/src/org/opencv/test/imgproc/imgprocTest.java
+0
-0
No files found.
modules/java/android_test/src/org/opencv/test/ConvertersTest.java
View file @
edead9a2
package
org
.
opencv
.
test
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ConvertersTest
extends
OpenCVTestCase
{
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
}
public
void
testMat_to_vector_float
()
{
fail
(
"Not yet implemented"
);
}
...
...
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
edead9a2
package
org
.
opencv
.
test
;
import
java.util.List
;
import
junit.framework.TestCase
;
import
org.opencv.core.CvType
;
...
...
@@ -14,9 +16,12 @@ public class OpenCVTestCase extends TestCase {
protected
static
int
matSize
=
10
;
protected
static
double
EPS
=
0.001
;
protected
static
double
weakEPS
=
0.5
;
protected
static
Mat
dst
;
protected
static
Mat
truth
;
protected
static
Scalar
colorBlack
;
// Naming notation: <channels info>_[depth]_[dimensions]_value
// examples: gray0 - single channel 8U 2d Mat filled with 0
...
...
@@ -62,7 +67,7 @@ public class OpenCVTestCase extends TestCase {
protected
static
Mat
v1
;
protected
static
Mat
v2
;
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
...
...
@@ -71,6 +76,8 @@ public class OpenCVTestCase extends TestCase {
assertTrue
(
dst
.
empty
());
truth
=
new
Mat
();
assertTrue
(
truth
.
empty
());
colorBlack
=
new
Scalar
(
0
);
gray0
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
0
));
gray1
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
1
));
...
...
@@ -82,8 +89,7 @@ public class OpenCVTestCase extends TestCase {
gray255
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
gray_16u_256
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_16U
,
new
Scalar
(
256
));
gray_16s_1024
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_16S
,
new
Scalar
(
1024
));
gray_16s_1024
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_16S
,
new
Scalar
(
1024
));
grayRnd
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
);
Core
.
randu
(
grayRnd
,
new
Scalar
(
0
),
new
Scalar
(
256
));
...
...
@@ -150,7 +156,17 @@ public class OpenCVTestCase extends TestCase {
super
.
tearDown
();
}
public
static
void
assertListEqual
(
List
<
Float
>
list1
,
List
<
Float
>
list2
,
double
epsilon
)
{
if
(
list1
.
size
()
!=
list2
.
size
())
{
throw
new
UnsupportedOperationException
();
}
for
(
int
i
=
0
;
i
<
list1
.
size
();
i
++)
assertTrue
(
Math
.
abs
(
list1
.
get
(
i
)
-
list2
.
get
(
i
))
<=
epsilon
);
}
public
static
void
assertMatEqual
(
Mat
m1
,
Mat
m2
)
{
compareMats
(
m1
,
m2
,
true
);
}
...
...
@@ -175,6 +191,11 @@ public class OpenCVTestCase extends TestCase {
assertEquals
(
expected
.
octave
,
actual
.
octave
);
assertEquals
(
expected
.
class_id
,
actual
.
class_id
);
}
public
static
void
assertPointEquals
(
Point
expected
,
Point
actual
,
double
eps
){
assertEquals
(
expected
.
x
,
actual
.
x
,
eps
);
assertEquals
(
expected
.
y
,
actual
.
y
,
eps
);
}
static
private
void
compareMats
(
Mat
expected
,
Mat
actual
,
boolean
isEqualityMeasured
)
{
if
(
expected
.
type
()
!=
actual
.
type
()
||
expected
.
cols
()
!=
actual
.
cols
()
...
...
modules/java/android_test/src/org/opencv/test/core/coreTest.java
View file @
edead9a2
...
...
@@ -99,10 +99,8 @@ public class coreTest extends OpenCVTestCase {
Mat
covar
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_64FC1
);
Mat
mean
=
new
Mat
(
1
,
matSize
,
CvType
.
CV_64FC1
);
Core
.
calcCovarMatrix
(
gray0_32f
,
covar
,
mean
,
8
|
1
/*
* TODO:
* CV_COVAR_NORMAL
*/
);
Core
.
calcCovarMatrix
(
gray0_32f
,
covar
,
mean
,
Core
.
COVAR_ROWS
|
Core
.
COVAR_NORMAL
);
assertMatEqual
(
gray0_64f
,
covar
,
EPS
);
assertMatEqual
(
gray0_64f_1d
,
mean
,
EPS
);
}
...
...
@@ -111,10 +109,7 @@ public class coreTest extends OpenCVTestCase {
Mat
covar
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
Mat
mean
=
new
Mat
(
1
,
matSize
,
CvType
.
CV_32F
);
Core
.
calcCovarMatrix
(
gray0_32f
,
covar
,
mean
,
8
|
1
/*
* TODO:
* CV_COVAR_NORMAL
*/
,
CvType
.
CV_32F
);
Core
.
calcCovarMatrix
(
gray0_32f
,
covar
,
mean
,
Core
.
COVAR_ROWS
|
Core
.
COVAR_NORMAL
,
CvType
.
CV_32F
);
assertMatEqual
(
gray0_32f
,
covar
,
EPS
);
assertMatEqual
(
gray0_32f_1d
,
mean
,
EPS
);
}
...
...
@@ -744,11 +739,8 @@ public class coreTest extends OpenCVTestCase {
Core
.
invert
(
src
,
dst
);
assertMatEqual
(
truth
,
dst
,
EPS
);
// TODO: needs epsilon comparison
// Mat m = grayRnd_32f.clone();
// Mat inv = m.inv();
// Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst);
// assertMatEqual(grayE_32f, dst);
Core
.
gemm
(
grayRnd_32f
,
grayRnd_32f
.
inv
(),
1.0
,
new
Mat
(),
0.0
,
dst
);
assertMatEqual
(
grayE_32f
,
dst
,
EPS
);
}
public
void
testInvertMatMatInt
()
{
...
...
@@ -852,10 +844,7 @@ public class coreTest extends OpenCVTestCase {
public
void
testMahalanobis
()
{
Mat
covar
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
Mat
mean
=
new
Mat
(
1
,
matSize
,
CvType
.
CV_32F
);
Core
.
calcCovarMatrix
(
grayRnd_32f
,
covar
,
mean
,
8
|
1
/*
* TODO:
* CV_COVAR_NORMAL
*/
,
CvType
.
CV_32F
);
Core
.
calcCovarMatrix
(
grayRnd_32f
,
covar
,
mean
,
Core
.
COVAR_ROWS
|
Core
.
COVAR_NORMAL
,
CvType
.
CV_32F
);
covar
.
inv
();
Mat
line1
=
grayRnd_32f
.
submat
(
0
,
1
,
0
,
grayRnd_32f
.
cols
());
...
...
@@ -1222,18 +1211,12 @@ public class coreTest extends OpenCVTestCase {
Mat
xCoordinate
=
new
Mat
();
Mat
yCoordinate
=
new
Mat
();
// x.put(0, 0, 3.0, 6.0, 5,0);
// y.put(0, 0, 4.0, 8.0, 12.0);
// magnitude.put(0, 0, 5.0, 10.0, 13.0);
// angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
magnitude
.
put
(
0
,
0
,
5.0
,
10.0
,
13.0
);
angle
.
put
(
0
,
0
,
0.92729962
,
0.92729962
,
1.1759995
);
x
.
put
(
0
,
0
,
3.0
,
6.0
,
5
,
0
);
y
.
put
(
0
,
0
,
4.0
,
8.0
,
12.0
);
// TODO: needs epsilon comparison
Core
.
polarToCart
(
magnitude
,
angle
,
xCoordinate
,
yCoordinate
);
assertMatEqual
(
x
,
xCoordinate
,
EPS
);
}
...
...
@@ -1504,11 +1487,11 @@ public class coreTest extends OpenCVTestCase {
Mat
submat
=
gray0
.
submat
(
0
,
gray0
.
rows
()
/
2
,
0
,
gray0
.
cols
()
/
2
);
submat
.
setTo
(
new
Scalar
(
1.0
));
Core
.
sort
(
gray0
,
dst
,
0
/* TODO: CV_SORT_EVERY_ROW */
);
Core
.
sort
(
gray0
,
dst
,
Core
.
SORT_EVERY_ROW
);
submat
=
dst
.
submat
(
0
,
dst
.
rows
()
/
2
,
dst
.
cols
()
/
2
,
dst
.
cols
());
assertTrue
(
submat
.
total
()
==
Core
.
countNonZero
(
submat
));
Core
.
sort
(
gray0
,
dst
,
1
/* TODO: CV_SORT_EVERY_COLUMN */
);
Core
.
sort
(
gray0
,
dst
,
Core
.
SORT_EVERY_COLUMN
);
submat
=
dst
.
submat
(
dst
.
rows
()
/
2
,
dst
.
rows
(),
0
,
dst
.
cols
()
/
2
);
assertTrue
(
submat
.
total
()
==
Core
.
countNonZero
(
submat
));
}
...
...
@@ -1522,7 +1505,7 @@ public class coreTest extends OpenCVTestCase {
truth
.
put
(
1
,
0
,
0
,
2
,
1
);
truth
.
put
(
2
,
0
,
0
,
1
,
2
);
Core
.
sortIdx
(
a
,
b
,
0
+
0
/* TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING */
);
Core
.
sortIdx
(
a
,
b
,
Core
.
SORT_EVERY_ROW
+
Core
.
SORT_ASCENDING
);
assertMatEqual
(
truth
,
b
);
}
...
...
modules/java/android_test/src/org/opencv/test/features2d/StarDetectorTest.java
View file @
edead9a2
package
org
.
opencv
.
test
.
features2d
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.opencv.core.Core
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Point
;
import
org.opencv.core.RotatedRect
;
import
org.opencv.core.Scalar
;
import
org.opencv.core.Size
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.features2d.StarDetector
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
StarDetectorTest
extends
OpenCVTestCase
{
...
...
modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java
View file @
edead9a2
This diff is collapsed.
Click to expand it.
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