Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
自由之枫~
opencv
提交
ff90c3eb
O
opencv
项目概览
自由之枫~
/
opencv
与 Fork 源项目一致
Fork自
OpenCV / opencv
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ff90c3eb
编写于
8月 13, 2012
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
possibly fixes #2242 and #2257
上级
941897aa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
9 deletion
+32
-9
modules/python/src2/cv2.cpp
modules/python/src2/cv2.cpp
+32
-9
未找到文件。
modules/python/src2/cv2.cpp
浏览文件 @
ff90c3eb
...
...
@@ -229,17 +229,29 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
return
false
;
}
int
typenum
=
PyArray_TYPE
(
o
);
int
type
=
typenum
==
NPY_UBYTE
?
CV_8U
:
typenum
==
NPY_BYTE
?
CV_8S
:
typenum
==
NPY_USHORT
?
CV_16U
:
typenum
==
NPY_SHORT
?
CV_16S
:
typenum
==
NPY_INT
||
typenum
==
NPY_LONG
?
CV_32S
:
bool
needcopy
=
false
,
needcast
=
false
;
int
typenum
=
PyArray_TYPE
(
o
),
new_typenum
=
typenum
;
int
type
=
typenum
==
NPY_UBYTE
?
CV_8U
:
typenum
==
NPY_BYTE
?
CV_8S
:
typenum
==
NPY_USHORT
?
CV_16U
:
typenum
==
NPY_SHORT
?
CV_16S
:
typenum
==
NPY_INT32
?
CV_32S
:
typenum
==
NPY_FLOAT
?
CV_32F
:
typenum
==
NPY_DOUBLE
?
CV_64F
:
-
1
;
if
(
type
<
0
)
{
failmsg
(
"%s data type = %d is not supported"
,
info
.
name
,
typenum
);
return
false
;
if
(
typenum
==
NPY_INT64
||
typenum
==
NPY_UINT64
||
type
==
NPY_LONG
)
{
needcopy
=
needcast
=
true
;
new_typenum
=
NPY_INT32
;
type
=
CV_32S
;
}
else
{
failmsg
(
"%s data type = %d is not supported"
,
info
.
name
,
typenum
);
return
false
;
}
}
int
ndims
=
PyArray_NDIM
(
o
);
...
...
@@ -255,8 +267,16 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
const
npy_intp
*
_strides
=
PyArray_STRIDES
(
o
);
bool
ismultichannel
=
ndims
==
3
&&
_sizes
[
2
]
<=
CV_CN_MAX
;
bool
needcopy
=
(
_strides
[
ndims
-
1
]
!=
elemsize
)
||
(
ismultichannel
&&
_strides
[
ndims
-
2
]
!=
elemsize
*
_sizes
[
ndims
-
1
]);
for
(
int
i
=
ndims
-
1
;
i
>=
0
&&
!
needcopy
;
i
--
)
{
// these checks handle cases of
// a) multi-dimensional (ndims > 2) arrays, as well as simpler 1- and 2-dimensional cases
// b) transposed arrays, where _strides[] elements go in non-descending order
// c) flipped arrays, where some of _strides[] elements are negative
if
(
(
i
==
ndims
-
1
&&
(
size_t
)
_strides
[
i
]
!=
elemsize
)
||
(
i
<
ndims
-
1
&&
_strides
[
i
]
<
_strides
[
i
+
1
])
)
needcopy
=
true
;
}
if
(
needcopy
)
{
...
...
@@ -265,7 +285,10 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
failmsg
(
"output array %s is not row-contiguous (step[ndims-1] != elemsize)"
,
info
.
name
);
return
false
;
}
o
=
(
PyObject
*
)
PyArray_GETCONTIGUOUS
((
PyArrayObject
*
)
o
);
if
(
needcast
)
o
=
(
PyObject
*
)
PyArray_Cast
((
PyArrayObject
*
)
o
,
new_typenum
);
else
o
=
(
PyObject
*
)
PyArray_GETCONTIGUOUS
((
PyArrayObject
*
)
o
);
_strides
=
PyArray_STRIDES
(
o
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录