Commit 64bf5583 authored by Davis King's avatar Davis King

Fixed a few things so they work with the new image generic interface.

parent fa2499d8
...@@ -598,7 +598,8 @@ namespace dlib ...@@ -598,7 +598,8 @@ namespace dlib
if (feats.size() > 1) if (feats.size() > 1)
{ {
image_type temp1, temp2; typedef typename image_traits<image_type>::pixel_type pixel_type;
array2d<pixel_type> temp1, temp2;
pyr(img, temp1); pyr(img, temp1);
fe(temp1, feats[1], cell_size,filter_rows_padding,filter_cols_padding); fe(temp1, feats[1], cell_size,filter_rows_padding,filter_cols_padding);
swap(temp1,temp2); swap(temp1,temp2);
......
...@@ -515,8 +515,8 @@ namespace dlib ...@@ -515,8 +515,8 @@ namespace dlib
<< "\n\t is_same_object(in_img, out_img): " << is_same_object(in_img, out_img) << "\n\t is_same_object(in_img, out_img): " << is_same_object(in_img, out_img)
); );
const double x_scale = (in_img.nc()-1)/(double)std::max<long>((out_img.nc()-1),1); const double x_scale = (num_columns(in_img)-1)/(double)std::max<long>((num_columns(out_img)-1),1);
const double y_scale = (in_img.nr()-1)/(double)std::max<long>((out_img.nr()-1),1); const double y_scale = (num_rows(in_img)-1)/(double)std::max<long>((num_rows(out_img)-1),1);
transform_image(in_img, out_img, interp, transform_image(in_img, out_img, interp,
dlib::impl::helper_resize_image(x_scale,y_scale)); dlib::impl::helper_resize_image(x_scale,y_scale));
} }
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
class numpy_gray_image class numpy_gray_image
{ {
public: public:
typedef unsigned char type;
typedef dlib::default_memory_manager mem_manager_type;
numpy_gray_image() : _data(0), _nr(0), _nc(0) {} numpy_gray_image() : _data(0), _nr(0), _nc(0) {}
numpy_gray_image (boost::python::object& img) numpy_gray_image (boost::python::object& img)
...@@ -25,34 +23,26 @@ public: ...@@ -25,34 +23,26 @@ public:
_nc = shape[1]; _nc = shape[1];
} }
unsigned long size () const { return static_cast<unsigned long>(_nr*_nc); } friend inline long num_rows(const numpy_gray_image& img) { return img._nr; }
friend inline long num_columns(const numpy_gray_image& img) { return img._nc; }
inline type* operator[](const long row ) friend inline void* image_data(numpy_gray_image& img) { return img._data; }
{ return _data + _nc*row; } friend inline const void* image_data(const numpy_gray_image& img) { return img._data; }
friend inline long width_step(const numpy_gray_image& img) { return img._nc*sizeof(unsigned char); }
inline const type* operator[](const long row ) const
{ return _data + _nc*row; }
long nr() const { return _nr; }
long nc() const { return _nc; }
long width_step() const { return nc()*sizeof(type); }
private: private:
type* _data; unsigned char* _data;
long _nr; long _nr;
long _nc; long _nc;
}; };
// ---------------------------------------------------------------------------------------- namespace dlib
inline const dlib::matrix_op<dlib::op_array2d_to_mat<numpy_gray_image> > mat (
const numpy_gray_image& m
)
{ {
using namespace dlib; template <>
typedef op_array2d_to_mat<numpy_gray_image> op; struct image_traits<numpy_gray_image >
return matrix_op<op>(op(m)); {
typedef unsigned char pixel_type;
};
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -75,8 +65,6 @@ inline bool is_gray_python_image (boost::python::object& img) ...@@ -75,8 +65,6 @@ inline bool is_gray_python_image (boost::python::object& img)
class numpy_rgb_image class numpy_rgb_image
{ {
public: public:
typedef dlib::rgb_pixel type;
typedef dlib::default_memory_manager mem_manager_type;
numpy_rgb_image() : _data(0), _nr(0), _nc(0) {} numpy_rgb_image() : _data(0), _nr(0), _nc(0) {}
numpy_rgb_image (boost::python::object& img) numpy_rgb_image (boost::python::object& img)
...@@ -89,38 +77,32 @@ public: ...@@ -89,38 +77,32 @@ public:
throw dlib::error("Error, python object is not a three band image and therefore can't be a RGB image."); throw dlib::error("Error, python object is not a three band image and therefore can't be a RGB image.");
} }
unsigned long size () const { return static_cast<unsigned long>(_nr*_nc); } friend inline long num_rows(const numpy_rgb_image& img) { return img._nr; }
friend inline long num_columns(const numpy_rgb_image& img) { return img._nc; }
friend inline void* image_data(numpy_rgb_image& img) { return img._data; }
friend inline const void* image_data(const numpy_rgb_image& img) { return img._data; }
friend inline long width_step(const numpy_rgb_image& img) { return img._nc*sizeof(dlib::rgb_pixel); }
inline type* operator[](const long row )
{ return _data + _nc*row; }
inline const type* operator[](const long row ) const
{ return _data + _nc*row; }
long nr() const { return _nr; }
long nc() const { return _nc; }
long width_step() const { return nc()*sizeof(type); }
private: private:
type* _data; dlib::rgb_pixel* _data;
long _nr; long _nr;
long _nc; long _nc;
}; };
// ---------------------------------------------------------------------------------------- namespace dlib
inline const dlib::matrix_op<dlib::op_array2d_to_mat<numpy_rgb_image> > mat (
const numpy_rgb_image& m
)
{ {
using namespace dlib; template <>
typedef op_array2d_to_mat<numpy_rgb_image> op; struct image_traits<numpy_rgb_image >
return matrix_op<op>(op(m)); {
typedef rgb_pixel pixel_type;
};
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
inline bool is_rgb_python_image (boost::python::object& img) inline bool is_rgb_python_image (boost::python::object& img)
{ {
try try
......
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