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
2154fb5a
Commit
2154fb5a
authored
Apr 07, 2012
by
Ivan Korolev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: Fixed some bugs in the ImgprocTest.java
parent
99b24f77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
34 deletions
+24
-34
ImgprocTest.java
...android_test/src/org/opencv/test/imgproc/ImgprocTest.java
+24
-34
No files found.
modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java
View file @
2154fb5a
...
...
@@ -293,9 +293,9 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloatBoolean
()
{
List
<
Mat
>
images
=
Arrays
.
asList
(
gray255
,
gray128
);
List
<
Integer
>
channels
=
Arrays
.
asList
(
0
,
1
);
List
<
Integer
>
histSize
=
Arrays
.
asList
(
10
,
10
);
List
<
Float
>
ranges
=
Arrays
.
asList
(
0
f
,
256
f
,
0
f
,
256
f
);
MatOfInt
channels
=
new
MatOfInt
(
1
,
0
,
1
);
MatOfInt
histSize
=
new
MatOfInt
(
1
,
10
,
10
);
MatOfFloat
ranges
=
new
MatOfFloat
(
1
,
0
f
,
256
f
,
0
f
,
256
f
);
Mat
hist
=
new
Mat
();
Imgproc
.
calcHist
(
images
,
channels
,
new
Mat
(),
hist
,
histSize
,
ranges
,
true
);
...
...
@@ -541,15 +541,14 @@ public class ImgprocTest extends OpenCVTestCase {
Rect
r
=
new
Rect
(
new
Point
(
0
,
0
),
truthPosition
);
Core
.
rectangle
(
img
,
r
.
tl
(),
r
.
br
(),
new
Scalar
(
0
),
Core
.
FILLED
);
List
<
Point
>
corners
=
new
ArrayList
<
Point
>();
corners
.
add
(
new
Point
(
truthPosition
.
x
+
1
,
truthPosition
.
y
+
1
));
MatOfPoint2f
corners
=
new
MatOfPoint2f
(
new
Point
(
truthPosition
.
x
+
1
,
truthPosition
.
y
+
1
));
Size
winSize
=
new
Size
(
2
,
2
);
Size
zeroZone
=
new
Size
(-
1
,
-
1
);
TermCriteria
criteria
=
new
TermCriteria
(
TermCriteria
.
EPS
,
0
,
0.01
);
Imgproc
.
cornerSubPix
(
img
,
corners
,
winSize
,
zeroZone
,
criteria
);
assertPointEquals
(
truthPosition
,
corners
.
get
(
0
),
weakEPS
);
assertPointEquals
(
truthPosition
,
corners
.
toList
().
get
(
0
),
weakEPS
);
}
public
void
testCvtColorMatMatInt
()
{
...
...
@@ -601,7 +600,7 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testDrawContoursMatListOfMatIntScalar
()
{
Core
.
rectangle
(
gray0
,
new
Point
(
1
,
2
),
new
Point
(
7
,
8
),
new
Scalar
(
100
));
List
<
Mat
>
contours
=
new
ArrayList
<
Ma
t
>();
List
<
Mat
OfPoint
>
contours
=
new
ArrayList
<
MatOfPoin
t
>();
Imgproc
.
findContours
(
gray0
,
contours
,
new
Mat
(),
Imgproc
.
RETR_EXTERNAL
,
Imgproc
.
CHAIN_APPROX_SIMPLE
);
Imgproc
.
drawContours
(
gray0
,
contours
,
-
1
,
new
Scalar
(
0
));
...
...
@@ -611,7 +610,7 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testDrawContoursMatListOfMatIntScalarInt
()
{
Core
.
rectangle
(
gray0
,
new
Point
(
1
,
2
),
new
Point
(
7
,
8
),
new
Scalar
(
100
));
List
<
Mat
>
contours
=
new
ArrayList
<
Ma
t
>();
List
<
Mat
OfPoint
>
contours
=
new
ArrayList
<
MatOfPoin
t
>();
Imgproc
.
findContours
(
gray0
,
contours
,
new
Mat
(),
Imgproc
.
RETR_EXTERNAL
,
Imgproc
.
CHAIN_APPROX_SIMPLE
);
Imgproc
.
drawContours
(
gray0
,
contours
,
-
1
,
new
Scalar
(
0
),
Core
.
FILLED
);
...
...
@@ -706,7 +705,7 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testFindContoursMatListOfMatMatIntInt
()
{
Mat
img
=
new
Mat
(
50
,
50
,
CvType
.
CV_8UC1
,
new
Scalar
(
0
));
List
<
Mat
>
contours
=
new
ArrayList
<
Ma
t
>(
5
);
List
<
Mat
OfPoint
>
contours
=
new
ArrayList
<
MatOfPoin
t
>(
5
);
Mat
hierarchy
=
new
Mat
();
Imgproc
.
findContours
(
img
,
contours
,
hierarchy
,
Imgproc
.
RETR_EXTERNAL
,
Imgproc
.
CHAIN_APPROX_SIMPLE
);
...
...
@@ -728,8 +727,8 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testFindContoursMatListOfMatMatIntIntPoint
()
{
Mat
img
=
new
Mat
(
50
,
50
,
CvType
.
CV_8UC1
,
new
Scalar
(
0
));
Mat
img2
=
img
.
submat
(
5
,
50
,
3
,
50
);
List
<
Mat
>
contours
=
new
ArrayList
<
Ma
t
>();
List
<
Mat
>
contours2
=
new
ArrayList
<
Ma
t
>();
List
<
Mat
OfPoint
>
contours
=
new
ArrayList
<
MatOfPoin
t
>();
List
<
Mat
OfPoint
>
contours2
=
new
ArrayList
<
MatOfPoin
t
>();
Mat
hierarchy
=
new
Mat
();
Core
.
rectangle
(
img
,
new
Point
(
10
,
20
),
new
Point
(
20
,
30
),
new
Scalar
(
100
),
3
,
Core
.
LINE_AA
,
0
);
...
...
@@ -749,7 +748,7 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testFitEllipse
()
{
List
<
Point
>
points
=
Arrays
.
asList
(
new
Point
(
0
,
0
),
new
Point
(-
1
,
1
),
new
Point
(
1
,
1
),
new
Point
(
1
,
-
1
),
new
Point
(-
1
,
-
1
));
MatOfPoint2f
points
=
new
MatOfPoint2f
(
new
Point
(
0
,
0
),
new
Point
(-
1
,
1
),
new
Point
(
1
,
1
),
new
Point
(
1
,
-
1
),
new
Point
(-
1
,
-
1
));
RotatedRect
rrect
=
new
RotatedRect
();
rrect
=
Imgproc
.
fitEllipse
(
points
);
...
...
@@ -834,8 +833,8 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testGetAffineTransform
()
{
List
<
Point
>
src
=
Arrays
.
asList
(
new
Point
(
2
,
3
),
new
Point
(
3
,
1
),
new
Point
(
1
,
4
));
List
<
Point
>
dst
=
Arrays
.
asList
(
new
Point
(
3
,
3
),
new
Point
(
7
,
4
),
new
Point
(
5
,
6
));
MatOfPoint2f
src
=
new
MatOfPoint2f
(
new
Point
(
2
,
3
),
new
Point
(
3
,
1
),
new
Point
(
1
,
4
));
MatOfPoint2f
dst
=
new
MatOfPoint2f
(
new
Point
(
3
,
3
),
new
Point
(
7
,
4
),
new
Point
(
5
,
6
));
Mat
transform
=
Imgproc
.
getAffineTransform
(
src
,
dst
);
...
...
@@ -978,7 +977,7 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testGoodFeaturesToTrackMatListOfPointIntDoubleDouble
()
{
Mat
src
=
gray0
;
Core
.
rectangle
(
src
,
new
Point
(
2
,
2
),
new
Point
(
8
,
8
),
new
Scalar
(
100
),
-
1
);
List
<
Point
>
lp
=
new
ArrayList
<
Point
>
();
MatOfPoint
lp
=
new
MatOfPoint
();
Imgproc
.
goodFeaturesToTrack
(
src
,
lp
,
100
,
0.01
,
3
);
...
...
@@ -988,7 +987,7 @@ public class ImgprocTest extends OpenCVTestCase {
public
void
testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble
()
{
Mat
src
=
gray0
;
Core
.
rectangle
(
src
,
new
Point
(
2
,
2
),
new
Point
(
8
,
8
),
new
Scalar
(
100
),
-
1
);
List
<
Point
>
lp
=
new
ArrayList
<
Point
>
();
MatOfPoint
lp
=
new
MatOfPoint
();
Imgproc
.
goodFeaturesToTrack
(
src
,
lp
,
100
,
0.01
,
3
,
gray1
,
4
,
true
,
0
);
...
...
@@ -1278,11 +1277,11 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testIsContourConvex
()
{
List
<
Point
>
contour1
=
Arrays
.
asList
(
new
Point
(
0
,
0
),
new
Point
(
10
,
0
),
new
Point
(
10
,
10
),
new
Point
(
5
,
4
));
MatOfPoint2f
contour1
=
new
MatOfPoint2f
(
new
Point
(
0
,
0
),
new
Point
(
10
,
0
),
new
Point
(
10
,
10
),
new
Point
(
5
,
4
));
assertFalse
(
Imgproc
.
isContourConvex
(
contour1
));
List
<
Point
>
contour2
=
Arrays
.
asList
(
new
Point
(
0
,
0
),
new
Point
(
10
,
0
),
new
Point
(
10
,
10
),
new
Point
(
5
,
6
));
MatOfPoint2f
contour2
=
new
MatOfPoint2f
(
new
Point
(
0
,
0
),
new
Point
(
10
,
0
),
new
Point
(
10
,
10
),
new
Point
(
5
,
6
));
assertTrue
(
Imgproc
.
isContourConvex
(
contour2
));
}
...
...
@@ -1354,7 +1353,7 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testMinAreaRect
()
{
List
<
Point
>
points
=
Arrays
.
asList
(
new
Point
(
1
,
1
),
new
Point
(
5
,
1
),
new
Point
(
4
,
3
),
new
Point
(
6
,
2
));
MatOfPoint2f
points
=
new
MatOfPoint2f
(
new
Point
(
1
,
1
),
new
Point
(
5
,
1
),
new
Point
(
4
,
3
),
new
Point
(
6
,
2
));
RotatedRect
rrect
=
Imgproc
.
minAreaRect
(
points
);
...
...
@@ -1364,12 +1363,7 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testMinEnclosingCircle
()
{
List
<
Point
>
points
=
new
ArrayList
<
Point
>();
points
.
add
(
new
Point
(
0
,
0
));
points
.
add
(
new
Point
(-
1
,
0
));
points
.
add
(
new
Point
(
0
,
-
1
));
points
.
add
(
new
Point
(
1
,
0
));
points
.
add
(
new
Point
(
0
,
1
));
MatOfPoint2f
points
=
new
MatOfPoint2f
(
new
Point
(
0
,
0
),
new
Point
(-
1
,
0
),
new
Point
(
0
,
-
1
),
new
Point
(
1
,
0
),
new
Point
(
0
,
1
));
Point
actualCenter
=
new
Point
();
float
[]
radius
=
new
float
[
1
];
...
...
@@ -1429,8 +1423,7 @@ public class ImgprocTest extends OpenCVTestCase {
}
public
void
testPointPolygonTest
()
{
List
<
Point
>
contour
=
Arrays
.
asList
(
new
Point
(
0
,
0
),
new
Point
(
1
,
3
),
new
Point
(
3
,
4
),
new
Point
(
4
,
3
),
new
Point
(
2
,
1
));
MatOfPoint2f
contour
=
new
MatOfPoint2f
(
new
Point
(
0
,
0
),
new
Point
(
1
,
3
),
new
Point
(
3
,
4
),
new
Point
(
4
,
3
),
new
Point
(
2
,
1
));
double
sign1
=
Imgproc
.
pointPolygonTest
(
contour
,
new
Point
(
2
,
2
),
false
);
assertEquals
(
1.0
,
sign1
);
...
...
@@ -1762,18 +1755,15 @@ public class ImgprocTest extends OpenCVTestCase {
//undistortPoints(List<Point> src, List<Point> dst, Mat cameraMatrix, Mat distCoeffs)
public
void
testUndistortPointsListOfPointListOfPointMatMat
()
{
List
<
Point
>
src
=
new
ArrayList
<
Point
>(
3
);
src
.
add
(
new
Point
(
1
,
2
)
);
src
.
add
(
new
Point
(
3
,
4
)
);
src
.
add
(
new
Point
(-
1
,
-
1
)
);
List
<
Point
>
dst
=
new
ArrayList
<
Point
>();
MatOfPoint2f
src
=
new
MatOfPoint2f
(
new
Point
(
1
,
2
),
new
Point
(
3
,
4
),
new
Point
(-
1
,
-
1
));
MatOfPoint2f
dst
=
new
MatOfPoint2f
();
Mat
cameraMatrix
=
Mat
.
eye
(
3
,
3
,
CvType
.
CV_64FC1
);
Mat
distCoeffs
=
new
Mat
(
8
,
1
,
CvType
.
CV_64FC1
,
new
Scalar
(
0
));
Imgproc
.
undistortPoints
(
src
,
dst
,
cameraMatrix
,
distCoeffs
);
assertEquals
(
src
.
size
(),
dst
.
size
());
for
(
int
i
=
0
;
i
<
src
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
src
.
toList
().
size
();
i
++)
{
//Log.d("UndistortPoints", "s="+src.get(i)+", d="+dst.get(i));
assertTrue
(
src
.
get
(
i
).
equals
(
dst
.
get
(
i
)));
assertTrue
(
src
.
toList
().
get
(
i
).
equals
(
dst
.
toList
()
.
get
(
i
)));
}
}
...
...
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