Commit e83f3503 authored by Davis King's avatar Davis King

Fixed numpy_image and pybind11 crashing python sometimes when certain types of

conversions are attempted.
parent 86a9abe0
......@@ -138,12 +138,21 @@ namespace dlib
numpy_image() = default;
numpy_image(
py::array& img
const py::array& img
) : py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style>(img)
{
assert_is_image<pixel_type>(img);
}
numpy_image (
const py::object& img
)
{
py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style> arr = img.cast<py::array>();
assert_is_image<pixel_type>(arr);
py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style>::operator=(arr);
}
numpy_image(
const numpy_image& img
) : py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style>(img)
......@@ -154,8 +163,9 @@ namespace dlib
const py::object& rhs
)
{
assert_is_image<pixel_type>(rhs);
*this = rhs.cast<py::array>();
py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style> arr = rhs.cast<py::array>();
assert_is_image<pixel_type>(arr);
py::array_t<typename pixel_traits<pixel_type>::basic_pixel_type, py::array::c_style>::operator=(arr);
return *this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment