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
28732d43
Commit
28732d43
authored
Aug 04, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: added tests for SiftDescriptorExtractor and OrbDescriptorExtractor
parent
1523cb04
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
216 additions
and
2 deletions
+216
-2
BRIEFDescriptorExtractorTest.java
.../opencv/test/features2d/BRIEFDescriptorExtractorTest.java
+1
-2
ORBDescriptorExtractorTest.java
...rg/opencv/test/features2d/ORBDescriptorExtractorTest.java
+109
-0
SIFTDescriptorExtractorTest.java
...g/opencv/test/features2d/SIFTDescriptorExtractorTest.java
+106
-0
No files found.
modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java
View file @
28732d43
...
...
@@ -41,7 +41,6 @@ public class BRIEFDescriptorExtractorTest extends OpenCVTestCase {
Mat
descriptors
=
new
Mat
();
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
OpenCVTestRunner
.
Log
(
descriptors
);
Mat
truth
=
new
Mat
(
1
,
32
,
CvType
.
CV_8UC1
)
{
{
...
...
@@ -50,7 +49,7 @@ public class BRIEFDescriptorExtractorTest extends OpenCVTestCase {
}
};
assertMatEqual
(
truth
,
descriptors
,
EPS
);
assertMatEqual
(
truth
,
descriptors
);
}
public
void
testCreate
()
{
...
...
modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java
0 → 100644
View file @
28732d43
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.DescriptorExtractor
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
ORBDescriptorExtractorTest
extends
OpenCVTestCase
{
DescriptorExtractor
extractor
;
int
matSize
;
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
;
}
@Override
protected
void
setUp
()
throws
Exception
{
extractor
=
DescriptorExtractor
.
create
(
DescriptorExtractor
.
ORB
);
matSize
=
100
;
super
.
setUp
();
}
public
void
testCompute
()
{
KeyPoint
point
=
new
KeyPoint
(
55.775577545166016f
,
44.224422454833984f
,
16
,
9.754629f
,
8617.863f
,
1
,
-
1
);
List
<
KeyPoint
>
keypoints
=
Arrays
.
asList
(
point
);
Mat
img
=
getTestImg
();
Mat
descriptors
=
new
Mat
();
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
Mat
truth
=
new
Mat
(
1
,
32
,
CvType
.
CV_8UC1
)
{
{
put
(
0
,
0
,
20
,
51
,
88
,
22
,
14
,
181
,
78
,
111
,
36
,
144
,
62
,
0
,
188
,
196
,
4
,
8
,
133
,
80
,
96
,
18
,
64
,
29
,
0
,
254
,
230
,
247
,
12
,
2
,
78
,
129
,
70
,
145
);
}
};
assertMatEqual
(
truth
,
descriptors
);
}
public
void
testCreate
()
{
assertNotNull
(
extractor
);
}
public
void
testDescriptorSize
()
{
assertEquals
(
32
,
extractor
.
descriptorSize
());
}
public
void
testDescriptorType
()
{
assertEquals
(
CvType
.
CV_8U
,
extractor
.
descriptorType
());
}
public
void
testEmpty
()
{
assertFalse
(
extractor
.
empty
());
}
public
void
testRead
()
{
KeyPoint
point
=
new
KeyPoint
(
55.775577545166016f
,
44.224422454833984f
,
16
,
9.754629f
,
8617.863f
,
1
,
-
1
);
List
<
KeyPoint
>
keypoints
=
Arrays
.
asList
(
point
);
Mat
img
=
getTestImg
();
Mat
descriptors
=
new
Mat
();
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nscaleFactor: 1.1\nnLevels: 3\nfirstLevel: 0\nedgeThreshold: 31\npatchSize: 31\n"
);
extractor
.
read
(
filename
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
Mat
truth
=
new
Mat
(
1
,
32
,
CvType
.
CV_8UC1
)
{
{
put
(
0
,
0
,
20
,
55
,
88
,
20
,
14
,
49
,
70
,
111
,
148
,
144
,
30
,
16
,
252
,
133
,
0
,
8
,
5
,
85
,
32
,
0
,
74
,
25
,
0
,
252
,
119
,
191
,
4
,
2
,
66
,
1
,
66
,
145
);
}
};
assertMatEqual
(
truth
,
descriptors
);
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
extractor
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<scaleFactor>1.2000000476837158e+00</scaleFactor>\n<nLevels>3</nLevels>\n<firstLevel>0</firstLevel>\n<edgeThreshold>31</edgeThreshold>\n<patchSize>31</patchSize>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
extractor
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nscaleFactor: 1.2000000476837158e+00\nnLevels: 3\nfirstLevel: 0\nedgeThreshold: 31\npatchSize: 31\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java
0 → 100644
View file @
28732d43
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.DescriptorExtractor
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
SIFTDescriptorExtractorTest
extends
OpenCVTestCase
{
DescriptorExtractor
extractor
;
KeyPoint
keypoint
;
Mat
truth
;
int
matSize
;
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
;
}
@Override
protected
void
setUp
()
throws
Exception
{
extractor
=
DescriptorExtractor
.
create
(
DescriptorExtractor
.
SIFT
);
keypoint
=
new
KeyPoint
(
55.775577545166016f
,
44.224422454833984f
,
16
,
9.754629f
,
8617.863f
,
1
,
-
1
);
matSize
=
100
;
truth
=
new
Mat
(
1
,
128
,
CvType
.
CV_32FC1
)
{
{
put
(
0
,
0
,
123
,
0
,
0
,
1
,
123
,
0
,
0
,
1
,
123
,
0
,
0
,
0
,
0
,
0
,
0
,
2
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
123
,
0
,
0
,
2
,
123
,
0
,
0
,
2
,
123
,
0
,
0
,
0
,
0
,
0
,
0
,
2
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
123
,
30
,
7
,
31
,
123
,
0
,
0
,
0
,
123
,
52
,
88
,
0
,
0
,
0
,
0
,
0
,
0
,
2
,
123
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
110
,
0
,
0
,
0
,
0
,
0
,
18
,
37
,
18
,
34
,
16
,
21
,
12
,
23
,
12
,
50
,
123
,
0
,
0
,
0
,
90
,
26
,
0
,
3
,
123
,
0
,
0
,
1
,
122
,
0
,
0
,
2
,
123
,
0
,
0
,
1
,
93
,
0
);
}
};
super
.
setUp
();
}
public
void
testCompute
()
{
List
<
KeyPoint
>
keypoints
=
Arrays
.
asList
(
keypoint
);
Mat
img
=
getTestImg
();
Mat
descriptors
=
new
Mat
();
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
assertMatEqual
(
truth
,
descriptors
,
EPS
);
}
public
void
testCreate
()
{
assertNotNull
(
extractor
);
}
public
void
testDescriptorSize
()
{
assertEquals
(
128
,
extractor
.
descriptorSize
());
}
public
void
testDescriptorType
()
{
assertEquals
(
CvType
.
CV_32F
,
extractor
.
descriptorType
());
}
public
void
testEmpty
()
{
assertFalse
(
extractor
.
empty
());
}
public
void
testRead
()
{
List
<
KeyPoint
>
keypoints
=
Arrays
.
asList
(
keypoint
);
Mat
img
=
getTestImg
();
Mat
descriptors
=
new
Mat
();
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nmagnification: 3.\nisNormalize: 1\nrecalculateAngles: 1\nnOctaves: 6\nnOctaveLayers: 4\nfirstOctave: -1\nangleMode: 0\n"
);
extractor
.
read
(
filename
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
assertMatNotEqual
(
truth
,
descriptors
,
EPS
);
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
extractor
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<magnification>3.</magnification>\n<isNormalize>1</isNormalize>\n<recalculateAngles>1</recalculateAngles>\n<nOctaves>4</nOctaves>\n<nOctaveLayers>3</nOctaveLayers>\n<firstOctave>-1</firstOctave>\n<angleMode>0</angleMode>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
extractor
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nmagnification: 3.\nisNormalize: 1\nrecalculateAngles: 1\nnOctaves: 4\nnOctaveLayers: 3\nfirstOctave: -1\nangleMode: 0\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
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