- Formally defined how array2d objects must lay their components out in memory

- Added width_step() to array2d to help define the memory layout.  Also added
   it to cv_image to keep the interfaces compatible.
 - Fixed a typo in the deserialize for array2d objects.  The template wasn't
   declared properly.
This commit is contained in:
Davis King 2011-08-25 20:19:08 -04:00
parent c7103ce3d5
commit ec09a0400e
4 changed files with 31 additions and 2 deletions

View File

@ -284,6 +284,12 @@ namespace dlib
unsigned long size (
) const { return static_cast<unsigned long>(nc_ * nr_); }
long width_step (
) const
{
return nc_;
}
private:
// this object exists just so we can have a row type object that
@ -348,10 +354,11 @@ namespace dlib
}
template <
typename T
typename T,
typename mem_manager
>
void deserialize (
array2d<T>& item,
array2d<T,mem_manager>& item,
std::istream& in
)
{

View File

@ -50,6 +50,12 @@ namespace dlib
Also note that unless specified otherwise, no member functions
of this object throw exceptions.
Finally, note that this object stores each row of data contiguously
in memory, and the overall layout is in row major order. However,
there might be padding at the end of each row. To determine the
offset from one row to another you can use step_width().
!*/
@ -199,6 +205,14 @@ namespace dlib
- swaps *this and item
!*/
long width_step (
) const;
/*!
ensures
- returns the pointer offset to step from one row to another.
That is, &item[0][0] + step_width(item) == &item[1][0].
!*/
private:
// restricted functions

View File

@ -61,6 +61,7 @@ namespace dlib
long nr() const { return _nr; }
long nc() const { return _nc; }
long width_step() const { return _widthStep; }
cv_image& operator=( const cv_image& item)
{

View File

@ -142,6 +142,13 @@ namespace dlib
- returns #*this
!*/
long width_step (
) const;
/*!
ensures
- returns the pointer offset to step from one row to another.
That is, &item[0][0] + step_width(item) == &item[1][0].
!*/
};