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

This commit is contained in:
Davis King 2014-07-17 22:29:06 -04:00
parent fa2499d8e2
commit 64bf558373
3 changed files with 29 additions and 46 deletions

View File

@ -598,7 +598,8 @@ namespace dlib
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);
fe(temp1, feats[1], cell_size,filter_rows_padding,filter_cols_padding);
swap(temp1,temp2);

View File

@ -515,8 +515,8 @@ namespace dlib
<< "\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 y_scale = (in_img.nr()-1)/(double)std::max<long>((out_img.nr()-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 = (num_rows(in_img)-1)/(double)std::max<long>((num_rows(out_img)-1),1);
transform_image(in_img, out_img, interp,
dlib::impl::helper_resize_image(x_scale,y_scale));
}

View File

@ -13,8 +13,6 @@
class numpy_gray_image
{
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 (boost::python::object& img)
@ -25,34 +23,26 @@ public:
_nc = shape[1];
}
unsigned long size () const { return static_cast<unsigned long>(_nr*_nc); }
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); }
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; }
friend inline void* image_data(numpy_gray_image& img) { return img._data; }
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); }
private:
type* _data;
unsigned char* _data;
long _nr;
long _nc;
};
// ----------------------------------------------------------------------------------------
inline const dlib::matrix_op<dlib::op_array2d_to_mat<numpy_gray_image> > mat (
const numpy_gray_image& m
)
namespace dlib
{
using namespace dlib;
typedef op_array2d_to_mat<numpy_gray_image> op;
return matrix_op<op>(op(m));
template <>
struct image_traits<numpy_gray_image >
{
typedef unsigned char pixel_type;
};
}
// ----------------------------------------------------------------------------------------
@ -75,8 +65,6 @@ inline bool is_gray_python_image (boost::python::object& img)
class numpy_rgb_image
{
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 (boost::python::object& img)
@ -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.");
}
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:
type* _data;
dlib::rgb_pixel* _data;
long _nr;
long _nc;
};
// ----------------------------------------------------------------------------------------
inline const dlib::matrix_op<dlib::op_array2d_to_mat<numpy_rgb_image> > mat (
const numpy_rgb_image& m
)
namespace dlib
{
using namespace dlib;
typedef op_array2d_to_mat<numpy_rgb_image> op;
return matrix_op<op>(op(m));
template <>
struct image_traits<numpy_rgb_image >
{
typedef rgb_pixel pixel_type;
};
}
// ----------------------------------------------------------------------------------------
inline bool is_rgb_python_image (boost::python::object& img)
{
try