From cae3da777fd0ca7d6829696c3618cdf86885f6ad Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 30 Dec 2011 23:13:04 -0500 Subject: [PATCH] Added an unload() to the hog_image. --- dlib/image_keypoint/hashed_feature_image.h | 9 ++++----- dlib/image_keypoint/hog.h | 3 +++ dlib/image_keypoint/hog_abstract.h | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dlib/image_keypoint/hashed_feature_image.h b/dlib/image_keypoint/hashed_feature_image.h index bd0fd9c2d..1cdcb4805 100644 --- a/dlib/image_keypoint/hashed_feature_image.h +++ b/dlib/image_keypoint/hashed_feature_image.h @@ -245,18 +245,17 @@ namespace dlib const image_type& img ) { - feature_extractor fe_temp; - fe_temp.copy_configuration(fe); - fe_temp.load(img); + fe.load(img); - feats.set_size(fe_temp.nr(), fe_temp.nc()); + feats.set_size(fe.nr(), fe.nc()); for (long r = 0; r < feats.nr(); ++r) { for (long c = 0; c < feats.nc(); ++c) { - feats[r][c] = phash(fe_temp(r,c)); + feats[r][c] = phash(fe(r,c)); } } + fe.unload(); } // ---------------------------------------------------------------------------------------- diff --git a/dlib/image_keypoint/hog.h b/dlib/image_keypoint/hog.h index 635d22321..a39a92093 100644 --- a/dlib/image_keypoint/hog.h +++ b/dlib/image_keypoint/hog.h @@ -86,6 +86,9 @@ namespace dlib load_impl(array_to_matrix(img)); } + inline void unload( + ) { clear(); } + inline unsigned long size ( ) const { return static_cast(nr()*nc()); } diff --git a/dlib/image_keypoint/hog_abstract.h b/dlib/image_keypoint/hog_abstract.h index 9314f422b..e5447a695 100644 --- a/dlib/image_keypoint/hog_abstract.h +++ b/dlib/image_keypoint/hog_abstract.h @@ -169,6 +169,25 @@ namespace dlib - #size() > 0 !*/ + inline void unload ( + ); + /*! + ensures + - #nr() == 0 + - #nc() == 0 + - clears only the state information which is populated by load(). For + example, let H be a hog_image object. Then consider the two sequences + of instructions: + Sequence 1: + H.load(img); + H.unload(); + H.load(img); + + Sequence 2: + H.load(img); + Both sequence 1 and sequence 2 should have the same effect on H. + !*/ + inline unsigned long size ( ) const; /*!