mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
- 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:
parent
c7103ce3d5
commit
ec09a0400e
@ -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
|
||||
)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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].
|
||||
!*/
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user