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
e379ea6e
Commit
e379ea6e
authored
Jul 01, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4117 from jaimefrio:relaxed_strides
parents
80eec9d5
c613ee2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
cv2.cpp
modules/python/src2/cv2.cpp
+16
-4
No files found.
modules/python/src2/cv2.cpp
View file @
e379ea6e
...
@@ -319,8 +319,9 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info)
...
@@ -319,8 +319,9 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info)
// a) multi-dimensional (ndims > 2) arrays, as well as simpler 1- and 2-dimensional cases
// 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
// b) transposed arrays, where _strides[] elements go in non-descending order
// c) flipped arrays, where some of _strides[] elements are negative
// c) flipped arrays, where some of _strides[] elements are negative
if
(
(
i
==
ndims
-
1
&&
(
size_t
)
_strides
[
i
]
!=
elemsize
)
||
// the _sizes[i] > 1 is needed to avoid spurious copies when NPY_RELAXED_STRIDES is set
(
i
<
ndims
-
1
&&
_strides
[
i
]
<
_strides
[
i
+
1
])
)
if
(
(
i
==
ndims
-
1
&&
_sizes
[
i
]
>
1
&&
(
size_t
)
_strides
[
i
]
!=
elemsize
)
||
(
i
<
ndims
-
1
&&
_sizes
[
i
]
>
1
&&
_strides
[
i
]
<
_strides
[
i
+
1
])
)
needcopy
=
true
;
needcopy
=
true
;
}
}
...
@@ -347,10 +348,21 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info)
...
@@ -347,10 +348,21 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info)
_strides
=
PyArray_STRIDES
(
oarr
);
_strides
=
PyArray_STRIDES
(
oarr
);
}
}
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
// Normalize strides in case NPY_RELAXED_STRIDES is set
size_t
default_step
=
elemsize
;
for
(
int
i
=
ndims
-
1
;
i
>=
0
;
--
i
)
{
{
size
[
i
]
=
(
int
)
_sizes
[
i
];
size
[
i
]
=
(
int
)
_sizes
[
i
];
step
[
i
]
=
(
size_t
)
_strides
[
i
];
if
(
size
[
i
]
>
1
)
{
step
[
i
]
=
(
size_t
)
_strides
[
i
];
default_step
=
step
[
i
]
*
size
[
i
];
}
else
{
step
[
i
]
=
default_step
;
default_step
*=
size
[
i
];
}
}
}
// handle degenerate case
// handle degenerate case
...
...
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