Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
69588dfa
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,发现更多精彩内容 >>
提交
69588dfa
编写于
8月 03, 2011
作者:
A
Andrey Kamaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Java API: fixed bugs; added tests for SURF and BRIEF descriptor extractors
上级
f81e6f82
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
225 addition
and
168 deletion
+225
-168
modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
...va/android_test/src/org/opencv/test/OpenCVTestRunner.java
+5
-0
modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java
.../opencv/test/features2d/BRIEFDescriptorExtractorTest.java
+107
-0
modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java
...c/org/opencv/test/features2d/FASTFeatureDetectorTest.java
+3
-7
modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java
...g/opencv/test/features2d/SURFDescriptorExtractorTest.java
+107
-0
modules/java/android_test/src/org/opencv/test/features2d/SURFTest.java
...android_test/src/org/opencv/test/features2d/SURFTest.java
+0
-158
modules/java/gen_java.py
modules/java/gen_java.py
+1
-1
modules/java/src/cpp/features2d_manual.hpp
modules/java/src/cpp/features2d_manual.hpp
+2
-2
未找到文件。
modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
浏览文件 @
69588dfa
...
...
@@ -6,6 +6,7 @@ import android.test.InstrumentationTestRunner;
import
android.util.Log
;
import
org.opencv.android.Utils
;
import
org.opencv.core.Mat
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -46,6 +47,10 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
static
public
void
Log
(
String
message
)
{
Log
.
e
(
TAG
,
message
);
}
static
public
void
Log
(
Mat
m
)
{
Log
.
e
(
TAG
,
m
+
"\n"
+
m
.
dump
());
}
@Override
public
void
onStart
()
{
...
...
modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java
0 → 100644
浏览文件 @
69588dfa
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
BRIEFDescriptorExtractorTest
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
.
BRIEF
);
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
);
OpenCVTestRunner
.
Log
(
descriptors
);
Mat
truth
=
new
Mat
(
1
,
32
,
CvType
.
CV_8UC1
)
{
{
put
(
0
,
0
,
96
,
0
,
76
,
24
,
47
,
182
,
68
,
137
,
149
,
195
,
67
,
16
,
187
,
224
,
74
,
8
,
82
,
169
,
87
,
70
,
44
,
4
,
192
,
56
,
13
,
128
,
44
,
106
,
146
,
72
,
194
,
245
);
}
};
assertMatEqual
(
truth
,
descriptors
,
EPS
);
}
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\nnOctaves: 4\nnOctaveLayers: 2\nextended: 1\nupright: 0\n"
);
extractor
.
read
(
filename
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
assertEquals
(
128
,
descriptors
.
cols
());
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
extractor
.
write
(
filename
);
//OpenCVTestRunner.Log("!!!!!!!" + readFile(filename));
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>!!!!\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
extractor
.
write
(
filename
);
//OpenCVTestRunner.Log("!!!!!!!" + readFile(filename));
String
truth
=
"%YAML:1.0\n!!!"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java
浏览文件 @
69588dfa
...
...
@@ -22,9 +22,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
protected
void
setUp
()
throws
Exception
{
detector
=
FeatureDetector
.
create
(
FeatureDetector
.
FAST
);
truth
=
new
KeyPoint
[]
{
new
KeyPoint
(
32
,
27
,
6
,
-
1
,
254
,
0
,
-
1
),
new
KeyPoint
(
27
,
32
,
6
,
-
1
,
254
,
0
,
-
1
),
new
KeyPoint
(
73
,
68
,
6
,
-
1
,
254
,
0
,
-
1
),
truth
=
new
KeyPoint
[]
{
new
KeyPoint
(
32
,
27
,
6
,
-
1
,
254
,
0
,
-
1
),
new
KeyPoint
(
27
,
32
,
6
,
-
1
,
254
,
0
,
-
1
),
new
KeyPoint
(
73
,
68
,
6
,
-
1
,
254
,
0
,
-
1
),
new
KeyPoint
(
68
,
73
,
6
,
-
1
,
254
,
0
,
-
1
)
};
super
.
setUp
();
...
...
@@ -103,8 +101,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
public
void
testReadYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
writeFile
(
filename
,
writeFile
(
filename
,
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<threshold>130</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n</opencv_storage>\n"
);
detector
.
read
(
filename
);
...
...
@@ -112,8 +109,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector
.
detect
(
grayChess
,
keypoints1
);
writeFile
(
filename
,
writeFile
(
filename
,
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<threshold>150</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n</opencv_storage>\n"
);
detector
.
read
(
filename
);
...
...
modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java
0 → 100644
浏览文件 @
69588dfa
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
SURFDescriptorExtractorTest
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
.
SURF
);
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
,
64
,
CvType
.
CV_32FC1
)
{
{
put
(
0
,
0
,
0
,
0
,
0
,
0
,
0.011540107
,
0.0029440077
,
0.095483348
,
0.018144149
,
0.00014820647
,
0
,
0.00014820647
,
0
,
0
,
0
,
0
,
0
,
0
,
-
0.00014820647
,
0
,
0.00014820647
,
0.10196275
,
0.0099145742
,
0.57075155
,
0.047922116
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0.0029440068
,
-
0.011540107
,
0.018144149
,
0.095483348
,
0.085385554
,
-
0.054076977
,
0.34105155
,
0.47911066
,
0.023395451
,
-
0.11012388
,
0.088196531
,
0.50863767
,
0.0031790689
,
-
0.019882837
,
0.0089476965
,
0.054817006
,
-
0.0033560959
,
-
0.0011770058
,
0.0033560959
,
0.0011770058
,
0.019882834
,
0.0031790687
,
0.054817006
,
0.0089476984
,
0
,
0
,
0
,
0
,
-
0.0011770058
,
0.0033560959
,
0.0011770058
,
0.0033560959
);
}
};
assertMatEqual
(
truth
,
descriptors
,
EPS
);
}
public
void
testCreate
()
{
assertNotNull
(
extractor
);
}
public
void
testDescriptorSize
()
{
assertEquals
(
64
,
extractor
.
descriptorSize
());
}
public
void
testDescriptorType
()
{
assertEquals
(
CvType
.
CV_32F
,
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\nnOctaves: 4\nnOctaveLayers: 2\nextended: 1\nupright: 0\n"
);
extractor
.
read
(
filename
);
extractor
.
compute
(
img
,
keypoints
,
descriptors
);
assertEquals
(
128
,
descriptors
.
cols
());
}
public
void
testWrite
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"xml"
);
extractor
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<nOctaves>4</nOctaves>\n<nOctaveLayers>2</nOctaveLayers>\n<extended>0</extended>\n<upright>0</upright>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
public
void
testWriteYml
()
{
String
filename
=
OpenCVTestRunner
.
getTempFileName
(
"yml"
);
extractor
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nnOctaves: 4\nnOctaveLayers: 2\nextended: 0\nupright: 0\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
}
}
modules/java/android_test/src/org/opencv/test/features2d/SURFTest.java
已删除
100644 → 0
浏览文件 @
f81e6f82
package
org.opencv.test.features2d
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
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.SURF
;
import
org.opencv.test.OpenCVTestCase
;
public
class
SURFTest
extends
OpenCVTestCase
{
int
matSize
;
KeyPoint
[]
truth
;
public
void
test_1
()
{
super
.
test_1
(
"features2d.SURF"
);
}
@Override
protected
void
setUp
()
throws
Exception
{
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
getCross
()
{
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
;
}
});
}
public
void
testDescriptorSize
()
{
SURF
surf
=
new
SURF
(
500.0
,
4
,
2
,
false
);
assertEquals
(
64
,
surf
.
descriptorSize
());
surf
=
new
SURF
(
500.0
,
4
,
2
,
true
);
assertEquals
(
128
,
surf
.
descriptorSize
());
}
public
void
testDetectMatMatListOfKeyPoint_noPointsDetected
()
{
SURF
surf
=
new
SURF
(
8000
);
List
<
KeyPoint
>
keypoints
=
new
LinkedList
<
KeyPoint
>();
Mat
gray0
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
surf
.
detect
(
gray0
,
new
Mat
(),
keypoints
);
assertEquals
(
0
,
keypoints
.
size
());
}
public
void
testDetectMatMatListOfKeyPoint
()
{
SURF
surf
=
new
SURF
(
8000
);
List
<
KeyPoint
>
keypoints
=
new
LinkedList
<
KeyPoint
>();
Mat
cross
=
getCross
();
surf
.
detect
(
cross
,
new
Mat
(),
keypoints
);
assertEquals
(
truth
.
length
,
keypoints
.
size
());
order
(
keypoints
);
for
(
int
i
=
0
;
i
<
truth
.
length
;
i
++)
assertKeyPointEqual
(
truth
[
i
],
keypoints
.
get
(
i
),
EPS
);
// for(KeyPoint kp : keypoints)
// OpenCVTestRunner.Log(kp.toString());
}
public
void
testDetectMatMatListOfKeyPointListOfFloat
()
{
SURF
surf
=
new
SURF
(
8000
);
List
<
KeyPoint
>
keypoints
=
new
LinkedList
<
KeyPoint
>();
List
<
Float
>
descriptors
=
new
LinkedList
<
Float
>();
Mat
cross
=
getCross
();
surf
.
detect
(
cross
,
new
Mat
(),
keypoints
,
descriptors
);
assertEquals
(
truth
.
length
,
keypoints
.
size
());
assertEquals
(
truth
.
length
*
surf
.
descriptorSize
(),
descriptors
.
size
());
order
(
keypoints
);
for
(
int
i
=
0
;
i
<
truth
.
length
;
i
++)
assertKeyPointEqual
(
truth
[
i
],
(
KeyPoint
)
keypoints
.
get
(
i
),
EPS
);
}
public
void
testDetectMatMatListOfKeyPointListOfFloatBoolean
()
{
SURF
surf
=
new
SURF
(
8000
);
List
<
KeyPoint
>
original_keypoints
=
Arrays
.
asList
(
truth
);
List
<
KeyPoint
>
keypoints
=
new
LinkedList
<
KeyPoint
>(
original_keypoints
);
List
<
Float
>
descriptors
=
new
LinkedList
<
Float
>();
Mat
gray255
=
new
Mat
(
matSize
,
matSize
,
CvType
.
CV_8U
,
new
Scalar
(
255
));
surf
.
detect
(
gray255
,
new
Mat
(),
keypoints
,
descriptors
,
true
);
// unmodified keypoints
assertEquals
(
original_keypoints
.
size
(),
keypoints
.
size
());
for
(
int
i
=
0
;
i
<
keypoints
.
size
();
i
++)
assertKeyPointEqual
(
original_keypoints
.
get
(
i
),
keypoints
.
get
(
i
),
EPS
);
// zero descriptors
assertEquals
(
surf
.
descriptorSize
()
*
original_keypoints
.
size
(),
descriptors
.
size
());
for
(
float
d
:
descriptors
)
assertTrue
(
Math
.
abs
(
d
)
<
EPS
);
}
public
void
testSURF
()
{
SURF
surf
=
new
SURF
();
assertNotNull
(
surf
);
}
public
void
testSURFDouble
()
{
SURF
surf
=
new
SURF
(
500.0
);
assertNotNull
(
surf
);
}
public
void
testSURFDoubleInt
()
{
SURF
surf
=
new
SURF
(
500.0
,
4
);
assertNotNull
(
surf
);
}
public
void
testSURFDoubleIntInt
()
{
SURF
surf
=
new
SURF
(
500.0
,
4
,
2
);
assertNotNull
(
surf
);
}
public
void
testSURFDoubleIntIntBoolean
()
{
SURF
surf
=
new
SURF
(
500.0
,
4
,
2
,
false
);
assertNotNull
(
surf
);
}
public
void
testSURFDoubleIntIntBooleanBoolean
()
{
SURF
surf
=
new
SURF
(
500.0
,
4
,
2
,
false
,
false
);
assertNotNull
(
surf
);
}
}
modules/java/gen_java.py
浏览文件 @
69588dfa
...
...
@@ -12,7 +12,7 @@ class_ignore_list = (
#highgui
"VideoWriter"
,
"VideoCapture"
,
#features2d
"KeyPoint"
,
"MSER"
,
"StarDetector"
,
"KeyPoint"
,
"MSER"
,
"StarDetector"
,
"SURF"
,
)
const_ignore_list
=
(
...
...
modules/java/src/cpp/features2d_manual.hpp
浏览文件 @
69588dfa
...
...
@@ -230,8 +230,8 @@ public:
#if 0
CV_WRAP void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
CV_WRAP void compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, CV_OUT vector<Mat>& descriptors ) const;
CV_WRAP virtual int descriptorSize() const
= 0
;
CV_WRAP virtual int descriptorType() const
= 0
;
CV_WRAP virtual int descriptorSize() const;
CV_WRAP virtual int descriptorType() const;
CV_WRAP virtual bool empty() const;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录