Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
28a5c127
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,发现更多精彩内容 >>
提交
28a5c127
编写于
7月 16, 2013
作者:
R
Roman Donchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made the Python bindings not use deprecated NumPy 1.7 API.
上级
886c009d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
12 deletion
+25
-12
modules/python/src2/cv2.cpp
modules/python/src2/cv2.cpp
+21
-12
modules/python/src2/cv2.cv.hpp
modules/python/src2/cv2.cv.hpp
+4
-0
未找到文件。
modules/python/src2/cv2.cpp
浏览文件 @
28a5c127
...
...
@@ -6,6 +6,7 @@
#define MODULESTR "cv2"
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include "numpy/ndarrayobject.h"
#include "opencv2/core/core.hpp"
...
...
@@ -193,10 +194,10 @@ public:
if
(
!
o
)
CV_Error_
(
CV_StsError
,
(
"The numpy array of typenum=%d, ndims=%d can not be created"
,
typenum
,
dims
));
refcount
=
refcountFromPyObject
(
o
);
npy_intp
*
_strides
=
PyArray_STRIDES
(
o
);
npy_intp
*
_strides
=
PyArray_STRIDES
(
(
PyArrayObject
*
)
o
);
for
(
i
=
0
;
i
<
dims
-
(
cn
>
1
);
i
++
)
step
[
i
]
=
(
size_t
)
_strides
[
i
];
datastart
=
data
=
(
uchar
*
)
PyArray_DATA
(
o
);
datastart
=
data
=
(
uchar
*
)
PyArray_DATA
(
(
PyArrayObject
*
)
o
);
}
void
deallocate
(
int
*
refcount
,
uchar
*
,
uchar
*
)
...
...
@@ -263,8 +264,10 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
return
false
;
}
PyArrayObject
*
oarr
=
(
PyArrayObject
*
)
o
;
bool
needcopy
=
false
,
needcast
=
false
;
int
typenum
=
PyArray_TYPE
(
o
),
new_typenum
=
typenum
;
int
typenum
=
PyArray_TYPE
(
o
arr
),
new_typenum
=
typenum
;
int
type
=
typenum
==
NPY_UBYTE
?
CV_8U
:
typenum
==
NPY_BYTE
?
CV_8S
:
typenum
==
NPY_USHORT
?
CV_16U
:
...
...
@@ -289,7 +292,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
}
}
int
ndims
=
PyArray_NDIM
(
o
);
int
ndims
=
PyArray_NDIM
(
o
arr
);
if
(
ndims
>=
CV_MAX_DIM
)
{
failmsg
(
"%s dimensionality (=%d) is too high"
,
info
.
name
,
ndims
);
...
...
@@ -298,8 +301,8 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
int
size
[
CV_MAX_DIM
+
1
];
size_t
step
[
CV_MAX_DIM
+
1
],
elemsize
=
CV_ELEM_SIZE1
(
type
);
const
npy_intp
*
_sizes
=
PyArray_DIMS
(
o
);
const
npy_intp
*
_strides
=
PyArray_STRIDES
(
o
);
const
npy_intp
*
_sizes
=
PyArray_DIMS
(
o
arr
);
const
npy_intp
*
_strides
=
PyArray_STRIDES
(
o
arr
);
bool
ismultichannel
=
ndims
==
3
&&
_sizes
[
2
]
<=
CV_CN_MAX
;
for
(
int
i
=
ndims
-
1
;
i
>=
0
&&
!
needcopy
;
i
--
)
...
...
@@ -323,11 +326,17 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
failmsg
(
"Layout of the output array %s is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)"
,
info
.
name
);
return
false
;
}
if
(
needcast
)
o
=
(
PyObject
*
)
PyArray_Cast
((
PyArrayObject
*
)
o
,
new_typenum
);
else
o
=
(
PyObject
*
)
PyArray_GETCONTIGUOUS
((
PyArrayObject
*
)
o
);
_strides
=
PyArray_STRIDES
(
o
);
if
(
needcast
)
{
o
=
PyArray_Cast
(
oarr
,
new_typenum
);
oarr
=
(
PyArrayObject
*
)
o
;
}
else
{
oarr
=
PyArray_GETCONTIGUOUS
(
oarr
);
o
=
(
PyObject
*
)
oarr
;
}
_strides
=
PyArray_STRIDES
(
oarr
);
}
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
...
...
@@ -355,7 +364,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
return
false
;
}
m
=
Mat
(
ndims
,
size
,
type
,
PyArray_DATA
(
o
),
step
);
m
=
Mat
(
ndims
,
size
,
type
,
PyArray_DATA
(
o
arr
),
step
);
if
(
m
.
data
)
{
...
...
modules/python/src2/cv2.cv.hpp
浏览文件 @
28a5c127
...
...
@@ -510,7 +510,11 @@ static void arrayinterface_common(PyArrayInterface *s, int mtype)
assert
(
0
);
}
#ifdef NPY_1_7_API_VERSION
s
->
flags
=
NPY_ARRAY_WRITEABLE
|
NPY_ARRAY_NOTSWAPPED
;
#else
s
->
flags
=
NPY_WRITEABLE
|
NPY_NOTSWAPPED
;
#endif
}
static
PyObject
*
cvmat_array_struct
(
cvmat_t
*
cva
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录