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
1890a0ae
Commit
1890a0ae
authored
Aug 02, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: added new tests for SURF and STAR feature detectors
parent
257c0bf4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
273 additions
and
89 deletions
+273
-89
MSERTest.java
...android_test/src/org/opencv/test/features2d/MSERTest.java
+0
-31
STARFeatureDetectorTest.java
...c/org/opencv/test/features2d/STARFeatureDetectorTest.java
+130
-0
SURFFeatureDetectorTest.java
...c/org/opencv/test/features2d/SURFFeatureDetectorTest.java
+142
-0
StarDetectorTest.java
...test/src/org/opencv/test/features2d/StarDetectorTest.java
+0
-58
gen_java.py
modules/java/gen_java.py
+1
-0
No files found.
modules/java/android_test/src/org/opencv/test/features2d/MSERTest.java
deleted
100644 → 0
View file @
257c0bf4
package
org
.
opencv
.
test
.
features2d
;
import
org.opencv.features2d.MSER
;
import
org.opencv.test.OpenCVTestCase
;
public
class
MSERTest
extends
OpenCVTestCase
{
private
MSER
mser
;
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
mser
=
null
;
}
public
void
test_1
()
{
super
.
test_1
(
"FEATURES2D.MSER"
);
}
public
void
testMSER
()
{
mser
=
new
MSER
();
assertTrue
(
null
!=
mser
);
}
public
void
testMSERIntIntIntDoubleDoubleIntDoubleDoubleInt
()
{
mser
=
new
MSER
(
5
,
60
,
14400
,
.
25
f
,
.
2
f
,
200
,
1.01
,
.
003
,
5
);
assertTrue
(
null
!=
mser
);
}
}
modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java
0 → 100644
View file @
1890a0ae
package
org
.
opencv
.
test
.
features2d
;
import
org.opencv.core.Core
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Point
;
import
org.opencv.core.Scalar
;
import
org.opencv.features2d.FeatureDetector
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
STARFeatureDetectorTest
extends
OpenCVTestCase
{
FeatureDetector
detector
;
KeyPoint
[]
truth
;
int
matSize
;
protected
void
setUp
()
throws
Exception
{
detector
=
FeatureDetector
.
create
(
FeatureDetector
.
STAR
);
matSize
=
200
;
truth
=
new
KeyPoint
[]
{
new
KeyPoint
(
95
,
80
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
105
,
80
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
80
,
95
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
120
,
95
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
100
,
100
,
8
,
-
1
,
-
219.90825f
,
0
,
-
1
),
new
KeyPoint
(
80
,
105
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
120
,
105
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
95
,
120
,
22
,
-
1
,
31.595734f
,
0
,
-
1
),
new
KeyPoint
(
105
,
120
,
22
,
-
1
,
31.595734f
,
0
,
-
1
)
};
super
.
setUp
();
}
private
Mat
getTestImg
()
{
Scalar
color
=
new
Scalar
(
0
);
int
center
=
matSize
/
2
;
int
radius
=
6
;
int
offset
=
40
;
Mat
img
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Core
.
circle
(
img
,
new
Point
(
center
-
offset
,
center
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
+
offset
,
center
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
-
offset
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
+
offset
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
),
radius
,
color
,
-
1
);
return
img
;
}
private
Mat
getMaskImg
()
{
Mat
mask
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Mat
right
=
mask
.
submat
(
0
,
matSize
,
matSize
/
2
,
matSize
);
right
.
setTo
(
new
Scalar
(
0
));
return
mask
;
}
public
void
testCreate
()
{
assertNotNull
(
detector
);
}
public
void
testDetectMatListOfKeyPointMat
()
{
Mat
img
=
getTestImg
();
Mat
mask
=
getMaskImg
();
List
<
KeyPoint
>
keypoints
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
img
,
keypoints
,
mask
);
KeyPoint
[]
_truth
=
new
KeyPoint
[]
{
truth
[
0
],
truth
[
2
],
truth
[
5
],
truth
[
7
]
};
assertEquals
(
_truth
.
length
,
keypoints
.
size
());
for
(
int
i
=
0
;
i
<
_truth
.
length
;
i
++)
assertKeyPointEqual
(
_truth
[
i
],
keypoints
.
get
(
i
),
EPS
);
}
public
void
testDetectMatListOfKeyPoint
()
{
Mat
img
=
getTestImg
();
List
<
KeyPoint
>
keypoints
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
img
,
keypoints
);
assertEquals
(
truth
.
length
,
keypoints
.
size
());
for
(
int
i
=
0
;
i
<
truth
.
length
;
i
++)
assertKeyPointEqual
(
truth
[
i
],
keypoints
.
get
(
i
),
EPS
);
}
public
void
testEmpty
()
{
assertFalse
(
detector
.
empty
());
}
public
void
testRead
()
{
Mat
img
=
getTestImg
();
List
<
KeyPoint
>
keypoints1
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
img
,
keypoints1
);
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nmaxSize: 45\nresponseThreshold: 150\nlineThresholdProjected: 10\nlineThresholdBinarized: 8\nsuppressNonmaxSize: 5\n"
);
detector
.
read
(
filename
);
List
<
KeyPoint
>
keypoints2
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
img
,
keypoints2
);
assertTrue
(
keypoints2
.
size
()
<=
keypoints1
.
size
());
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
detector
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<maxSize>45</maxSize>\n<responseThreshold>30</responseThreshold>\n<lineThresholdProjected>10</lineThresholdProjected>\n<lineThresholdBinarized>8</lineThresholdBinarized>\n<suppressNonmaxSize>5</suppressNonmaxSize>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
detector
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nmaxSize: 45\nresponseThreshold: 30\nlineThresholdProjected: 10\nlineThresholdBinarized: 8\nsuppressNonmaxSize: 5\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java
0 → 100644
View file @
1890a0ae
package
org
.
opencv
.
test
.
features2d
;
import
org.opencv.core.Core
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Point
;
import
org.opencv.core.Scalar
;
import
org.opencv.features2d.FeatureDetector
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
public
class
SURFFeatureDetectorTest
extends
OpenCVTestCase
{
FeatureDetector
detector
;
KeyPoint
[]
truth
;
int
matSize
;
@Override
protected
void
setUp
()
throws
Exception
{
detector
=
FeatureDetector
.
create
(
FeatureDetector
.
SURF
);
matSize
=
100
;
truth
=
new
KeyPoint
[]
{
new
KeyPoint
(
55.775577545166016f
,
44.224422454833984f
,
16
,
9.754629f
,
8617.863f
,
1
,
-
1
),
new
KeyPoint
(
44.224422454833984f
,
44.224422454833984f
,
16
,
99.75463f
,
8617.863f
,
1
,
-
1
),
new
KeyPoint
(
44.224422454833984f
,
55.775577545166016f
,
16
,
189.7546f
,
8617.863f
,
1
,
-
1
),
new
KeyPoint
(
55.775577545166016f
,
55.775577545166016f
,
16
,
279.75464f
,
8617.863f
,
1
,
-
1
)
};
super
.
setUp
();
}
private
Mat
getTestImg
()
{
Mat
cross
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Core
.
line
(
cross
,
new
Point
(
20
,
matSize
/
2
),
new
Point
(
matSize
-
21
,
matSize
/
2
),
new
Scalar
(
100
),
2
);
Core
.
line
(
cross
,
new
Point
(
matSize
/
2
,
20
),
new
Point
(
matSize
/
2
,
matSize
-
21
),
new
Scalar
(
100
),
2
);
return
cross
;
}
private
void
order
(
List
<
KeyPoint
>
points
)
{
Collections
.
sort
(
points
,
new
Comparator
<
KeyPoint
>()
{
public
int
compare
(
KeyPoint
p1
,
KeyPoint
p2
)
{
if
(
p1
.
angle
<
p2
.
angle
)
return
-
1
;
if
(
p1
.
angle
>
p2
.
angle
)
return
1
;
return
0
;
}
});
}
private
Mat
getMaskImg
()
{
Mat
mask
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Mat
right
=
mask
.
submat
(
0
,
matSize
,
matSize
/
2
,
matSize
);
right
.
setTo
(
new
Scalar
(
0
));
return
mask
;
}
public
void
testCreate
()
{
assertNotNull
(
detector
);
}
public
void
testDetectMatListOfKeyPointMat
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
);
detector
.
read
(
filename
);
Mat
img
=
getTestImg
();
Mat
mask
=
getMaskImg
();
List
<
KeyPoint
>
keypoints
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
img
,
keypoints
,
mask
);
KeyPoint
[]
_truth
=
new
KeyPoint
[]
{
truth
[
1
],
truth
[
2
]
};
assertEquals
(
_truth
.
length
,
keypoints
.
size
());
order
(
keypoints
);
for
(
int
i
=
0
;
i
<
_truth
.
length
;
i
++)
assertKeyPointEqual
(
_truth
[
i
],
keypoints
.
get
(
i
),
EPS
);
}
public
void
testDetectMatListOfKeyPoint
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
);
detector
.
read
(
filename
);
List
<
KeyPoint
>
keypoints
=
new
ArrayList
<
KeyPoint
>();
Mat
cross
=
getTestImg
();
detector
.
detect
(
cross
,
keypoints
);
assertEquals
(
truth
.
length
,
keypoints
.
size
());
order
(
keypoints
);
for
(
int
i
=
0
;
i
<
truth
.
length
;
i
++)
assertKeyPointEqual
(
truth
[
i
],
keypoints
.
get
(
i
),
EPS
);
}
public
void
testEmpty
()
{
assertFalse
(
detector
.
empty
());
}
public
void
testRead
()
{
Mat
cross
=
getTestImg
();
List
<
KeyPoint
>
keypoints1
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
cross
,
keypoints1
);
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
);
detector
.
read
(
filename
);
List
<
KeyPoint
>
keypoints2
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
cross
,
keypoints2
);
assertTrue
(
keypoints2
.
size
()
<=
keypoints1
.
size
());
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
detector
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<hessianThreshold>400.</hessianThreshold>\n<octaves>3</octaves>\n<octaveLayers>4</octaveLayers>\n<upright>0</upright>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
detector
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nhessianThreshold: 400.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
modules/java/android_test/src/org/opencv/test/features2d/StarDetectorTest.java
deleted
100644 → 0
View file @
257c0bf4
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.Scalar
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.features2d.StarDetector
;
import
org.opencv.test.OpenCVTestCase
;
public
class
StarDetectorTest
extends
OpenCVTestCase
{
public
void
test_1
()
{
super
.
test_1
(
"FEATURES2D.StarDetector"
);
}
private
Mat
getStarImg
()
{
Scalar
color
=
new
Scalar
(
0
);
int
center
=
100
;
int
radius
=
5
;
int
offset
=
40
;
Mat
img
=
new
Mat
(
200
,
200
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Core
.
circle
(
img
,
new
Point
(
center
-
offset
,
center
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
+
offset
,
center
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
-
offset
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
+
offset
),
radius
,
color
,
-
1
);
Core
.
circle
(
img
,
new
Point
(
center
,
center
),
radius
,
color
,
-
1
);
return
img
;
}
public
void
testDetect
()
{
Mat
img
=
getStarImg
();
List
<
KeyPoint
>
keypoints
=
new
LinkedList
<
KeyPoint
>();
StarDetector
star
=
new
StarDetector
();
star
.
detect
(
img
,
keypoints
);
KeyPoint
truth
=
new
KeyPoint
(
100
,
100
,
8
,
-
1
,
-
223.40334f
,
0
,
-
1
);
assertEquals
(
1
,
keypoints
.
size
());
assertKeyPointEqual
(
truth
,
keypoints
.
get
(
0
),
EPS
);
}
public
void
testStarDetector
()
{
StarDetector
star
=
new
StarDetector
();
assertNotNull
(
star
);
}
public
void
testStarDetectorIntIntIntIntInt
()
{
StarDetector
star
=
new
StarDetector
(
45
,
30
,
10
,
8
,
5
);
assertNotNull
(
star
);
}
}
modules/java/gen_java.py
View file @
1890a0ae
...
...
@@ -14,6 +14,7 @@ class_ignore_list = (
#features2d
"KeyPoint"
,
"MSER"
,
"StarDetector"
,
)
const_ignore_list
=
(
...
...
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