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
e1cd84bb
Commit
e1cd84bb
authored
Aug 03, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java API: added and fixed several tests
parent
19c3cf45
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
6 deletions
+84
-6
OpenCVTestRunner.java
...va/android_test/src/org/opencv/test/OpenCVTestRunner.java
+5
-0
calib3dTest.java
...android_test/src/org/opencv/test/calib3d/calib3dTest.java
+1
-1
features2dTest.java
...d_test/src/org/opencv/test/features2d/features2dTest.java
+78
-0
VideoCaptureTest.java
...id_test/src/org/opencv/test/highgui/VideoCaptureTest.java
+0
-5
No files found.
modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
View file @
e1cd84bb
...
...
@@ -70,4 +70,9 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
androidTestRunner
=
super
.
getAndroidTestRunner
();
return
androidTestRunner
;
}
public
static
String
getOutputFileName
(
String
name
)
{
return
context
.
getExternalFilesDir
(
null
).
getAbsolutePath
()
+
File
.
separatorChar
+
name
;
}
}
modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java
View file @
e1cd84bb
...
...
@@ -242,7 +242,7 @@ public class calib3dTest extends OpenCVTestCase {
List
<
Point
>
pts1
=
new
ArrayList
<
Point
>();
List
<
Point
>
pts2
=
new
ArrayList
<
Point
>();
int
minFundamentalMatPoints
=
9
;
// FIXME: probably should be 8 (see ticket #1262)
int
minFundamentalMatPoints
=
8
;
for
(
int
i
=
0
;
i
<
minFundamentalMatPoints
;
i
++)
{
double
x
=
Math
.
random
()
*
100
-
50
;
double
y
=
Math
.
random
()
*
100
-
50
;
...
...
modules/java/android_test/src/org/opencv/test/features2d/features2dTest.java
View file @
e1cd84bb
package
org
.
opencv
.
test
.
features2d
;
import
org.opencv.calib3d.Calib3d
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
import
org.opencv.core.Point
;
import
org.opencv.core.Range
;
import
org.opencv.features2d.DMatch
;
import
org.opencv.features2d.DescriptorExtractor
;
import
org.opencv.features2d.DescriptorMatcher
;
import
org.opencv.features2d.FeatureDetector
;
import
org.opencv.features2d.Features2d
;
import
org.opencv.features2d.KeyPoint
;
import
org.opencv.highgui.Highgui
;
import
org.opencv.test.OpenCVTestCase
;
import
org.opencv.test.OpenCVTestRunner
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
features2dTest
extends
OpenCVTestCase
{
public
void
testPTOD
()
{
String
detectorCfg
=
"%YAML:1.0\nhessianThreshold: 4000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
;
String
extractorCfg
=
"%YAML:1.0\nnOctaves: 4\nnOctaveLayers: 2\nextended: 0\nupright: 0\n"
;
FeatureDetector
detector
=
FeatureDetector
.
create
(
FeatureDetector
.
SURF
);
DescriptorExtractor
extractor
=
DescriptorExtractor
.
create
(
DescriptorExtractor
.
SURF
);
DescriptorMatcher
matcher
=
DescriptorMatcher
.
create
(
DescriptorMatcher
.
BRUTEFORCE
);
String
detectorCfgFile
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
detectorCfgFile
,
detectorCfg
);
detector
.
read
(
detectorCfgFile
);
String
extractorCfgFile
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
extractorCfgFile
,
extractorCfg
);
extractor
.
read
(
extractorCfgFile
);
Mat
imgTrain
=
Highgui
.
imread
(
OpenCVTestRunner
.
LENA_PATH
,
Highgui
.
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
imgQuery
=
imgTrain
.
submat
(
new
Range
(
0
,
imgTrain
.
rows
()-
100
),
Range
.
all
());
List
<
KeyPoint
>
trainKeypoints
=
new
ArrayList
<
KeyPoint
>();
List
<
KeyPoint
>
queryKeypoints
=
new
ArrayList
<
KeyPoint
>();
detector
.
detect
(
imgTrain
,
trainKeypoints
);
detector
.
detect
(
imgQuery
,
queryKeypoints
);
//OpenCVTestRunner.Log("Keypoints found: " + trainKeypoints.size() + ":" + queryKeypoints.size());
Mat
trainDescriptors
=
new
Mat
();
Mat
queryDescriptors
=
new
Mat
();
extractor
.
compute
(
imgTrain
,
trainKeypoints
,
trainDescriptors
);
extractor
.
compute
(
imgQuery
,
queryKeypoints
,
queryDescriptors
);
List
<
DMatch
>
matches
=
new
ArrayList
<
DMatch
>();
matcher
.
add
(
Arrays
.
asList
(
trainDescriptors
));
matcher
.
match
(
queryDescriptors
,
matches
);
//OpenCVTestRunner.Log("Matches found: " + matches.size());
List
<
Point
>
points1
=
new
ArrayList
<
Point
>();
List
<
Point
>
points2
=
new
ArrayList
<
Point
>();
for
(
int
i
=
0
;
i
<
matches
.
size
();
i
++){
DMatch
match
=
matches
.
get
(
i
);
points1
.
add
(
trainKeypoints
.
get
(
match
.
trainIdx
).
pt
);
points2
.
add
(
queryKeypoints
.
get
(
match
.
queryIdx
).
pt
);
}
Mat
hmg
=
Calib3d
.
findHomography
(
points1
,
points2
,
Calib3d
.
RANSAC
);
assertMatEqual
(
Mat
.
eye
(
3
,
3
,
CvType
.
CV_64F
),
hmg
,
EPS
);
Mat
outimg
=
new
Mat
();
Features2d
.
drawMatches
(
imgQuery
,
queryKeypoints
,
imgTrain
,
trainKeypoints
,
matches
,
outimg
);
String
outputPath
=
OpenCVTestRunner
.
getOutputFileName
(
"PTODresult.png"
);
Highgui
.
imwrite
(
outputPath
,
outimg
);
//OpenCVTestRunner.Log("Output image is saved to: " + outputPath);
}
}
modules/java/android_test/src/org/opencv/test/highgui/VideoCaptureTest.java
View file @
e1cd84bb
...
...
@@ -122,9 +122,4 @@ public class VideoCaptureTest extends OpenCVTestCase {
capture
.
release
();
assertTrue
(
isOpened
);
}
public
void
testVideoCaptureString
()
{
fail
(
"Not yet implemented"
);
}
}
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