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
ebb08bc0
Commit
ebb08bc0
authored
Aug 10, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: Fixed bug in Mat port; fixed/implemented all java tests for core module
parent
04e4eaab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
217 additions
and
48 deletions
+217
-48
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+8
-1
CoreTest.java
.../java/android_test/src/org/opencv/test/core/CoreTest.java
+11
-12
MatTest.java
...s/java/android_test/src/org/opencv/test/core/MatTest.java
+164
-19
RotatedRectTest.java
...ndroid_test/src/org/opencv/test/core/RotatedRectTest.java
+19
-3
Mat.cpp
modules/java/src/cpp/Mat.cpp
+9
-9
core+Mat.java
modules/java/src/java/core+Mat.java
+6
-4
No files found.
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
ebb08bc0
...
@@ -18,6 +18,7 @@ import org.opencv.core.Point;
...
@@ -18,6 +18,7 @@ import org.opencv.core.Point;
import
org.opencv.core.Point3
;
import
org.opencv.core.Point3
;
import
org.opencv.core.Rect
;
import
org.opencv.core.Rect
;
import
org.opencv.core.Scalar
;
import
org.opencv.core.Scalar
;
import
org.opencv.core.Size
;
import
org.opencv.features2d.DMatch
;
import
org.opencv.features2d.DMatch
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.highgui.Highgui
;
import
org.opencv.highgui.Highgui
;
...
@@ -307,7 +308,13 @@ public class OpenCVTestCase extends TestCase {
...
@@ -307,7 +308,13 @@ public class OpenCVTestCase extends TestCase {
assertEquals
(
msg
,
expected
.
x
,
actual
.
x
,
eps
);
assertEquals
(
msg
,
expected
.
x
,
actual
.
x
,
eps
);
assertEquals
(
msg
,
expected
.
y
,
actual
.
y
,
eps
);
assertEquals
(
msg
,
expected
.
y
,
actual
.
y
,
eps
);
}
}
public
static
void
assertSizeEquals
(
Size
expected
,
Size
actual
,
double
eps
)
{
String
msg
=
"expected:<"
+
expected
+
"> but was:<"
+
actual
+
">"
;
assertEquals
(
msg
,
expected
.
width
,
actual
.
width
,
eps
);
assertEquals
(
msg
,
expected
.
height
,
actual
.
height
,
eps
);
}
public
static
void
assertPoint3Equals
(
Point3
expected
,
Point3
actual
,
double
eps
)
{
public
static
void
assertPoint3Equals
(
Point3
expected
,
Point3
actual
,
double
eps
)
{
String
msg
=
"expected:<"
+
expected
+
"> but was:<"
+
actual
+
">"
;
String
msg
=
"expected:<"
+
expected
+
"> but was:<"
+
actual
+
">"
;
assertEquals
(
msg
,
expected
.
x
,
actual
.
x
,
eps
);
assertEquals
(
msg
,
expected
.
x
,
actual
.
x
,
eps
);
...
...
modules/java/android_test/src/org/opencv/test/core/CoreTest.java
View file @
ebb08bc0
...
@@ -16,6 +16,7 @@ import org.opencv.core.Scalar;
...
@@ -16,6 +16,7 @@ import org.opencv.core.Scalar;
import
org.opencv.core.Size
;
import
org.opencv.core.Size
;
import
org.opencv.core.TermCriteria
;
import
org.opencv.core.TermCriteria
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
public
class
CoreTest
extends
OpenCVTestCase
{
public
class
CoreTest
extends
OpenCVTestCase
{
...
@@ -33,17 +34,11 @@ public class CoreTest extends OpenCVTestCase {
...
@@ -33,17 +34,11 @@ public class CoreTest extends OpenCVTestCase {
public
void
testAddMatMatMatMat
()
{
public
void
testAddMatMatMatMat
()
{
Mat
mask
=
makeMask
(
gray1
.
clone
());
Mat
mask
=
makeMask
(
gray1
.
clone
());
dst
=
gray127
.
clone
();
Core
.
add
(
gray127
,
gray1
,
dst
,
mask
);
Core
.
add
(
gray127
,
gray1
,
dst
,
mask
);
assertMatEqual
(
makeMask
(
gray128
,
127
),
dst
);
assertMatEqual
(
makeMask
(
gray128
,
127
),
dst
);
// FIXME: https://code.ros.org/trac/opencv/ticket/1286
/*
* dst is uninitialized => add allocates it 2) left half of mask is zeor
* => add do not assign it 3) so left part of dst remains uninitialized
* => filled with random junk values
*/
}
}
public
void
testAddMatMatMatMatInt
()
{
public
void
testAddMatMatMatMatInt
()
{
...
@@ -735,16 +730,19 @@ public class CoreTest extends OpenCVTestCase {
...
@@ -735,16 +730,19 @@ public class CoreTest extends OpenCVTestCase {
}
}
public
void
testFillConvexPolyMatListOfPointScalarIntInt
()
{
public
void
testFillConvexPolyMatListOfPointScalarIntInt
()
{
List
<
Point
>
polyline1
=
Arrays
.
asList
(
new
Point
(
1
,
1
),
new
Point
(
5
,
1
),
new
Point
(
5
,
8
),
new
Point
(
1
,
8
));
List
<
Point
>
polyline1
=
Arrays
.
asList
(
new
Point
(
2
,
1
),
new
Point
(
5
,
1
),
new
Point
(
5
,
7
),
new
Point
(
2
,
7
));
List
<
Point
>
polyline2
=
Arrays
.
asList
(
new
Point
(
2
,
2
),
new
Point
(
10
,
2
),
new
Point
(
10
,
16
),
new
Point
(
2
,
16
));
List
<
Point
>
polyline2
=
Arrays
.
asList
(
new
Point
(
4
,
2
),
new
Point
(
10
,
2
),
new
Point
(
10
,
14
),
new
Point
(
4
,
14
));
// FIXME: https://code.ros.org/trac/opencv/ticket/1284
// current implementation of fixed-point version of fillConvexPoly
// requires image to be at least 2-pixel wider in each direction than
// contour
Core
.
fillConvexPoly
(
gray0
,
polyline1
,
colorWhite
,
Core
.
LINE_8
,
0
);
Core
.
fillConvexPoly
(
gray0
,
polyline1
,
colorWhite
,
Core
.
LINE_8
,
0
);
assertTrue
(
0
<
Core
.
countNonZero
(
gray0
));
assertTrue
(
0
<
Core
.
countNonZero
(
gray0
));
assertTrue
(
gray0
.
total
()
>
Core
.
countNonZero
(
gray0
));
assertTrue
(
gray0
.
total
()
>
Core
.
countNonZero
(
gray0
));
Core
.
fillConvexPoly
(
gray0
,
polyline2
,
colorBlack
,
Core
.
LINE_8
,
1
);
Core
.
fillConvexPoly
(
gray0
,
polyline2
,
colorBlack
,
Core
.
LINE_8
,
1
);
OpenCVTestRunner
.
Log
(
gray0
);
assertEquals
(
"see https://code.ros.org/trac/opencv/ticket/1284"
,
0
,
Core
.
countNonZero
(
gray0
));
assertEquals
(
"see https://code.ros.org/trac/opencv/ticket/1284"
,
0
,
Core
.
countNonZero
(
gray0
));
}
}
...
@@ -1632,9 +1630,10 @@ public class CoreTest extends OpenCVTestCase {
...
@@ -1632,9 +1630,10 @@ public class CoreTest extends OpenCVTestCase {
put
(
0
,
0
,
1
,
0
,
0
,
0
,
1
);
put
(
0
,
0
,
1
,
0
,
0
,
0
,
1
);
}
}
};
};
dst
=
src
.
clone
();
Core
.
normalize
(
src
,
dst
,
1
,
2
,
Core
.
NORM_MINMAX
,
CvType
.
CV_32F
,
mask
);
Core
.
normalize
(
src
,
dst
,
1
,
2
,
Core
.
NORM_MINMAX
,
CvType
.
CV_32F
,
mask
);
// FIXME: https://code.ros.org/trac/opencv/ticket/1286
Mat
expected
=
new
Mat
(
1
,
5
,
CvType
.
CV_32F
)
{
Mat
expected
=
new
Mat
(
1
,
5
,
CvType
.
CV_32F
)
{
{
{
put
(
0
,
0
,
1
,
1
,
2
,
3
,
2
);
put
(
0
,
0
,
1
,
1
,
2
,
3
,
2
);
...
@@ -2356,11 +2355,11 @@ public class CoreTest extends OpenCVTestCase {
...
@@ -2356,11 +2355,11 @@ public class CoreTest extends OpenCVTestCase {
public
void
testSubtractMatMatMatMat
()
{
public
void
testSubtractMatMatMatMat
()
{
Mat
mask
=
makeMask
(
gray1
.
clone
());
Mat
mask
=
makeMask
(
gray1
.
clone
());
dst
=
gray128
.
clone
();
Core
.
subtract
(
gray128
,
gray1
,
dst
,
mask
);
Core
.
subtract
(
gray128
,
gray1
,
dst
,
mask
);
assertMatEqual
(
makeMask
(
gray127
,
128
),
dst
);
assertMatEqual
(
makeMask
(
gray127
,
128
),
dst
);
// FIXME: https://code.ros.org/trac/opencv/ticket/1286
}
}
public
void
testSubtractMatMatMatMatInt
()
{
public
void
testSubtractMatMatMatMatInt
()
{
...
...
modules/java/android_test/src/org/opencv/test/core/MatTest.java
View file @
ebb08bc0
...
@@ -4,6 +4,7 @@ import org.opencv.core.Core;
...
@@ -4,6 +4,7 @@ import org.opencv.core.Core;
import
org.opencv.core.CvException
;
import
org.opencv.core.CvException
;
import
org.opencv.core.CvType
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Point
;
import
org.opencv.core.Range
;
import
org.opencv.core.Range
;
import
org.opencv.core.Rect
;
import
org.opencv.core.Rect
;
import
org.opencv.core.Scalar
;
import
org.opencv.core.Scalar
;
...
@@ -15,19 +16,38 @@ import java.util.Arrays;
...
@@ -15,19 +16,38 @@ import java.util.Arrays;
public
class
MatTest
extends
OpenCVTestCase
{
public
class
MatTest
extends
OpenCVTestCase
{
public
void
testAdjustROI
()
{
public
void
testAdjustROI
()
{
fail
(
"Not yet implemented"
);
Mat
roi
=
gray0
.
submat
(
3
,
5
,
7
,
10
);
Mat
originalroi
=
roi
.
clone
();
Mat
adjusted
=
roi
.
adjustROI
(
2
,
2
,
2
,
2
);
assertMatEqual
(
adjusted
,
roi
);
assertSizeEquals
(
new
Size
(
5
,
6
),
adjusted
.
size
(),
EPS
);
assertEquals
(
originalroi
.
type
(),
adjusted
.
type
());
assertTrue
(
adjusted
.
isSubmatrix
());
assertFalse
(
adjusted
.
isContinuous
());
Point
offset
=
new
Point
();
Size
size
=
new
Size
();
adjusted
.
locateROI
(
size
,
offset
);
assertPointEquals
(
new
Point
(
5
,
1
),
offset
,
EPS
);
assertSizeEquals
(
gray0
.
size
(),
size
,
EPS
);
}
}
public
void
testAssignToMat
()
{
public
void
testAssignToMat
()
{
gray0
.
assignTo
(
dst
);
gray0
.
assignTo
(
dst
);
assertMatEqual
(
gray0
,
dst
);
assertMatEqual
(
gray0
,
dst
);
gray255
.
assignTo
(
dst
);
gray255
.
assignTo
(
dst
);
assertMatEqual
(
gray255
,
dst
);
assertMatEqual
(
gray255
,
dst
);
}
}
public
void
testAssignToMatInt
()
{
public
void
testAssignToMatInt
()
{
fail
(
"Not yet implemented"
);
gray255
.
assignTo
(
dst
,
CvType
.
CV_32F
);
assertMatEqual
(
gray255_32f
,
dst
,
EPS
);
}
}
public
void
testChannels
()
{
public
void
testChannels
()
{
...
@@ -39,15 +59,36 @@ public class MatTest extends OpenCVTestCase {
...
@@ -39,15 +59,36 @@ public class MatTest extends OpenCVTestCase {
public
void
testCheckVectorInt
()
{
public
void
testCheckVectorInt
()
{
// ! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel
// ! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel
// (1 x N) or (N x 1); negative number otherwise
// (1 x N) or (N x 1); negative number otherwise
fail
(
"Not yet implemented"
);
assertEquals
(
2
,
new
Mat
(
2
,
10
,
CvType
.
CV_8U
).
checkVector
(
10
));
assertEquals
(
2
,
new
Mat
(
1
,
2
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
));
assertEquals
(
2
,
new
Mat
(
2
,
1
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
));
assertEquals
(
2
,
new
Mat
(
1
,
10
,
CvType
.
CV_8UC2
).
checkVector
(
10
));
assertTrue
(
0
>
new
Mat
().
checkVector
(
0
));
assertTrue
(
0
>
new
Mat
(
10
,
1
,
CvType
.
CV_8U
).
checkVector
(
10
));
assertTrue
(
0
>
new
Mat
(
10
,
20
,
CvType
.
CV_8U
).
checkVector
(
10
));
}
}
public
void
testCheckVectorIntInt
()
{
public
void
testCheckVectorIntInt
()
{
fail
(
"Not yet implemented"
);
assertEquals
(
2
,
new
Mat
(
2
,
10
,
CvType
.
CV_8U
).
checkVector
(
10
,
CvType
.
CV_8U
));
assertEquals
(
2
,
new
Mat
(
1
,
2
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
,
CvType
.
CV_8U
));
assertEquals
(
2
,
new
Mat
(
2
,
1
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
,
CvType
.
CV_8U
));
assertEquals
(
2
,
new
Mat
(
1
,
10
,
CvType
.
CV_8UC2
).
checkVector
(
10
,
CvType
.
CV_8U
));
assertTrue
(
0
>
new
Mat
(
2
,
10
,
CvType
.
CV_8U
).
checkVector
(
10
,
CvType
.
CV_8S
));
assertTrue
(
0
>
new
Mat
(
1
,
2
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
,
CvType
.
CV_8S
));
assertTrue
(
0
>
new
Mat
(
2
,
1
,
CvType
.
CV_8UC
(
10
)).
checkVector
(
10
,
CvType
.
CV_8S
));
assertTrue
(
0
>
new
Mat
(
1
,
10
,
CvType
.
CV_8UC2
).
checkVector
(
10
,
CvType
.
CV_8S
));
}
}
public
void
testCheckVectorIntIntBoolean
()
{
public
void
testCheckVectorIntIntBoolean
()
{
fail
(
"Not yet implemented"
);
Mat
mm
=
new
Mat
(
5
,
1
,
CvType
.
CV_8UC
(
10
));
Mat
roi
=
new
Mat
(
5
,
3
,
CvType
.
CV_8UC
(
10
)).
submat
(
1
,
3
,
2
,
3
);
assertEquals
(
5
,
mm
.
checkVector
(
10
,
CvType
.
CV_8U
,
true
));
assertEquals
(
5
,
mm
.
checkVector
(
10
,
CvType
.
CV_8U
,
false
));
assertEquals
(
2
,
roi
.
checkVector
(
10
,
CvType
.
CV_8U
,
false
));
assertTrue
(
0
>
roi
.
checkVector
(
10
,
CvType
.
CV_8U
,
true
));
}
}
public
void
testClone
()
{
public
void
testClone
()
{
...
@@ -202,7 +243,7 @@ public class MatTest extends OpenCVTestCase {
...
@@ -202,7 +243,7 @@ public class MatTest extends OpenCVTestCase {
public
void
testElemSize
()
{
public
void
testElemSize
()
{
assertEquals
(
Byte
.
SIZE
/
8
*
gray0
.
channels
(),
gray0
.
elemSize
());
assertEquals
(
Byte
.
SIZE
/
8
*
gray0
.
channels
(),
gray0
.
elemSize
());
assertEquals
(
Double
.
SIZE
/
8
*
gray0_32f
.
channels
(),
gray0_32f
.
elemSize
());
assertEquals
(
Float
.
SIZE
/
8
*
gray0_32f
.
channels
(),
gray0_32f
.
elemSize
());
assertEquals
(
Byte
.
SIZE
/
8
*
rgbLena
.
channels
(),
rgbLena
.
elemSize
());
assertEquals
(
Byte
.
SIZE
/
8
*
rgbLena
.
channels
(),
rgbLena
.
elemSize
());
}
}
...
@@ -303,9 +344,27 @@ public class MatTest extends OpenCVTestCase {
...
@@ -303,9 +344,27 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testInvInt
()
{
public
void
testInvInt
()
{
fail
(
"Not yet implemented"
);
Mat
src
=
new
Mat
(
2
,
2
,
CvType
.
CV_32F
)
{
dst
=
gray0_32f
.
inv
(
Core
.
DECOMP_CHOLESKY
);
{
assertMatEqual
(
gray0_32f
,
dst
,
EPS
);
put
(
0
,
0
,
1.0
);
put
(
0
,
1
,
2.0
);
put
(
1
,
0
,
1.5
);
put
(
1
,
1
,
4.0
);
}
};
dst
=
src
.
inv
(
Core
.
DECOMP_CHOLESKY
);
truth
=
new
Mat
(
2
,
2
,
CvType
.
CV_32F
)
{
{
put
(
0
,
0
,
4.0
);
put
(
0
,
1
,
-
2.0
);
put
(
1
,
0
,
-
1.5
);
put
(
1
,
1
,
1.0
);
}
};
assertMatEqual
(
truth
,
dst
,
EPS
);
}
}
public
void
testIsContinuous
()
{
public
void
testIsContinuous
()
{
...
@@ -322,7 +381,14 @@ public class MatTest extends OpenCVTestCase {
...
@@ -322,7 +381,14 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testLocateROI
()
{
public
void
testLocateROI
()
{
fail
(
"Not yet implemented"
);
Mat
roi
=
gray0
.
submat
(
3
,
5
,
7
,
10
);
Point
offset
=
new
Point
();
Size
size
=
new
Size
();
roi
.
locateROI
(
size
,
offset
);
assertPointEquals
(
new
Point
(
7
,
3
),
offset
,
EPS
);
assertSizeEquals
(
new
Size
(
10
,
10
),
size
,
EPS
);
}
}
public
void
testMat
()
{
public
void
testMat
()
{
...
@@ -462,7 +528,17 @@ public class MatTest extends OpenCVTestCase {
...
@@ -462,7 +528,17 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testPutIntIntByteArray
()
{
public
void
testPutIntIntByteArray
()
{
fail
(
"Not yet implemented"
);
Mat
m
=
new
Mat
(
5
,
5
,
CvType
.
CV_8UC3
);
byte
[]
bytes
=
new
byte
[]
{
10
,
20
,
30
,
40
,
50
,
60
};
m
.
put
(
1
,
1
,
bytes
);
try
{
byte
[]
bytes2
=
new
byte
[]
{
10
,
20
,
30
,
40
,
50
};
m
.
put
(
2
,
2
,
bytes2
);
fail
(
"Expected UnsupportedOperationException (data.length % CvType.channels(t) != 0)"
);
}
catch
(
UnsupportedOperationException
e
)
{
// expected
}
}
}
public
void
testPutIntIntDoubleArray
()
{
public
void
testPutIntIntDoubleArray
()
{
...
@@ -478,15 +554,45 @@ public class MatTest extends OpenCVTestCase {
...
@@ -478,15 +554,45 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testPutIntIntFloatArray
()
{
public
void
testPutIntIntFloatArray
()
{
fail
(
"Not yet implemented"
);
Mat
m
=
new
Mat
(
5
,
5
,
CvType
.
CV_32FC3
);
float
[]
elements
=
new
float
[]
{
10
,
20
,
30
,
40
,
50
,
60
};
m
.
put
(
1
,
1
,
elements
);
try
{
float
[]
elements2
=
new
float
[]
{
10
,
20
,
30
,
40
,
50
};
m
.
put
(
2
,
2
,
elements2
);
fail
(
"Expected UnsupportedOperationException (data.length % CvType.channels(t) != 0)"
);
}
catch
(
UnsupportedOperationException
e
)
{
// expected
}
}
}
public
void
testPutIntIntIntArray
()
{
public
void
testPutIntIntIntArray
()
{
fail
(
"Not yet implemented"
);
Mat
m
=
new
Mat
(
5
,
5
,
CvType
.
CV_32SC3
);
int
[]
elements
=
new
int
[]
{
10
,
20
,
30
,
40
,
50
,
60
};
m
.
put
(
1
,
1
,
elements
);
try
{
int
[]
elements2
=
new
int
[]
{
10
,
20
,
30
,
40
,
50
};
m
.
put
(
2
,
2
,
elements2
);
fail
(
"Expected UnsupportedOperationException (data.length % CvType.channels(t) != 0)"
);
}
catch
(
UnsupportedOperationException
e
)
{
// expected
}
}
}
public
void
testPutIntIntShortArray
()
{
public
void
testPutIntIntShortArray
()
{
fail
(
"Not yet implemented"
);
Mat
m
=
new
Mat
(
5
,
5
,
CvType
.
CV_16SC3
);
short
[]
elements
=
new
short
[]
{
10
,
20
,
30
,
40
,
50
,
60
};
m
.
put
(
1
,
1
,
elements
);
try
{
short
[]
elements2
=
new
short
[]
{
10
,
20
,
30
,
40
,
50
};
m
.
put
(
2
,
2
,
elements2
);
fail
(
"Expected UnsupportedOperationException (data.length % CvType.channels(t) != 0)"
);
}
catch
(
UnsupportedOperationException
e
)
{
// expected
}
}
}
public
void
testRelease
()
{
public
void
testRelease
()
{
...
@@ -523,7 +629,6 @@ public class MatTest extends OpenCVTestCase {
...
@@ -523,7 +629,6 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testRowRangeIntInt
()
{
public
void
testRowRangeIntInt
()
{
fail
(
"Not yet implemented"
);
Mat
rows
=
gray0
.
rowRange
(
0
,
gray0
.
rows
()
/
2
);
Mat
rows
=
gray0
.
rowRange
(
0
,
gray0
.
rows
()
/
2
);
assertEquals
(
gray0
.
rows
()
/
2
,
rows
.
rows
());
assertEquals
(
gray0
.
rows
()
/
2
,
rows
.
rows
());
assertEquals
(
gray0
.
cols
(),
rows
.
cols
());
assertEquals
(
gray0
.
cols
(),
rows
.
cols
());
...
@@ -541,11 +646,45 @@ public class MatTest extends OpenCVTestCase {
...
@@ -541,11 +646,45 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testSetToMat
()
{
public
void
testSetToMat
()
{
fail
(
"Not yet implemented"
);
Mat
vals
=
new
Mat
(
7
,
1
,
CvType
.
CV_8U
)
{
{
put
(
0
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
}
};
Mat
dst
=
new
Mat
(
1
,
1
,
CvType
.
CV_8UC
(
7
));
dst
.
setTo
(
vals
);
Mat
truth
=
new
Mat
(
1
,
1
,
CvType
.
CV_8UC
(
7
))
{
{
put
(
0
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
}
};
assertMatEqual
(
truth
,
dst
);
}
}
public
void
testSetToMatMat
()
{
public
void
testSetToMatMat
()
{
fail
(
"Not yet implemented"
);
Mat
vals
=
new
Mat
(
7
,
1
,
CvType
.
CV_8U
)
{
{
put
(
0
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
}
};
Mat
dst
=
Mat
.
zeros
(
2
,
1
,
CvType
.
CV_8UC
(
7
));
Mat
mask
=
new
Mat
(
2
,
1
,
CvType
.
CV_8U
)
{
{
put
(
0
,
0
,
0
,
1
);
}
};
dst
.
setTo
(
vals
,
mask
);
Mat
truth
=
new
Mat
(
2
,
1
,
CvType
.
CV_8UC
(
7
))
{
{
put
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
put
(
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
);
}
};
assertMatEqual
(
truth
,
dst
);
}
}
public
void
testSetToScalar
()
{
public
void
testSetToScalar
()
{
...
@@ -560,13 +699,19 @@ public class MatTest extends OpenCVTestCase {
...
@@ -560,13 +699,19 @@ public class MatTest extends OpenCVTestCase {
}
}
public
void
testStep1
()
{
public
void
testStep1
()
{
assertEquals
(
10
,
gray0
.
step1
());
assertEquals
(
matSize
*
CvType
.
channels
(
CvType
.
CV_8U
)
,
gray0
.
step1
());
assertEquals
(
3
,
v2
.
step1
());
assertEquals
(
3
,
v2
.
step1
());
}
}
public
void
testStep1Int
()
{
public
void
testStep1Int
()
{
fail
(
"Not yet implemented"
);
Mat
roi
=
rgba0
.
submat
(
3
,
5
,
7
,
10
);
Mat
m
=
roi
.
clone
();
assertEquals
(
rgba0
.
channels
()
*
rgba0
.
cols
(),
roi
.
step1
(
0
));
assertEquals
(
rgba0
.
channels
(),
roi
.
step1
(
1
));
assertEquals
(
rgba0
.
channels
()
*
(
10
-
7
),
m
.
step1
(
0
));
assertEquals
(
rgba0
.
channels
(),
m
.
step1
(
1
));
}
}
public
void
testSubmatIntIntIntInt
()
{
public
void
testSubmatIntIntIntInt
()
{
...
...
modules/java/android_test/src/org/opencv/test/core/RotatedRectTest.java
View file @
ebb08bc0
...
@@ -163,11 +163,27 @@ public class RotatedRectTest extends OpenCVTestCase {
...
@@ -163,11 +163,27 @@ public class RotatedRectTest extends OpenCVTestCase {
}
}
public
void
testSet
()
{
public
void
testSet
()
{
fail
(
"Not yet implemented"
);
double
[]
vals1
=
{};
RotatedRect
r1
=
new
RotatedRect
(
center
,
size
,
40
);
r1
.
set
(
vals1
);
assertEquals
(
0
.,
r1
.
angle
);
assertPointEquals
(
new
Point
(
0
,
0
),
r1
.
center
,
EPS
);
assertSizeEquals
(
new
Size
(
0
,
0
),
r1
.
size
,
EPS
);
double
[]
vals2
=
{
1
,
2
,
3
,
4
,
5
};
RotatedRect
r2
=
new
RotatedRect
(
center
,
size
,
40
);
r2
.
set
(
vals2
);
assertEquals
(
5
.,
r2
.
angle
);
assertPointEquals
(
new
Point
(
1
,
2
),
r2
.
center
,
EPS
);
assertSizeEquals
(
new
Size
(
3
,
4
),
r2
.
size
,
EPS
);
}
}
public
void
testToString
()
{
public
void
testToString
()
{
String
actual
=
new
RotatedRect
(
new
Point
(
1
,
2
),
new
Size
(
10
,
12
),
4.5
).
toString
();
String
actual
=
new
RotatedRect
(
new
Point
(
1
,
2
),
new
Size
(
10
,
12
),
4.5
).
toString
();
String
expected
=
"{ {1.0, 2.0} 10x12 * 4.5 }"
;
String
expected
=
"{ {1.0, 2.0} 10x12 * 4.5 }"
;
assertEquals
(
expected
,
actual
);
assertEquals
(
expected
,
actual
);
}
}
...
...
modules/java/src/cpp/Mat.cpp
View file @
ebb08bc0
...
@@ -1174,27 +1174,27 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix
...
@@ -1174,27 +1174,27 @@ JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix
//
//
JNIEXPORT
void
JNICALL
Java_org_opencv_core_Mat_
n_1locateROI
JNIEXPORT
void
JNICALL
Java_org_opencv_core_Mat_
locateROI_10
(
JNIEnv
*
env
,
jclass
cls
,
jlong
self
,
jdouble
wholeSize_width
,
jdouble
wholeSize_height
,
jdouble
ofs_x
,
jdouble
ofs_y
)
(
JNIEnv
*
env
,
jclass
cls
,
jlong
self
,
jdouble
Array
wholeSize_out
,
jdoubleArray
ofs_out
)
{
{
try
{
try
{
LOGD
(
"
Mat::n_1locateROI
()"
);
LOGD
(
"
core::locateROI_10
()"
);
Mat
*
me
=
(
Mat
*
)
self
;
//TODO: check for NULL
Mat
*
me
=
(
Mat
*
)
self
;
//TODO: check for NULL
Size
wholeSize
((
int
)
wholeSize_width
,
(
int
)
wholeSize_height
)
;
Size
wholeSize
;
Point
ofs
((
int
)
ofs_x
,
(
int
)
ofs_y
)
;
Point
ofs
;
me
->
locateROI
(
wholeSize
,
ofs
);
me
->
locateROI
(
wholeSize
,
ofs
);
jdouble
tmp_wholeSize
[
2
]
=
{
wholeSize
.
width
,
wholeSize
.
height
};
env
->
SetDoubleArrayRegion
(
wholeSize_out
,
0
,
2
,
tmp_wholeSize
);
jdouble
tmp_ofs
[
2
]
=
{
ofs
.
x
,
ofs
.
y
};
env
->
SetDoubleArrayRegion
(
ofs_out
,
0
,
2
,
tmp_ofs
);
return
;
return
;
}
catch
(
cv
::
Exception
e
)
{
}
catch
(
cv
::
Exception
e
)
{
LOGD
(
"Mat::
n_1locateROI
() catched cv::Exception: %s"
,
e
.
what
());
LOGD
(
"Mat::
locateROI_10
() catched cv::Exception: %s"
,
e
.
what
());
jclass
je
=
env
->
FindClass
(
"org/opencv/core/CvException"
);
jclass
je
=
env
->
FindClass
(
"org/opencv/core/CvException"
);
if
(
!
je
)
je
=
env
->
FindClass
(
"java/lang/Exception"
);
if
(
!
je
)
je
=
env
->
FindClass
(
"java/lang/Exception"
);
env
->
ThrowNew
(
je
,
e
.
what
());
env
->
ThrowNew
(
je
,
e
.
what
());
return
;
return
;
}
catch
(...)
{
}
catch
(...)
{
LOGD
(
"Mat::
n_1locateROI
() catched unknown exception (...)"
);
LOGD
(
"Mat::
locateROI_10
() catched unknown exception (...)"
);
jclass
je
=
env
->
FindClass
(
"java/lang/Exception"
);
jclass
je
=
env
->
FindClass
(
"java/lang/Exception"
);
env
->
ThrowNew
(
je
,
"Unknown exception in JNI code {Mat::
n_1locateROI
()}"
);
env
->
ThrowNew
(
je
,
"Unknown exception in JNI code {Mat::
locateROI_10
()}"
);
return
;
return
;
}
}
}
}
...
...
modules/java/src/java/core+Mat.java
View file @
ebb08bc0
...
@@ -549,9 +549,11 @@ public class Mat {
...
@@ -549,9 +549,11 @@ public class Mat {
// javadoc: Mat::locateROI(wholeSize, ofs)
// javadoc: Mat::locateROI(wholeSize, ofs)
public
void
locateROI
(
Size
wholeSize
,
Point
ofs
)
public
void
locateROI
(
Size
wholeSize
,
Point
ofs
)
{
{
double
[]
wholeSize_out
=
new
double
[
2
];
n_locateROI
(
nativeObj
,
wholeSize
.
width
,
wholeSize
.
height
,
ofs
.
x
,
ofs
.
y
);
double
[]
ofs_out
=
new
double
[
2
];
locateROI_0
(
nativeObj
,
wholeSize_out
,
ofs_out
);
if
(
wholeSize
!=
null
){
wholeSize
.
width
=
wholeSize_out
[
0
];
wholeSize
.
height
=
wholeSize_out
[
1
];
}
if
(
ofs
!=
null
){
ofs
.
x
=
ofs_out
[
0
];
ofs
.
y
=
ofs_out
[
1
];
}
return
;
return
;
}
}
...
@@ -1190,7 +1192,7 @@ public class Mat {
...
@@ -1190,7 +1192,7 @@ public class Mat {
private
static
native
boolean
n_isSubmatrix
(
long
nativeObj
);
private
static
native
boolean
n_isSubmatrix
(
long
nativeObj
);
// C++: void Mat::locateROI(Size wholeSize, Point ofs)
// C++: void Mat::locateROI(Size wholeSize, Point ofs)
private
static
native
void
n_locateROI
(
long
nativeObj
,
double
wholeSize_width
,
double
wholeSize_height
,
double
ofs_x
,
double
ofs_y
);
private
static
native
void
locateROI_0
(
long
nativeObj
,
double
[]
wholeSize_out
,
double
[]
ofs_out
);
// C++: Mat Mat::mul(Mat m, double scale = 1)
// C++: Mat Mat::mul(Mat m, double scale = 1)
private
static
native
long
n_mul
(
long
nativeObj
,
long
m_nativeObj
,
double
scale
);
private
static
native
long
n_mul
(
long
nativeObj
,
long
m_nativeObj
,
double
scale
);
...
...
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