Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
9235a801
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
9235a801
编写于
7月 27, 2011
作者:
A
Andrey Pavlenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Java API generator: KeyPoint converters from/to Mat
上级
20b4d0fa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
30 deletion
+76
-30
modules/java/gen_java.py
modules/java/gen_java.py
+1
-1
modules/java/src/cpp/converters.cpp
modules/java/src/cpp/converters.cpp
+15
-6
modules/java/src/java/Converters.java
modules/java/src/java/Converters.java
+48
-11
modules/java/src/java/features2d+KeyPoint.java
modules/java/src/java/features2d+KeyPoint.java
+12
-12
未找到文件。
modules/java/gen_java.py
浏览文件 @
9235a801
...
...
@@ -11,7 +11,7 @@ class_ignore_list = (
"FileNode"
,
"FileStorage"
,
#highgui
"VideoWriter"
,
"VideoCapture"
,
#feature2d
#feature
s
2d
"KeyPoint"
,
)
...
...
modules/java/src/cpp/converters.cpp
浏览文件 @
9235a801
...
...
@@ -114,17 +114,27 @@ void vector_Point_to_Mat(vector<Point>& v_point, Mat& mat)
//vector_KeyPoint
void
Mat_to_vector_KeyPoint
(
Mat
&
mat
,
vector
<
KeyPoint
>&
v_kp
)
{
v_kp
.
clear
();
//CHECK_MAT(mat.type()!= ??? || mat.rows!=1);
v_kp
=
(
vector
<
KeyPoint
>
)
mat
;
v_kp
.
clear
();
CHECK_MAT
(
mat
.
type
()
!=
CV_64FC
(
7
)
||
mat
.
rows
!=
1
);
for
(
int
i
=
0
;
i
<
mat
.
cols
;
i
++
)
{
Vec
<
double
,
7
>
v
=
mat
.
at
<
Vec
<
double
,
7
>
>
(
0
,
i
);
KeyPoint
kp
((
float
)
v
[
0
],
(
float
)
v
[
1
],
(
float
)
v
[
2
],
(
float
)
v
[
3
],
(
float
)
v
[
4
],
(
int
)
v
[
5
],
(
int
)
v
[
6
]);
v_kp
.
push_back
(
kp
);
}
return
;
}
void
vector_KeyPoint_to_Mat
(
vector
<
KeyPoint
>&
v_kp
,
Mat
&
mat
)
{
mat
=
Mat
(
v_kp
);
return
;
int
count
=
v_kp
.
size
();
mat
.
create
(
1
,
count
,
CV_64FC
(
7
));
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
KeyPoint
kp
=
v_kp
[
i
];
mat
.
at
<
Vec
<
double
,
7
>
>
(
0
,
i
)
=
Vec
<
double
,
7
>
(
kp
.
pt
.
x
,
kp
.
pt
.
y
,
kp
.
size
,
kp
.
angle
,
kp
.
response
,
kp
.
octave
,
kp
.
class_id
);
}
}
...
...
@@ -154,5 +164,4 @@ void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
long
long
addr
=
(
long
long
)
new
Mat
(
v_mat
[
i
]);
mat
.
at
<
Vec
<
int
,
2
>
>
(
0
,
i
)
=
Vec
<
int
,
2
>
(
addr
>>
32
,
addr
&
0xffffffff
);
}
return
;
}
modules/java/src/java/Converters.java
浏览文件 @
9235a801
...
...
@@ -9,7 +9,7 @@ import org.opencv.core.Rect;
import
org.opencv.features2d.KeyPoint
;
public
class
Converters
{
public
static
Mat
vector_Point_to_Mat
(
List
<
Point
>
pts
)
{
Mat
res
;
int
count
=
(
pts
!=
null
)
?
pts
.
size
()
:
0
;
...
...
@@ -52,7 +52,7 @@ public class Converters {
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_32SC2
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
pts
.
clear
();
int
[]
buff
=
new
int
[
2
*
cols
];
m
.
get
(
0
,
0
,
buff
);
...
...
@@ -85,7 +85,7 @@ public class Converters {
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_32SC2
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
mats
.
clear
();
int
[]
buff
=
new
int
[
cols
*
2
];
m
.
get
(
0
,
0
,
buff
);
...
...
@@ -95,10 +95,6 @@ public class Converters {
}
}
public
static
void
Mat_to_vector_KeyPoint
(
Mat
kp_mat
,
List
<
KeyPoint
>
kps
)
{
// TODO Auto-generated method stub
}
public
static
Mat
vector_float_to_Mat
(
List
<
Float
>
fs
)
{
Mat
res
;
int
count
=
(
fs
!=
null
)
?
fs
.
size
()
:
0
;
...
...
@@ -122,7 +118,7 @@ public class Converters {
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_32FC1
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
fs
.
clear
();
float
[]
buff
=
new
float
[
cols
];
m
.
get
(
0
,
0
,
buff
);
...
...
@@ -171,7 +167,7 @@ public class Converters {
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_32SC1
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
is
.
clear
();
int
[]
buff
=
new
int
[
cols
];
m
.
get
(
0
,
0
,
buff
);
...
...
@@ -184,7 +180,7 @@ public class Converters {
Mat
res
;
int
count
=
(
rs
!=
null
)
?
rs
.
size
()
:
0
;
if
(
count
>
0
){
res
=
new
Mat
(
1
,
count
,
CvType
.
CV_32SC4
);
//Point can be saved into double[2]
res
=
new
Mat
(
1
,
count
,
CvType
.
CV_32SC4
);
int
[]
buff
=
new
int
[
4
*
count
];
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Rect
r
=
rs
.
get
(
i
);
...
...
@@ -206,7 +202,7 @@ public class Converters {
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_32SC4
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
rs
.
clear
();
int
[]
buff
=
new
int
[
4
*
cols
];
m
.
get
(
0
,
0
,
buff
);
...
...
@@ -215,6 +211,47 @@ public class Converters {
}
}
public
static
Mat
vector_KeyPoint_to_Mat
(
List
<
KeyPoint
>
kps
)
{
Mat
res
;
int
count
=
(
kps
!=
null
)
?
kps
.
size
()
:
0
;
if
(
count
>
0
){
res
=
new
Mat
(
1
,
count
,
CvType
.
CV_64FC
(
7
));
double
[]
buff
=
new
double
[
count
*
7
];
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
KeyPoint
kp
=
kps
.
get
(
i
);
buff
[
7
*
i
]
=
kp
.
pt
.
x
;
buff
[
7
*
i
+
1
]
=
kp
.
pt
.
y
;
buff
[
7
*
i
+
2
]
=
kp
.
size
;
buff
[
7
*
i
+
3
]
=
kp
.
angle
;
buff
[
7
*
i
+
4
]
=
kp
.
response
;
buff
[
7
*
i
+
5
]
=
kp
.
octave
;
buff
[
7
*
i
+
6
]
=
kp
.
class_id
;
}
res
.
put
(
0
,
0
,
buff
);
}
else
{
res
=
new
Mat
();
}
return
res
;
}
public
static
void
Mat_to_vector_KeyPoint
(
Mat
m
,
List
<
KeyPoint
>
kps
)
{
if
(
kps
==
null
)
throw
new
java
.
lang
.
IllegalArgumentException
();
int
cols
=
m
.
cols
();
if
(
CvType
.
CV_64FC
(
7
)
!=
m
.
type
()
||
m
.
rows
()!=
1
)
throw
new
java
.
lang
.
IllegalArgumentException
();
kps
.
clear
();
double
[]
buff
=
new
double
[
7
*
cols
];
m
.
get
(
0
,
0
,
buff
);
for
(
int
i
=
0
;
i
<
cols
;
i
++)
{
kps
.
add
(
new
KeyPoint
(
(
float
)
buff
[
4
*
i
],
(
float
)
buff
[
4
*
i
+
1
],
(
float
)
buff
[
4
*
i
+
2
],
(
float
)
buff
[
4
*
i
+
3
],
(
float
)
buff
[
4
*
i
+
4
],
(
int
)
buff
[
4
*
i
+
5
],
(
int
)
buff
[
4
*
i
+
6
]
)
);
}
}
public
static
Mat
vector_double_to_Mat
(
List
<
Double
>
ds
)
{
Mat
res
;
int
count
=
(
ds
!=
null
)
?
ds
.
size
()
:
0
;
...
...
modules/java/src/java/features2d+KeyPoint.java
浏览文件 @
9235a801
...
...
@@ -5,18 +5,18 @@ import org.opencv.core.Point;
//javadoc: KeyPoint
public
class
KeyPoint
{
//javadoc: KeyPoint::pt
Point
pt
;
//javadoc: KeyPoint::size
float
size
;
//javadoc: KeyPoint::angle
float
angle
;
//javadoc: KeyPoint::response
float
response
;
//javadoc: KeyPoint::octave
int
octave
;
//javadoc: KeyPoint::class_id
int
class_id
;
//javadoc: KeyPoint::pt
public
Point
pt
;
//javadoc: KeyPoint::size
public
float
size
;
//javadoc: KeyPoint::angle
public
float
angle
;
//javadoc: KeyPoint::response
public
float
response
;
//javadoc: KeyPoint::octave
public
int
octave
;
//javadoc: KeyPoint::class_id
public
int
class_id
;
//javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave, _class_id)
public
KeyPoint
(
float
x
,
float
y
,
float
_size
,
float
_angle
,
float
_response
,
int
_octave
,
int
_class_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录