Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d989b6c8
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
d989b6c8
编写于
7月 18, 2011
作者:
A
Andrey Pavlenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Java API: added pointers support (Point*, double*)
上级
51922658
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
60 addition
and
39 deletion
+60
-39
modules/java/gen_java.py
modules/java/gen_java.py
+60
-39
未找到文件。
modules/java/gen_java.py
浏览文件 @
d989b6c8
...
...
@@ -215,7 +215,12 @@ class ClassInfo(object):
class
ArgInfo
(
object
):
def
__init__
(
self
,
arg_tuple
):
# [ ctype, name, def val, [mod], argno ]
self
.
ctype
=
arg_tuple
[
0
]
self
.
pointer
=
False
ctype
=
arg_tuple
[
0
]
if
ctype
.
endswith
(
"*"
):
ctype
=
ctype
[:
-
1
]
self
.
pointer
=
True
self
.
ctype
=
ctype
self
.
name
=
arg_tuple
[
1
]
self
.
defval
=
arg_tuple
[
2
]
self
.
out
=
""
...
...
@@ -674,9 +679,20 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_n_1getTextSize
# // C++: c_decl
# e.g:
# // C++: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), int dtype = -1)
c_decl
=
"%s %s %s(%s)"
%
\
(
fi
.
static
,
fi
.
ctype
,
fi
.
cname
,
\
", "
.
join
(
a
.
ctype
+
" "
+
a
.
name
+
[
""
,
" = "
+
a
.
defval
][
bool
(
a
.
defval
)]
for
a
in
fi
.
args
)
)
decl_args
=
[]
for
a
in
fi
.
args
:
s
=
a
.
ctype
if
a
.
pointer
:
s
+=
"*"
elif
a
.
out
:
s
+=
"&"
s
+=
" "
+
a
.
name
if
a
.
defval
:
s
+=
" = "
+
a
.
defval
decl_args
.
append
(
s
)
c_decl
=
"%s %s %s(%s)"
%
(
fi
.
static
,
fi
.
ctype
,
fi
.
cname
,
", "
.
join
(
decl_args
)
)
indent
=
" "
*
4
if
fi
.
classname
:
indent
+=
" "
*
4
...
...
@@ -723,14 +739,12 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_n_1getTextSize
c_prologue
=
[]
c_epilogue
=
[]
if
type_dict
[
fi
.
ctype
][
"jni_type"
]
==
"jdoubleArray"
:
fields
=
type_dict
[
fi
.
ctype
].
get
(
"jn_args"
)
if
fields
:
fields
=
type_dict
[
fi
.
ctype
][
"jn_args"
]
c_epilogue
.
append
(
\
"jdoubleArray _da_retval_ = env->NewDoubleArray(6); /* assuming '6' is enough*/ "
+
"jdouble _tmp_retval_[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(_da_retval_, 0, %(cnt)i, _tmp_retval_);"
%
(
"jdoubleArray _da_retval_ = env->NewDoubleArray(%(cnt)i); "
+
"jdouble _tmp_retval_[%(cnt)i] = {%(args)s}; "
+
"env->SetDoubleArrayRegion(_da_retval_, 0, %(cnt)i, _tmp_retval_);"
)
%
{
"cnt"
:
len
(
fields
),
"args"
:
", "
.
join
([
"_retval_"
+
f
[
1
]
for
f
in
fields
])
}
)
else
:
c_epilogue
.
append
(
"/* TODO: NYI !!! */"
)
if
fi
.
classname
and
fi
.
ctype
and
not
fi
.
static
:
# non-static class method except c-tor
# adding 'self'
jn_args
.
append
(
ArgInfo
([
"__int64"
,
"nativeObj"
,
""
,
[],
""
])
)
...
...
@@ -756,27 +770,28 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_n_1getTextSize
fields
=
type_dict
[
a
.
ctype
].
get
(
"jn_args"
)
if
fields
:
# complex type
if
"I"
in
a
.
out
or
not
a
.
out
or
a
.
ctype
in
self
.
classes
:
# input arg, pass by primitive fields
for
f
in
fields
:
jn_args
.
append
(
ArgInfo
([
f
[
0
],
a
.
name
+
f
[
1
],
""
,
[],
""
])
)
jni_args
.
append
(
ArgInfo
([
f
[
0
],
a
.
name
+
f
[
1
].
replace
(
"."
,
"_"
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
),
""
,
[],
""
])
)
else
:
jn_args
.
append
(
a
)
jni_args
.
append
(
a
)
if
a
.
out
and
a
.
ctype
not
in
self
.
classes
:
# pass as double[]
if
a
.
out
and
a
.
ctype
not
in
self
.
classes
:
# out args, pass as double[]
jn_args
.
append
(
ArgInfo
([
"double[]"
,
"%s_out"
%
a
.
name
,
""
,
[],
""
])
)
#jn_args.append ( ArgInfo([ "int", "%s_out.length" % a.name, "", [], "" ]) )
jni_args
.
append
(
ArgInfo
([
"double[]"
,
"%s_out"
%
a
.
name
,
""
,
[],
""
])
)
#jni_args.append ( ArgInfo([ "int", "%s_out_length" % a.name, "", [], "" ]) )
j_prologue
.
append
(
"double[] %s_out = new double[%i];"
%
(
a
.
name
,
len
(
type_dict
[
a
.
ctype
].
get
(
"jn_args"
,
[
1
])))
)
if
fields
:
j_prologue
.
append
(
"double[] %s_out = new double[%i];"
%
(
a
.
name
,
len
(
fields
))
)
j_epilogue
.
append
(
"%s.set(%s_out);"
%
(
a
.
name
,
a
.
name
))
c_epilogue
.
append
(
\
"jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);"
%
{
"n"
:
a
.
name
,
"cnt"
:
len
(
fields
),
"args"
:
", "
.
join
([
a
.
name
+
f
[
1
]
for
f
in
fields
])
}
)
else
:
j_epilogue
.
append
(
"/* TODO: NYI: %s.set(%s_out); */"
%
(
a
.
name
,
a
.
name
))
else
:
# primitive type
if
"I"
in
a
.
out
or
not
a
.
out
:
# input arg, pass by primitive fields
jn_args
.
append
(
a
)
jni_args
.
append
(
a
)
if
a
.
out
and
a
.
ctype
not
in
self
.
classes
:
# out args, pass as double[]
jn_args
.
append
(
ArgInfo
([
"double[]"
,
"%s_out"
%
a
.
name
,
""
,
[],
""
])
)
jni_args
.
append
(
ArgInfo
([
"double[]"
,
"%s_out"
%
a
.
name
,
""
,
[],
""
])
)
j_prologue
.
append
(
"double[] %s_out = new double[1];"
%
a
.
name
)
j_epilogue
.
append
(
"%s = %s_out[0];"
%
(
a
.
name
,
a
.
name
))
c_epilogue
.
append
(
\
"jdouble tmp_%(n)s[1] = {%(n)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, 1, tmp_%(n)s);"
%
{
"n"
:
a
.
name
}
)
...
...
@@ -872,7 +887,6 @@ $indent}
ret
=
"return _da_retval_;"
cvname
=
"cv::"
+
fi
.
name
#j2cvargs = []
retval
=
fi
.
ctype
+
" _retval_ = "
if
fi
.
ctype
==
"void"
:
retval
=
""
...
...
@@ -890,9 +904,16 @@ $indent}
)
cvargs
=
[]
for
a
in
args
:
cvargs
.
append
(
type_dict
[
a
.
ctype
].
get
(
"jni_name"
,
"%(n)s"
)
%
{
"n"
:
a
.
name
})
if
"vector"
not
in
a
.
ctype
and
"jni_var"
in
type_dict
[
a
.
ctype
]:
# complex type
if
a
.
pointer
:
jni_name
=
"&%(n)s"
else
:
jni_name
=
"%(n)s"
cvargs
.
append
(
type_dict
[
a
.
ctype
].
get
(
"jni_name"
,
jni_name
)
%
{
"n"
:
a
.
name
})
if
"vector"
not
in
a
.
ctype
:
if
(
"I"
in
a
.
out
or
not
a
.
out
or
a
.
ctype
in
self
.
classes
)
and
"jni_var"
in
type_dict
[
a
.
ctype
]:
# complex type
c_prologue
.
append
(
type_dict
[
a
.
ctype
][
"jni_var"
]
%
{
"n"
:
a
.
name
}
+
";"
)
if
a
.
out
and
"I"
not
in
a
.
out
and
a
.
ctype
not
in
self
.
classes
:
c_prologue
.
append
(
"%s %s;"
%
(
a
.
ctype
,
a
.
name
))
rtype
=
type_dict
[
fi
.
ctype
].
get
(
"jni_type"
,
"jdoubleArray"
)
self
.
cpp_code
.
write
(
Template
(
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录