Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hydra-image-processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
hydra-image-processor
Commits
2735e7b2
Commit
2735e7b2
authored
6 years ago
by
Mark Winter
Browse files
Options
Downloads
Patches
Plain Diff
Support for ImageOwner semantics
parent
64d6becb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/c/WrapCmds/PyConverters.h
+17
-18
17 additions, 18 deletions
src/c/WrapCmds/PyConverters.h
src/c/WrapCmds/ScriptTraits.h
+1
-1
1 addition, 1 deletion
src/c/WrapCmds/ScriptTraits.h
with
18 additions
and
19 deletions
src/c/WrapCmds/PyConverters.h
+
17
−
18
View file @
2735e7b2
#include
"../Cuda/Image
Container
.h"
#include
"../Cuda/Image
View
.h"
#include
"mph/tuple_helpers.h"
#include
"mph/qualifier_helpers.h"
...
...
@@ -524,8 +524,8 @@ namespace Script
if
(
ndim
>
1
)
throw
VectorConvertError
(
"Array must be 1-D with 3 numeric values"
);
Script
::
DimType
*
DIMS
=
Script
::
ArrayInfo
::
getDim
s
(
arrPtr
);
if
(
DIMS
[
0
]
!=
3
)
Script
::
DimType
size
=
Script
::
ArrayInfo
::
getDim
(
arrPtr
,
0
);
if
(
size
!=
3
)
throw
VectorConvertError
(
"Array must be 1-D with 3 numeric values"
);
pyArrayCopyConvert
(
out
.
e
,
arrPtr
);
...
...
@@ -533,25 +533,24 @@ namespace Script
template
<
typename
T
>
static
void
pyArrayToImageCopy
(
Image
Contai
ner
<
T
>&
out
,
const
PyObject
*
inPtr
)
static
void
pyArrayToImageCopy
(
Image
Ow
ner
<
T
>&
out
,
const
PyObject
*
inPtr
)
{
// TODO: IMPORTANT! Make ownership semantics for ImageContainer/ImageView
PyArrayObject
*
arrPtr
=
const_cast
<
PyArrayObject
*>
(
reinterpret_cast
<
const
PyArrayObject
*>
(
inPtr
));
std
::
size_t
ndim
=
Script
::
ArrayInfo
::
getNDims
(
arrPtr
);
// TODO: Check number of dims?
// TODO: Do we need to allow overloads for array checks?
// TODO: Check for contiguous
Script
::
DimInfo
info
=
Script
::
getDimInfo
(
arrPtr
);
ImageDimensions
inDims
;
Script
::
DimType
*
DIMS
=
Script
::
ArrayInfo
::
getDims
(
arrPtr
);
// TODO: Do we need to allow overloads for array checks?
if
(
!
info
.
contiguous
)
throw
ImageConvertError
(
"Only contiguous numpy arrays are supported"
);
for
(
int
i
=
0
;
i
<
ndim
;
++
i
)
inDims
.
dims
.
e
[
i
]
=
DIMS
[
i
];
ImageDimensions
inDims
(
Vec
<
std
::
size_t
>
(
1
),
1
,
1
);
std
::
size_t
nspatial
=
std
::
max
<
std
::
size_t
>
(
3
,
info
.
dims
.
size
());
for
(
std
::
size_t
i
=
0
;
i
<
nspatial
;
++
i
)
inDims
.
dims
.
e
[
i
]
=
info
.
dims
[
i
];
inDims
.
chan
=
(
ndim
>=
4
)
?
(
DIMS
[
3
]
)
:
(
1
);
inDims
.
frame
=
(
ndim
>=
5
)
?
(
DIMS
[
4
]
)
:
(
1
);
inDims
.
chan
=
(
info
.
dims
.
size
()
>=
4
)
?
info
.
dims
[
3
]
:
(
1
);
inDims
.
frame
=
(
info
.
dims
.
size
()
>=
5
)
?
info
.
dims
[
4
]
:
(
1
);
out
.
resize
(
inDims
);
out
=
ImageOwner
<
T
>
(
inDims
);
pyArrayCopyConvert
(
out
.
getPtr
(),
arrPtr
);
}
...
...
@@ -646,9 +645,9 @@ namespace Script
}
// Concrete Image
Contai
ner<T> conversions
// Concrete Image
Ow
ner<T> conversions
template
<
typename
T
>
static
void
convert_impl
(
Image
Contai
ner
<
T
>&
out
,
const
PyObject
*
inPtr
)
static
void
convert_impl
(
Image
Ow
ner
<
T
>&
out
,
const
PyObject
*
inPtr
)
{
if
(
PyArray_Check
(
inPtr
)
)
{
...
...
This diff is collapsed.
Click to expand it.
src/c/WrapCmds/ScriptTraits.h
+
1
−
1
View file @
2735e7b2
...
...
@@ -121,7 +121,7 @@ namespace Script
template
<
typename
BaseType
>
struct
dtype_to_concrete
<
Image
<
BaseType
>>
{
using
type
=
Image
Contai
ner
<
BaseType
>
;
using
type
=
Image
Ow
ner
<
BaseType
>
;
};
template
<
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment