Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
3a4e06e2
Commit
3a4e06e2
authored
May 31, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolved ticket #1104 (processing of transposed numpy arrays)
parent
ef5d7278
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
cv2.cpp
modules/python/src2/cv2.cpp
+16
-0
No files found.
modules/python/src2/cv2.cpp
View file @
3a4e06e2
...
...
@@ -179,6 +179,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const char* name = "<unknown>"
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
);
bool
transposed
=
false
;
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
...
...
@@ -192,6 +193,13 @@ static int pyopencv_to(const PyObject* o, Mat& m, const char* name = "<unknown>"
ndims
++
;
}
if
(
ndims
>=
2
&&
step
[
0
]
<
step
[
1
]
)
{
std
::
swap
(
size
[
0
],
size
[
1
]);
std
::
swap
(
step
[
0
],
step
[
1
]);
transposed
=
true
;
}
if
(
ndims
==
3
&&
size
[
2
]
<=
CV_CN_MAX
&&
step
[
1
]
==
elemsize
*
size
[
2
]
)
{
ndims
--
;
...
...
@@ -213,6 +221,14 @@ static int pyopencv_to(const PyObject* o, Mat& m, const char* name = "<unknown>"
// (since Mat destructor will decrement the reference counter)
};
m
.
allocator
=
&
g_numpyAllocator
;
if
(
transposed
)
{
Mat
tmp
;
tmp
.
allocator
=
&
g_numpyAllocator
;
transpose
(
m
,
tmp
);
m
=
tmp
;
}
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment