Commit 382c3d97 authored by Davis King's avatar Davis King

Added another overload of extract_fhog_features(). This one returns the

features as a column vector but by reference instead of by value.
parent 98d1e564
......@@ -658,24 +658,42 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template <
typename image_type
typename image_type,
typename T
>
matrix<double,0,1> extract_fhog_features(
void extract_fhog_features(
const image_type& img,
matrix<T,0,1>& feats,
int cell_size = 8,
int filter_rows_padding = 1,
int filter_cols_padding = 1
)
{
dlib::array<array2d<double> > hog;
dlib::array<array2d<T> > hog;
extract_fhog_features(img, hog, cell_size, filter_rows_padding, filter_cols_padding);
matrix<double,0,1> temp(hog.size()*hog[0].size());
feats.set_size(hog.size()*hog[0].size());
for (unsigned long i = 0; i < hog.size(); ++i)
{
const long size = hog[i].size();
set_rowm(temp, range(i*size, (i+1)*size-1)) = reshape_to_column_vector(mat(hog[i]));
set_rowm(feats, range(i*size, (i+1)*size-1)) = reshape_to_column_vector(mat(hog[i]));
}
return temp;
}
// ----------------------------------------------------------------------------------------
template <
typename image_type
>
matrix<double,0,1> extract_fhog_features(
const image_type& img,
int cell_size = 8,
int filter_rows_padding = 1,
int filter_cols_padding = 1
)
{
matrix<double,0,1> feats;
extract_fhog_features(img, feats, cell_size, filter_rows_padding, filter_cols_padding);
return feats;
}
// ----------------------------------------------------------------------------------------
......
......@@ -137,6 +137,34 @@ namespace dlib
H[0], then H[1], then H[2], and so on in ascending index order.
!*/
// ----------------------------------------------------------------------------------------
template <
typename image_type,
typename T
>
void extract_fhog_features(
const image_type& img,
matrix<T,0,1>& feats,
int cell_size = 8,
int filter_rows_padding = 1,
int filter_cols_padding = 1
);
/*!
requires
- cell_size > 0
- filter_rows_padding > 0
- filter_cols_padding > 0
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- img contains some kind of pixel type.
(i.e. pixel_traits<typename image_type::type> is defined)
- T is float, double, or long double
ensures
- This function is identical to the above version of extract_fhog_features()
that returns a matrix<double,0,1> except that it returns the matrix here
through a reference argument instead of returning it by value.
!*/
// ----------------------------------------------------------------------------------------
inline point image_to_fhog (
......
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