Commit 6700c46e authored by Davis King's avatar Davis King

Added an overload of extract_fhog_features() that returns a single column

vector represented using a matrix.
parent 972e3253
......@@ -655,6 +655,29 @@ namespace dlib
return impl_fhog::impl_extract_fhog_features(img, hog, cell_size, filter_rows_padding, filter_cols_padding);
}
// ----------------------------------------------------------------------------------------
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
)
{
dlib::array<array2d<double> > hog;
extract_fhog_features(img, hog, cell_size, filter_rows_padding, filter_cols_padding);
matrix<double,0,1> temp(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]));
}
return temp;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
......
......@@ -29,9 +29,9 @@ namespace dlib
- cell_size > 0
- filter_rows_padding > 0
- filter_cols_padding > 0
- in_image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- img contains some kind of pixel type.
(i.e. pixel_traits<typename in_image_type::type> is defined)
(i.e. pixel_traits<typename image_type::type> is defined)
- T should be float or double
ensures
- This function implements the HOG feature extraction method described in
......@@ -89,9 +89,9 @@ namespace dlib
- cell_size > 0
- filter_rows_padding > 0
- filter_cols_padding > 0
- in_image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- img contains some kind of pixel type.
(i.e. pixel_traits<typename in_image_type::type> is defined)
(i.e. pixel_traits<typename image_type::type> is defined)
- T should be float or double
ensures
- This function is identical to the above extract_fhog_features() routine
......@@ -105,6 +105,38 @@ namespace dlib
- #hog.size() == 31
!*/
// ----------------------------------------------------------------------------------------
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
);
/*!
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)
ensures
- This function calls the above extract_fhog_features() routine and simply
packages the entire output into a dlib::matrix. The matrix is constructed
using the planar version of extract_fhog_features() and then each output
plane is converted into a column vector and subsequently all 31 column
vectors are concatenated together and returned.
- Each plane is converted into a column vector using reshape_to_column_vector(),
and is therefore represented in row major order inside the returned vector.
- If H is the array<array2d<double>> object output by the planar
extract_fhog_features() then the returned vector is composed by concatenating
H[0], then H[1], then H[2], and so on in ascending index order.
!*/
// ----------------------------------------------------------------------------------------
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