Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
44c06150
Commit
44c06150
authored
Jun 02, 2018
by
Davis King
Browse files
Fixed numpy_image not compiling when C++14 is enabled.
parent
85fc0e0b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+18
-7
No files found.
dlib/python/numpy_image.h
View file @
44c06150
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/pybind11.h>
#include <dlib/image_transforms/assign_image.h>
#include <dlib/image_transforms/assign_image.h>
#include <stdint.h>
#include <stdint.h>
#include <type_traits>
namespace
py
=
pybind11
;
namespace
py
=
pybind11
;
...
@@ -356,18 +357,28 @@ namespace pybind11
...
@@ -356,18 +357,28 @@ namespace pybind11
{
{
using
basic_pixel_type
=
typename
dlib
::
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
using
basic_pixel_type
=
typename
dlib
::
pixel_traits
<
pixel_type
>::
basic_pixel_type
;
static
PYBIND11_DESCR
name
()
{
template
<
size_t
channels
>
constexpr
size_t
channels
=
dlib
::
pixel_traits
<
pixel_type
>::
num
;
static
PYBIND11_DESCR
getname
(
typename
std
::
enable_if
<
channels
==
1
,
int
>::
type
)
{
if
(
channels
==
1
)
return
_
(
"numpy.ndarray[(rows,cols),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
return
_
(
"numpy.ndarray[(rows,cols),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
else
if
(
channels
==
2
)
};
template
<
size_t
channels
>
static
PYBIND11_DESCR
getname
(
typename
std
::
enable_if
<
channels
!=
1
,
int
>::
type
)
{
if
(
channels
==
2
)
return
_
(
"numpy.ndarray[(rows,cols,2),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
return
_
(
"numpy.ndarray[(rows,cols,2),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
else
if
(
channels
==
3
)
else
if
(
channels
==
3
)
return
_
(
"numpy.ndarray[(rows,cols,3),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
return
_
(
"numpy.ndarray[(rows,cols,3),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
else
if
(
channels
==
4
)
else
if
(
channels
==
4
)
return
_
(
"numpy.ndarray[(rows,cols,4),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
return
_
(
"numpy.ndarray[(rows,cols,4),"
)
+
npy_format_descriptor
<
basic_pixel_type
>::
name
()
+
_
(
"]"
);
else
};
DLIB_CASSERT
(
false
,
"unsupported pixel type"
);
static
PYBIND11_DESCR
name
()
{
constexpr
size_t
channels
=
dlib
::
pixel_traits
<
pixel_type
>::
num
;
// The reason we have to call getname() in this wonky way is because
// pybind11 uses a type that records the length of the returned string in
// the type. So we have to do this overloading to make the return type
// from name() consistent. In C++17 this would be a lot cleaner with
// constexpr if, but can't use C++17 yet because of lack of wide support :(
return
getname
<
channels
>
(
0
);
}
}
};
};
...
...
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