Commit b90b5f15 authored by Davis King's avatar Davis King

Added a missing assert and also added a function to convert from HOG

block coordinates back into the original image coordinates.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403465
parent 8381d8c4
......@@ -7,6 +7,7 @@
#include "../algs.h"
#include "../matrix.h"
#include "../array2d.h"
#include "../geometry.h"
#include <cmath>
namespace dlib
......@@ -87,6 +88,18 @@ namespace dlib
long col
) const
{
// make sure requires clause is not broken
DLIB_ASSERT( 0 <= row && row < nr() &&
0 <= col && col < nc(),
"\t descriptor_type hog_image::operator()()"
<< "\n\t invalid row or col argument"
<< "\n\t row: " << row
<< "\n\t col: " << col
<< "\n\t nr(): " << nr()
<< "\n\t nc(): " << nc()
<< "\n\t this: " << this
);
row *= cell_stride;
col *= cell_stride;
++row;
......@@ -109,6 +122,36 @@ namespace dlib
return des;
}
const rectangle get_block_rect (
long row,
long col
) const
{
// make sure requires clause is not broken
DLIB_ASSERT( 0 <= row && row < nr() &&
0 <= col && col < nc(),
"\t rectangle hog_image::get_block_rect()"
<< "\n\t invalid row or col argument"
<< "\n\t row: " << row
<< "\n\t col: " << col
<< "\n\t nr(): " << nr()
<< "\n\t nc(): " << nc()
<< "\n\t this: " << this
);
row *= cell_stride;
col *= cell_stride;
row *= cell_size;
col *= cell_size;
// do this to account for the 1 pixel padding we use all around the image
++row;
++col;
return rectangle(col, row, col+cell_size*block_size-1, row+cell_size*block_size-1);
}
private:
template <
......
......@@ -6,6 +6,7 @@
#include "../algs.h"
#include "../matrix.h"
#include "../array2d.h"
#include "../geometry.h"
#include <cmath>
namespace dlib
......@@ -170,9 +171,24 @@ namespace dlib
- 0 <= col < nc()
ensures
- returns the descriptor for the HOG block at the given row and column. This descriptor
will include information from a window that is cell_size*block_size pixels wide and tall.
will include information from a window that is located at get_block_rect(row,col) in
the original image given to load().
- The returned descriptor vector will have block_size*block_size*num_orientation_bins elements.
!*/
const rectangle get_block_rect (
long row,
long col
) const;
/*!
requires
- 0 <= row < nr()
- 0 <= col < nc()
ensures
- returns a rectangle that tells you what part of the original image is associated
with a particular HOG block.
- The returned rectangle will be cell_size*block_size pixels wide and tall.
!*/
};
// ----------------------------------------------------------------------------------------
......
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