Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
2d820d23
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d820d23
编写于
8月 03, 2011
作者:
A
Andrey Kamaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Java API: added tests for BruteForceMatcher (L1)
上级
472820d8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
217 addition
and
4 deletion
+217
-4
modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java
...encv/test/features2d/BruteForceDescriptorMatcherTest.java
+0
-4
modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java
...cv/test/features2d/BruteForceL1DescriptorMatcherTest.java
+217
-0
未找到文件。
modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java
浏览文件 @
2d820d23
...
...
@@ -66,10 +66,6 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
detector
.
read
(
filename
);
detector
.
detect
(
img
,
keypoints
);
OpenCVTestRunner
.
Log
(
"points found: "
+
keypoints
.
size
());
for
(
KeyPoint
kp
:
keypoints
)
OpenCVTestRunner
.
Log
(
kp
.
toString
());
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
return
descriptors
;
...
...
modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java
0 → 100644
浏览文件 @
2d820d23
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.DMatch
;
import
org.opencv.features2d.DescriptorExtractor
;
import
org.opencv.features2d.DescriptorMatcher
;
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.Arrays
;
import
java.util.List
;
public
class
BruteForceL1DescriptorMatcherTest
extends
OpenCVTestCase
{
DescriptorMatcher
matcher
;
int
matSize
;
DMatch
[]
truth
;
protected
void
setUp
()
throws
Exception
{
matcher
=
DescriptorMatcher
.
create
(
DescriptorMatcher
.
BRUTEFORCE_L1
);
matSize
=
100
;
truth
=
new
DMatch
[]
{
new
DMatch
(
0
,
0
,
0
,
3.175296f
),
new
DMatch
(
1
,
1
,
0
,
3.5954158f
),
new
DMatch
(
2
,
1
,
0
,
1.2537984f
),
new
DMatch
(
3
,
1
,
0
,
3.5761614f
),
new
DMatch
(
4
,
1
,
0
,
1.3250958f
)
};
super
.
setUp
();
}
private
Mat
getTrainImg
()
{
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
Mat
getQueryImg
()
{
Mat
cross
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
Core
.
line
(
cross
,
new
Point
(
30
,
matSize
/
2
),
new
Point
(
matSize
-
31
,
matSize
/
2
),
new
Scalar
(
100
),
3
);
Core
.
line
(
cross
,
new
Point
(
matSize
/
2
,
30
),
new
Point
(
matSize
/
2
,
matSize
-
31
),
new
Scalar
(
100
),
3
);
return
cross
;
}
private
Mat
getQueryDescriptors
()
{
Mat
img
=
getQueryImg
();
List
<
KeyPoint
>
keypoints
=
new
ArrayList
<
KeyPoint
>();
Mat
descriptors
=
new
Mat
();
FeatureDetector
detector
=
FeatureDetector
.
create
(
FeatureDetector
.
SURF
);
DescriptorExtractor
extractor
=
DescriptorExtractor
.
create
(
DescriptorExtractor
.
SURF
);
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n"
);
detector
.
read
(
filename
);
detector
.
detect
(
img
,
keypoints
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
return
descriptors
;
}
private
Mat
getTrainDescriptors
()
{
Mat
img
=
getTrainImg
();
List
<
KeyPoint
>
keypoints
=
Arrays
.
asList
(
new
KeyPoint
(
50
,
50
,
16
,
0
,
20000
,
1
,
-
1
),
new
KeyPoint
(
42
,
42
,
16
,
160
,
10000
,
1
,
-
1
));
Mat
descriptors
=
new
Mat
();
DescriptorExtractor
extractor
=
DescriptorExtractor
.
create
(
DescriptorExtractor
.
SURF
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
return
descriptors
;
}
private
Mat
getMaskImg
()
{
return
new
Mat
(
5
,
2
,
CvType
.
CV_8U
,
new
Scalar
(
0
))
{
{
put
(
0
,
0
,
1
,
1
,
1
,
1
);
}
};
}
public
void
testAdd
()
{
matcher
.
add
(
Arrays
.
asList
(
new
Mat
()));
assertFalse
(
matcher
.
empty
());
}
public
void
testClear
()
{
matcher
.
add
(
Arrays
.
asList
(
new
Mat
()));
matcher
.
clear
();
assertTrue
(
matcher
.
empty
());
}
public
void
testCloneBoolean
()
{
matcher
.
add
(
Arrays
.
asList
(
new
Mat
()));
DescriptorMatcher
cloned
=
matcher
.
clone
(
true
);
assertNotNull
(
cloned
);
assertTrue
(
cloned
.
empty
());
}
public
void
testClone
()
{
Mat
train
=
new
Mat
(
1
,
1
,
CvType
.
CV_8U
,
new
Scalar
(
123
));
Mat
truth
=
train
.
clone
();
matcher
.
add
(
Arrays
.
asList
(
train
));
DescriptorMatcher
cloned
=
matcher
.
clone
();
assertNotNull
(
cloned
);
List
<
Mat
>
descriptors
=
cloned
.
getTrainDescriptors
();
assertEquals
(
1
,
descriptors
.
size
());
assertMatEqual
(
truth
,
descriptors
.
get
(
0
));
}
public
void
testCreate
()
{
assertNotNull
(
matcher
);
}
public
void
testEmpty
()
{
assertTrue
(
matcher
.
empty
());
}
public
void
testGetTrainDescriptors
()
{
Mat
train
=
new
Mat
(
1
,
1
,
CvType
.
CV_8U
,
new
Scalar
(
123
));
Mat
truth
=
train
.
clone
();
matcher
.
add
(
Arrays
.
asList
(
train
));
List
<
Mat
>
descriptors
=
matcher
.
getTrainDescriptors
();
assertEquals
(
1
,
descriptors
.
size
());
assertMatEqual
(
truth
,
descriptors
.
get
(
0
));
}
public
void
testIsMaskSupported
()
{
assertTrue
(
matcher
.
isMaskSupported
());
}
public
void
testMatchMatMatListOfDMatchMat
()
{
Mat
train
=
getTrainDescriptors
();
Mat
query
=
getQueryDescriptors
();
Mat
mask
=
getMaskImg
();
List
<
DMatch
>
matches
=
new
ArrayList
<
DMatch
>();
matcher
.
match
(
query
,
train
,
matches
,
mask
);
assertListDMatchEquals
(
Arrays
.
asList
(
truth
[
0
],
truth
[
1
]),
matches
,
EPS
);
}
public
void
testMatchMatMatListOfDMatch
()
{
Mat
train
=
getTrainDescriptors
();
Mat
query
=
getQueryDescriptors
();
List
<
DMatch
>
matches
=
new
ArrayList
<
DMatch
>();
matcher
.
match
(
query
,
train
,
matches
);
assertListDMatchEquals
(
Arrays
.
asList
(
truth
),
matches
,
EPS
);
}
public
void
testMatchMatListOfDMatchListOfMat
()
{
Mat
train
=
getTrainDescriptors
();
Mat
query
=
getQueryDescriptors
();
Mat
mask
=
getMaskImg
();
List
<
DMatch
>
matches
=
new
ArrayList
<
DMatch
>();
matcher
.
add
(
Arrays
.
asList
(
train
));
matcher
.
match
(
query
,
matches
,
Arrays
.
asList
(
mask
));
assertListDMatchEquals
(
Arrays
.
asList
(
truth
[
0
],
truth
[
1
]),
matches
,
EPS
);
}
public
void
testMatchMatListOfDMatch
()
{
Mat
train
=
getTrainDescriptors
();
Mat
query
=
getQueryDescriptors
();
List
<
DMatch
>
matches
=
new
ArrayList
<
DMatch
>();
matcher
.
add
(
Arrays
.
asList
(
train
));
matcher
.
match
(
query
,
matches
);
assertListDMatchEquals
(
Arrays
.
asList
(
truth
),
matches
,
EPS
);
}
public
void
testRead
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
"%YAML:1.0\n"
);
matcher
.
read
(
filename
);
assertTrue
(
true
);
// BruteforceMatcher has no settings
}
public
void
testTrain
()
{
matcher
.
train
();
// BruteforceMatcher does not need to train
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
matcher
.
write
(
filename
);
String
truth
=
"%YAML:1.0\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录