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
039fd554
Commit
039fd554
authored
Jul 27, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added several Android tests
parent
26bd6b3f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
115 deletions
+133
-115
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+116
-114
calib3dTest.java
...android_test/src/org/opencv/test/calib3d/calib3dTest.java
+0
-0
RectTest.java
.../java/android_test/src/org/opencv/test/core/RectTest.java
+17
-1
coreTest.java
.../java/android_test/src/org/opencv/test/core/coreTest.java
+0
-0
No files found.
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
039fd554
...
...
@@ -8,64 +8,63 @@ import org.opencv.core.Scalar;
import
org.opencv.core.Core
;
import
org.opencv.highgui.Highgui
;
public
class
OpenCVTestCase
extends
TestCase
{
protected
static
int
matSize
=
10
;
protected
static
double
EPS
=
0.001
;
protected
static
Mat
dst
;
protected
static
Mat
truth
;
//Naming notation: <channels info>_[depth]_[dimensions]_value
//
examples: gray0
- single channel 8U 2d Mat filled with 0
//
grayRnd - single channel 8U 2d Mat filled with random numbers
//
gray0_32f_1d
//
TODO: OpenCVTestCase refactorings
// - rename matrices
// - create some masks
// - use truth member everywhere
protected
static
Mat
gray0
;
protected
static
Mat
gray1
;
protected
static
Mat
gray2
;
protected
static
Mat
gray3
;
protected
static
Mat
gray9
;
protected
static
Mat
gray127
;
protected
static
Mat
gray128
;
protected
static
Mat
gray255
;
protected
static
Mat
grayRnd
;
protected
static
Mat
gray_16u_256
;
protected
static
Mat
gray_16s_1024
;
protected
static
Mat
gray0_32f
;
protected
static
Mat
gray1_32f
;
protected
static
Mat
gray3_32f
;
protected
static
Mat
gray9_32f
;
protected
static
Mat
gray255_32f
;
protected
static
Mat
grayE_32f
;
protected
static
Mat
grayRnd_32f
;
protected
static
Mat
gray0_32f_1d
;
protected
static
Mat
gray0_64f
;
protected
static
Mat
gray0_64f_1d
;
protected
static
Mat
rgba0
;
protected
static
Mat
rgba128
;
protected
static
Mat
rgbLena
;
protected
static
Mat
grayChess
;
protected
static
Mat
v1
;
protected
static
Mat
v2
;
protected
static
int
matSize
=
10
;
protected
static
double
EPS
=
0.001
;
protected
static
Mat
dst
;
protected
static
Mat
truth
;
//
Naming notation: <channels info>_[depth]_[dimensions]_value
//
examples: gray0
- single channel 8U 2d Mat filled with 0
// grayRnd - single channel 8U 2d Mat filled with random numbers
// gray0_32f_1d
//
TODO: OpenCVTestCase refactorings
// - rename matrices
// - create some masks
// - use truth member everywhere
protected
static
Mat
gray0
;
protected
static
Mat
gray1
;
protected
static
Mat
gray2
;
protected
static
Mat
gray3
;
protected
static
Mat
gray9
;
protected
static
Mat
gray127
;
protected
static
Mat
gray128
;
protected
static
Mat
gray255
;
protected
static
Mat
grayRnd
;
protected
static
Mat
gray_16u_256
;
protected
static
Mat
gray_16s_1024
;
protected
static
Mat
gray0_32f
;
protected
static
Mat
gray1_32f
;
protected
static
Mat
gray3_32f
;
protected
static
Mat
gray9_32f
;
protected
static
Mat
gray255_32f
;
protected
static
Mat
grayE_32f
;
protected
static
Mat
grayRnd_32f
;
protected
static
Mat
gray0_32f_1d
;
protected
static
Mat
gray0_64f
;
protected
static
Mat
gray0_64f_1d
;
protected
static
Mat
rgba0
;
protected
static
Mat
rgba128
;
protected
static
Mat
rgbLena
;
protected
static
Mat
grayChess
;
protected
static
Mat
v1
;
protected
static
Mat
v2
;
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
dst
=
new
Mat
();
assertTrue
(
dst
.
empty
());
truth
=
new
Mat
();
...
...
@@ -79,99 +78,102 @@ public class OpenCVTestCase extends TestCase {
gray127
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
127
));
gray128
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
128
));
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
));
Mat
low
=
new
Mat
(
1
,
1
,
CvType
.
CV_16UC1
,
new
Scalar
(
0
));
gray_16s_1024
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_16S
,
new
Scalar
(
1024
));
Mat
low
=
new
Mat
(
1
,
1
,
CvType
.
CV_16UC1
,
new
Scalar
(
0
));
Mat
high
=
new
Mat
(
1
,
1
,
CvType
.
CV_16UC1
,
new
Scalar
(
256
));
grayRnd
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
);
Core
.
randu
(
grayRnd
,
low
,
high
);
grayRnd
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
);
Core
.
randu
(
grayRnd
,
low
,
high
);
gray0_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
0.0
));
gray1_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
1.0
));
gray3_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
3.0
));
gray9_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
9.0
));
gray255_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
255.0
));
grayE_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
grayE_32f
=
Mat
.
eye
(
matSize
,
matSize
,
CvType
.
CV_32FC1
);
grayRnd_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
Core
.
randu
(
grayRnd_32f
,
low
,
high
);
gray255_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
255.0
));
grayE_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
grayE_32f
=
Mat
.
eye
(
matSize
,
matSize
,
CvType
.
CV_32FC1
);
grayRnd_32f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_32F
);
Core
.
randu
(
grayRnd_32f
,
low
,
high
);
gray0_32f_1d
=
new
Mat
(
1
,
matSize
,
CvType
.
CV_32F
,
new
Scalar
(
0.0
));
gray0_64f
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_64F
,
new
Scalar
(
0.0
));
gray0_64f_1d
=
new
Mat
(
1
,
matSize
,
CvType
.
CV_64F
,
new
Scalar
(
0.0
));
rgba0
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8UC4
,
Scalar
.
all
(
0
));
rgba128
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8UC4
,
Scalar
.
all
(
128
));
rgbLena
=
Highgui
.
imread
(
OpenCVTestRunner
.
LENA_PATH
);
grayChess
=
Highgui
.
imread
(
OpenCVTestRunner
.
CHESS_PATH
,
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
);
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
);
}
public
static
void
assertMatEqual
(
Mat
m1
,
Mat
m2
)
{
compareMats
(
m1
,
m2
,
true
);
compareMats
(
m1
,
m2
,
true
);
}
public
static
void
assertMatNotEqual
(
Mat
m1
,
Mat
m2
)
{
compareMats
(
m1
,
m2
,
false
);
compareMats
(
m1
,
m2
,
false
);
}
static
private
void
compareMats
(
Mat
m1
,
Mat
m2
,
boolean
isEqualityMeasured
)
{
//OpenCVTestRunner.Log(m1.toString());
//OpenCVTestRunner.Log(m2.toString());
if
(
m1
.
type
()
!=
m2
.
type
()
||
m1
.
cols
()
!=
m2
.
cols
()
||
m1
.
rows
()
!=
m2
.
rows
())
{
throw
new
UnsupportedOperationException
();
}
else
if
(
m1
.
channels
()
==
1
)
{
if
(
isEqualityMeasured
)
{
assertTrue
(
CalcPercentageOfDifference
(
m1
,
m2
)
==
0.0
);
}
else
{
assertTrue
(
CalcPercentageOfDifference
(
m1
,
m2
)
!=
0.0
);
}
}
else
{
for
(
int
coi
=
0
;
coi
<
m1
.
channels
();
coi
++)
{
Mat
m1c
=
getCOI
(
m1
,
coi
);
Mat
m2c
=
getCOI
(
m2
,
coi
);
if
(
isEqualityMeasured
)
{
assertTrue
(
CalcPercentageOfDifference
(
m1c
,
m2c
)
==
0.0
);
}
else
{
assertTrue
(
CalcPercentageOfDifference
(
m1c
,
m2c
)
!=
0.0
);
}
}
}
// OpenCVTestRunner.Log(m1.toString());
// OpenCVTestRunner.Log(m2.toString());
if
(
m1
.
type
()
!=
m2
.
type
()
||
m1
.
cols
()
!=
m2
.
cols
()
||
m1
.
rows
()
!=
m2
.
rows
())
{
throw
new
UnsupportedOperationException
();
}
else
if
(
m1
.
channels
()
==
1
)
{
if
(
isEqualityMeasured
)
{
assertTrue
(
CalcPercentageOfDifference
(
m1
,
m2
)
==
0.0
);
}
else
{
assertTrue
(
CalcPercentageOfDifference
(
m1
,
m2
)
!=
0.0
);
}
}
else
{
for
(
int
coi
=
0
;
coi
<
m1
.
channels
();
coi
++)
{
Mat
m1c
=
getCOI
(
m1
,
coi
);
Mat
m2c
=
getCOI
(
m2
,
coi
);
if
(
isEqualityMeasured
)
{
assertTrue
(
CalcPercentageOfDifference
(
m1c
,
m2c
)
==
0.0
);
}
else
{
assertTrue
(
CalcPercentageOfDifference
(
m1c
,
m2c
)
!=
0.0
);
}
}
}
}
static
private
Mat
getCOI
(
Mat
m
,
int
coi
)
{
Mat
ch
=
new
Mat
(
m
.
rows
(),
m
.
cols
(),
m
.
depth
());
for
(
int
i
=
0
;
i
<
m
.
rows
();
i
++)
for
(
int
j
=
0
;
j
<
m
.
cols
();
j
++)
{
double
pixel
[]
=
m
.
get
(
i
,
j
);
ch
.
put
(
i
,
j
,
pixel
[
coi
]);
}
return
ch
;
Mat
ch
=
new
Mat
(
m
.
rows
(),
m
.
cols
(),
m
.
depth
());
for
(
int
i
=
0
;
i
<
m
.
rows
();
i
++)
for
(
int
j
=
0
;
j
<
m
.
cols
();
j
++)
{
double
pixel
[]
=
m
.
get
(
i
,
j
);
ch
.
put
(
i
,
j
,
pixel
[
coi
]);
}
return
ch
;
}
static
private
double
CalcPercentageOfDifference
(
Mat
m1
,
Mat
m2
)
{
Mat
cmp
=
new
Mat
(
0
,
0
,
CvType
.
CV_8U
);
Core
.
compare
(
m1
,
m2
,
cmp
,
Core
.
CMP_EQ
);
double
difference
=
100.0
*
(
1.0
-
Double
.
valueOf
(
Core
.
countNonZero
(
cmp
))
/
Double
.
valueOf
(
cmp
.
rows
()
*
cmp
.
cols
()));
double
difference
=
100.0
*
(
1.0
-
Double
.
valueOf
(
Core
.
countNonZero
(
cmp
))
/
Double
.
valueOf
(
cmp
.
rows
()
*
cmp
.
cols
()));
return
difference
;
}
public
void
test_1
(
String
label
)
{
OpenCVTestRunner
.
Log
(
"================================================"
);
OpenCVTestRunner
.
Log
(
"=============== "
+
label
);
OpenCVTestRunner
.
Log
(
"================================================"
);
OpenCVTestRunner
.
Log
(
"=============== "
+
label
);
}
}
modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java
View file @
039fd554
This diff is collapsed.
Click to expand it.
modules/java/android_test/src/org/opencv/test/core/RectTest.java
View file @
039fd554
package
org
.
opencv
.
test
.
core
;
import
org.opencv.core.Point
;
import
org.opencv.core.Rect
;
import
org.opencv.test.OpenCVTestCase
;
public
class
RectTest
extends
OpenCVTestCase
{
...
...
@@ -21,7 +23,21 @@ public class RectTest extends OpenCVTestCase {
}
public
void
testContains
()
{
fail
(
"Not yet implemented"
);
Rect
r
=
new
Rect
(
0
,
0
,
10
,
10
);
Point
p_inner
=
new
Point
(
5
,
5
);
Point
p_outer
=
new
Point
(
5
,
55
);
Point
p_bl
=
new
Point
(
0
,
0
);
Point
p_br
=
new
Point
(
10
,
0
);
Point
p_tl
=
new
Point
(
0
,
10
);
Point
p_tr
=
new
Point
(
10
,
10
);
assertTrue
(
r
.
contains
(
p_inner
));
assertTrue
(
r
.
contains
(
p_bl
));
assertFalse
(
r
.
contains
(
p_outer
));
assertFalse
(
r
.
contains
(
p_br
));
assertFalse
(
r
.
contains
(
p_tl
));
assertFalse
(
r
.
contains
(
p_tr
));
}
public
void
testEqualsObject
()
{
...
...
modules/java/android_test/src/org/opencv/test/core/coreTest.java
View file @
039fd554
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