diff --git a/dlib/python/numpy_image.h b/dlib/python/numpy_image.h index 6ae2acf0b..30733a52b 100644 --- a/dlib/python/numpy_image.h +++ b/dlib/python/numpy_image.h @@ -148,26 +148,17 @@ namespace dlib numpy_image ( const py::object& img - ) - { - py::array_t::basic_pixel_type, py::array::c_style> arr = img.cast(); - assert_is_image(arr); - py::array_t::basic_pixel_type, py::array::c_style>::operator=(arr); - } + ) : numpy_image(img.cast()) {} numpy_image( const numpy_image& img - ) : py::array_t::basic_pixel_type, py::array::c_style>(img) - { - } + ) = default; numpy_image& operator= ( const py::object& rhs ) { - py::array arr = rhs.cast(); - assert_is_image(arr); - py::array_t::basic_pixel_type, py::array::c_style>::operator=(arr); + *this = numpy_image(rhs); return *this; } @@ -175,33 +166,25 @@ namespace dlib const py::array_t::basic_pixel_type, py::array::c_style>& rhs ) { - assert_is_image(rhs); - py::array_t::basic_pixel_type, py::array::c_style>::operator=(rhs); + *this = numpy_image(rhs); return *this; } numpy_image& operator= ( const numpy_image& rhs - ) - { - py::array_t::basic_pixel_type, py::array::c_style>::operator=(rhs); - return *this; - } + ) = default; template numpy_image ( matrix&& rhs - ) - { - *this = convert_to_numpy(std::move(rhs)); - } + ) : numpy_image(convert_to_numpy(std::move(rhs))) {} template numpy_image& operator= ( matrix&& rhs ) { - *this = convert_to_numpy(std::move(rhs)); + *this = numpy_image(rhs); return *this; }