Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
c331a214
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,发现更多精彩内容 >>
提交
c331a214
编写于
9月 10, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12054 from alalek:debug_bindings
上级
c35c5a47
95dd4b3f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
210 addition
and
1 deletion
+210
-1
modules/core/include/opencv2/core/bindings_utils.hpp
modules/core/include/opencv2/core/bindings_utils.hpp
+23
-0
modules/core/src/bindings_utils.cpp
modules/core/src/bindings_utils.cpp
+145
-0
modules/python/test/test_misc.py
modules/python/test/test_misc.py
+39
-0
modules/python/test/tests_common.py
modules/python/test/tests_common.py
+3
-1
未找到文件。
modules/core/include/opencv2/core/bindings_utils.hpp
0 → 100644
浏览文件 @
c331a214
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CORE_BINDINGS_UTILS_HPP
#define OPENCV_CORE_BINDINGS_UTILS_HPP
namespace
cv
{
namespace
utils
{
//! @addtogroup core_utils
//! @{
CV_EXPORTS_W
String
dumpInputArray
(
InputArray
argument
);
CV_EXPORTS_W
String
dumpInputArrayOfArrays
(
InputArrayOfArrays
argument
);
CV_EXPORTS_W
String
dumpInputOutputArray
(
InputOutputArray
argument
);
CV_EXPORTS_W
String
dumpInputOutputArrayOfArrays
(
InputOutputArrayOfArrays
argument
);
//! @}
}}
// namespace
#endif // OPENCV_CORE_BINDINGS_UTILS_HPP
modules/core/src/bindings_utils.cpp
0 → 100644
浏览文件 @
c331a214
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "precomp.hpp"
#include "opencv2/core/bindings_utils.hpp"
#include <sstream>
namespace
cv
{
namespace
utils
{
String
dumpInputArray
(
InputArray
argument
)
{
if
(
&
argument
==
&
noArray
())
return
"InputArray: noArray()"
;
std
::
ostringstream
ss
;
ss
<<
"InputArray:"
;
try
{
do
{
ss
<<
(
argument
.
empty
()
?
" empty()=true"
:
" empty()=false"
);
ss
<<
cv
::
format
(
" kind=0x%08llx"
,
(
long
long
int
)
argument
.
kind
());
ss
<<
cv
::
format
(
" flags=0x%08llx"
,
(
long
long
int
)
argument
.
getFlags
());
if
(
argument
.
getObj
()
==
NULL
)
{
ss
<<
" obj=NULL"
;
break
;
// done
}
ss
<<
cv
::
format
(
" total(-1)=%lld"
,
(
long
long
int
)
argument
.
total
(
-
1
));
ss
<<
cv
::
format
(
" dims(-1)=%d"
,
argument
.
dims
(
-
1
));
Size
size
=
argument
.
size
(
-
1
);
ss
<<
cv
::
format
(
" size(-1)=%dx%d"
,
size
.
width
,
size
.
height
);
ss
<<
" type(-1)="
<<
cv
::
typeToString
(
argument
.
type
(
-
1
));
}
while
(
0
);
}
catch
(...)
{
ss
<<
" ERROR: exception occured, dump is non-complete"
;
// need to properly support different kinds
}
return
ss
.
str
();
}
CV_EXPORTS_W
String
dumpInputArrayOfArrays
(
InputArrayOfArrays
argument
)
{
if
(
&
argument
==
&
noArray
())
return
"InputArrayOfArrays: noArray()"
;
std
::
ostringstream
ss
;
ss
<<
"InputArrayOfArrays:"
;
try
{
do
{
ss
<<
(
argument
.
empty
()
?
" empty()=true"
:
" empty()=false"
);
ss
<<
cv
::
format
(
" kind=0x%08llx"
,
(
long
long
int
)
argument
.
kind
());
ss
<<
cv
::
format
(
" flags=0x%08llx"
,
(
long
long
int
)
argument
.
getFlags
());
if
(
argument
.
getObj
()
==
NULL
)
{
ss
<<
" obj=NULL"
;
break
;
// done
}
ss
<<
cv
::
format
(
" total(-1)=%lld"
,
(
long
long
int
)
argument
.
total
(
-
1
));
ss
<<
cv
::
format
(
" dims(-1)=%d"
,
argument
.
dims
(
-
1
));
Size
size
=
argument
.
size
(
-
1
);
ss
<<
cv
::
format
(
" size(-1)=%dx%d"
,
size
.
width
,
size
.
height
);
if
(
argument
.
total
(
-
1
)
>
0
)
{
ss
<<
" type(0)="
<<
cv
::
typeToString
(
argument
.
type
(
0
));
ss
<<
cv
::
format
(
" dims(0)=%d"
,
argument
.
dims
(
0
));
size
=
argument
.
size
(
0
);
ss
<<
cv
::
format
(
" size(0)=%dx%d"
,
size
.
width
,
size
.
height
);
ss
<<
" type(0)="
<<
cv
::
typeToString
(
argument
.
type
(
0
));
}
}
while
(
0
);
}
catch
(...)
{
ss
<<
" ERROR: exception occured, dump is non-complete"
;
// need to properly support different kinds
}
return
ss
.
str
();
}
CV_EXPORTS_W
String
dumpInputOutputArray
(
InputOutputArray
argument
)
{
if
(
&
argument
==
&
noArray
())
return
"InputOutputArray: noArray()"
;
std
::
ostringstream
ss
;
ss
<<
"InputOutputArray:"
;
try
{
do
{
ss
<<
(
argument
.
empty
()
?
" empty()=true"
:
" empty()=false"
);
ss
<<
cv
::
format
(
" kind=0x%08llx"
,
(
long
long
int
)
argument
.
kind
());
ss
<<
cv
::
format
(
" flags=0x%08llx"
,
(
long
long
int
)
argument
.
getFlags
());
if
(
argument
.
getObj
()
==
NULL
)
{
ss
<<
" obj=NULL"
;
break
;
// done
}
ss
<<
cv
::
format
(
" total(-1)=%lld"
,
(
long
long
int
)
argument
.
total
(
-
1
));
ss
<<
cv
::
format
(
" dims(-1)=%d"
,
argument
.
dims
(
-
1
));
Size
size
=
argument
.
size
(
-
1
);
ss
<<
cv
::
format
(
" size(-1)=%dx%d"
,
size
.
width
,
size
.
height
);
ss
<<
" type(-1)="
<<
cv
::
typeToString
(
argument
.
type
(
-
1
));
}
while
(
0
);
}
catch
(...)
{
ss
<<
" ERROR: exception occured, dump is non-complete"
;
// need to properly support different kinds
}
return
ss
.
str
();
}
CV_EXPORTS_W
String
dumpInputOutputArrayOfArrays
(
InputOutputArrayOfArrays
argument
)
{
if
(
&
argument
==
&
noArray
())
return
"InputOutputArrayOfArrays: noArray()"
;
std
::
ostringstream
ss
;
ss
<<
"InputOutputArrayOfArrays:"
;
try
{
do
{
ss
<<
(
argument
.
empty
()
?
" empty()=true"
:
" empty()=false"
);
ss
<<
cv
::
format
(
" kind=0x%08llx"
,
(
long
long
int
)
argument
.
kind
());
ss
<<
cv
::
format
(
" flags=0x%08llx"
,
(
long
long
int
)
argument
.
getFlags
());
if
(
argument
.
getObj
()
==
NULL
)
{
ss
<<
" obj=NULL"
;
break
;
// done
}
ss
<<
cv
::
format
(
" total(-1)=%lld"
,
(
long
long
int
)
argument
.
total
(
-
1
));
ss
<<
cv
::
format
(
" dims(-1)=%d"
,
argument
.
dims
(
-
1
));
Size
size
=
argument
.
size
(
-
1
);
ss
<<
cv
::
format
(
" size(-1)=%dx%d"
,
size
.
width
,
size
.
height
);
if
(
argument
.
total
(
-
1
)
>
0
)
{
ss
<<
" type(0)="
<<
cv
::
typeToString
(
argument
.
type
(
0
));
ss
<<
cv
::
format
(
" dims(0)=%d"
,
argument
.
dims
(
0
));
size
=
argument
.
size
(
0
);
ss
<<
cv
::
format
(
" size(0)=%dx%d"
,
size
.
width
,
size
.
height
);
ss
<<
" type(0)="
<<
cv
::
typeToString
(
argument
.
type
(
0
));
}
}
while
(
0
);
}
catch
(...)
{
ss
<<
" ERROR: exception occured, dump is non-complete"
;
// need to properly support different kinds
}
return
ss
.
str
();
}
}}
// namespace
modules/python/test/test_misc.py
浏览文件 @
c331a214
...
...
@@ -46,5 +46,44 @@ class Bindings(NewOpenCVTests):
pass
class
Arguments
(
NewOpenCVTests
):
def
test_InputArray
(
self
):
res1
=
cv
.
utils
.
dumpInputArray
(
None
)
#self.assertEqual(res1, "InputArray: noArray()") # not supported
self
.
assertEqual
(
res1
,
"InputArray: empty()=true kind=0x00010000 flags=0x01010000 total(-1)=0 dims(-1)=0 size(-1)=0x0 type(-1)=CV_8UC1"
)
res2_1
=
cv
.
utils
.
dumpInputArray
((
1
,
2
))
self
.
assertEqual
(
res2_1
,
"InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=2 dims(-1)=2 size(-1)=1x2 type(-1)=CV_64FC1"
)
res2_2
=
cv
.
utils
.
dumpInputArray
(
1.5
)
# Scalar(1.5, 1.5, 1.5, 1.5)
self
.
assertEqual
(
res2_2
,
"InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=4 dims(-1)=2 size(-1)=1x4 type(-1)=CV_64FC1"
)
a
=
np
.
array
([[
1
,
2
],[
3
,
4
],[
5
,
6
]])
res3
=
cv
.
utils
.
dumpInputArray
(
a
)
# 32SC1
self
.
assertEqual
(
res3
,
"InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=6 dims(-1)=2 size(-1)=2x3 type(-1)=CV_32SC1"
)
a
=
np
.
array
([[[
1
,
2
],[
3
,
4
],[
5
,
6
]]],
dtype
=
'f'
)
res4
=
cv
.
utils
.
dumpInputArray
(
a
)
# 32FC2
self
.
assertEqual
(
res4
,
"InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=3 dims(-1)=2 size(-1)=3x1 type(-1)=CV_32FC2"
)
a
=
np
.
array
([[[
1
,
2
]],[[
3
,
4
]],[[
5
,
6
]]],
dtype
=
float
)
res5
=
cv
.
utils
.
dumpInputArray
(
a
)
# 64FC2
self
.
assertEqual
(
res5
,
"InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=3 dims(-1)=2 size(-1)=1x3 type(-1)=CV_64FC2"
)
def
test_InputArrayOfArrays
(
self
):
res1
=
cv
.
utils
.
dumpInputArrayOfArrays
(
None
)
#self.assertEqual(res1, "InputArray: noArray()") # not supported
self
.
assertEqual
(
res1
,
"InputArrayOfArrays: empty()=true kind=0x00050000 flags=0x01050000 total(-1)=0 dims(-1)=1 size(-1)=0x0"
)
res2_1
=
cv
.
utils
.
dumpInputArrayOfArrays
((
1
,
2
))
# { Scalar:all(1), Scalar::all(2) }
self
.
assertEqual
(
res2_1
,
"InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4 type(0)=CV_64FC1"
)
res2_2
=
cv
.
utils
.
dumpInputArrayOfArrays
([
1.5
])
self
.
assertEqual
(
res2_2
,
"InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=1 dims(-1)=1 size(-1)=1x1 type(0)=CV_64FC1 dims(0)=2 size(0)=1x4 type(0)=CV_64FC1"
)
a
=
np
.
array
([[
1
,
2
],[
3
,
4
],[
5
,
6
]])
b
=
np
.
array
([[
1
,
2
,
3
],[
4
,
5
,
6
],[
7
,
8
,
9
]])
res3
=
cv
.
utils
.
dumpInputArrayOfArrays
([
a
,
b
])
self
.
assertEqual
(
res3
,
"InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=2 dims(-1)=1 size(-1)=2x1 type(0)=CV_32SC1 dims(0)=2 size(0)=2x3 type(0)=CV_32SC1"
)
c
=
np
.
array
([[[
1
,
2
],[
3
,
4
],[
5
,
6
]]],
dtype
=
'f'
)
res4
=
cv
.
utils
.
dumpInputArrayOfArrays
([
c
,
a
,
b
])
self
.
assertEqual
(
res4
,
"InputArrayOfArrays: empty()=false kind=0x00050000 flags=0x01050000 total(-1)=3 dims(-1)=1 size(-1)=3x1 type(0)=CV_32FC2 dims(0)=2 size(0)=3x1 type(0)=CV_32FC2"
)
if
__name__
==
'__main__'
:
NewOpenCVTests
.
bootstrap
()
modules/python/test/tests_common.py
浏览文件 @
c331a214
...
...
@@ -26,7 +26,9 @@ class NewOpenCVTests(unittest.TestCase):
# github repository url
repoUrl
=
'https://raw.github.com/opencv/opencv/master'
def
get_sample
(
self
,
filename
,
iscolor
=
cv
.
IMREAD_COLOR
):
def
get_sample
(
self
,
filename
,
iscolor
=
None
):
if
iscolor
is
None
:
iscolor
=
cv
.
IMREAD_COLOR
if
not
filename
in
self
.
image_cache
:
filedata
=
None
if
NewOpenCVTests
.
repoPath
is
not
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录