Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
85a226b0
"vscode:/vscode.git/clone" did not exist on "40dcc7152d930a8761b84d9ed2041a32fa06972c"
Commit
85a226b0
authored
Mar 24, 2013
by
Davis King
Browse files
Moved setup_hashed_features() into its own file.
parent
173a2b61
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
204 additions
and
160 deletions
+204
-160
dlib/image_processing.h
dlib/image_processing.h
+1
-0
dlib/image_processing/scan_image_pyramid_tools.h
dlib/image_processing/scan_image_pyramid_tools.h
+0
-84
dlib/image_processing/scan_image_pyramid_tools_abstract.h
dlib/image_processing/scan_image_pyramid_tools_abstract.h
+5
-76
dlib/image_processing/setup_hashed_features.h
dlib/image_processing/setup_hashed_features.h
+104
-0
dlib/image_processing/setup_hashed_features_abstract.h
dlib/image_processing/setup_hashed_features_abstract.h
+94
-0
No files found.
dlib/image_processing.h
View file @
85a226b0
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include "image_processing/object_detector.h"
#include "image_processing/object_detector.h"
#include "image_processing/box_overlap_testing.h"
#include "image_processing/box_overlap_testing.h"
#include "image_processing/scan_image_pyramid_tools.h"
#include "image_processing/scan_image_pyramid_tools.h"
#include "image_processing/setup_hashed_features.h"
#include "image_processing/scan_image_boxes.h"
#include "image_processing/scan_image_boxes.h"
#endif // DLIB_IMAGE_PROCESSInG_H___
#endif // DLIB_IMAGE_PROCESSInG_H___
...
...
dlib/image_processing/scan_image_pyramid_tools.h
View file @
85a226b0
...
@@ -4,10 +4,7 @@
...
@@ -4,10 +4,7 @@
#define DLIB_SCAN_IMaGE_PYRAMID_TOOLS_H__
#define DLIB_SCAN_IMaGE_PYRAMID_TOOLS_H__
#include "scan_image_pyramid_tools_abstract.h"
#include "scan_image_pyramid_tools_abstract.h"
#include "scan_image_pyramid.h"
#include "../lsh.h"
#include "../statistics.h"
#include "../statistics.h"
#include "../image_keypoint.h"
#include <list>
#include <list>
#include "../geometry.h"
#include "../geometry.h"
#include <iostream>
#include <iostream>
...
@@ -15,87 +12,6 @@
...
@@ -15,87 +12,6 @@
namespace
dlib
namespace
dlib
{
{
// ----------------------------------------------------------------------------------------
class
image_hash_construction_failure
:
public
error
{
public:
image_hash_construction_failure
(
const
std
::
string
&
a
)
:
error
(
a
)
{}
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
const
feature_extractor
&
fe
,
int
bits
,
unsigned
long
num_samples
=
200000
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<
bits
&&
bits
<=
32
&&
num_samples
>
1
&&
images
.
size
()
>
0
,
"
\t
void setup_hashed_features()"
<<
"
\n\t
Invalid inputs were given to this function. "
<<
"
\n\t
bits: "
<<
bits
<<
"
\n\t
num_samples: "
<<
num_samples
<<
"
\n\t
images.size(): "
<<
images
.
size
()
);
pyramid
pyr
;
const
random_subset_selector
<
typename
feature_extractor
::
descriptor_type
>&
samps
=
randomly_sample_image_features
(
images
,
pyr
,
fe
,
num_samples
);
if
(
samps
.
size
()
<=
1
)
throw
dlib
::
image_hash_construction_failure
(
"Images too small, not able to gather enough samples to make hash"
);
projection_hash
phash
=
create_random_projection_hash
(
samps
,
bits
);
hashed_feature_image
<
feature_extractor
,
projection_hash
>
hfe
;
hfe
.
set_hash
(
phash
);
hfe
.
copy_configuration
(
fe
);
scanner
.
copy_configuration
(
hfe
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
int
bits
,
unsigned
long
num_samples
=
200000
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<
bits
&&
bits
<=
32
&&
num_samples
>
1
&&
images
.
size
()
>
0
,
"
\t
void setup_hashed_features()"
<<
"
\n\t
Invalid inputs were given to this function. "
<<
"
\n\t
bits: "
<<
bits
<<
"
\n\t
num_samples: "
<<
num_samples
<<
"
\n\t
images.size(): "
<<
images
.
size
()
);
feature_extractor
fe
;
setup_hashed_features
(
scanner
,
images
,
fe
,
bits
,
num_samples
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
namespace
impl
namespace
impl
...
...
dlib/image_processing/scan_image_pyramid_tools_abstract.h
View file @
85a226b0
...
@@ -4,86 +4,12 @@
...
@@ -4,86 +4,12 @@
#ifdef DLIB_SCAN_IMaGE_PYRAMID_TOOLS_ABSTRACT_H__
#ifdef DLIB_SCAN_IMaGE_PYRAMID_TOOLS_ABSTRACT_H__
#include "scan_image_pyramid_abstract.h"
#include "scan_image_pyramid_abstract.h"
#include
"../lsh/projection_hash_abstract.h"
#include
<vector>
#include "../
image_keypoint/hashed_feature_image_abstract
.h"
#include "../
geometry
.h"
namespace
dlib
namespace
dlib
{
{
// ----------------------------------------------------------------------------------------
class
image_hash_construction_failure
:
public
error
{
/*!
WHAT THIS OBJECT REPRESENTS
This is the exception object used by the routines in this file.
!*/
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
const
feature_extractor
&
fe
,
int
bits
,
unsigned
long
num_samples
=
200000
);
/*!
requires
- 0 < bits <= 32
- num_samples > 1
- images.size() > 0
- it must be valid to pass images[0] into scanner.load().
(also, image_array must be an implementation of dlib/array/array_kernel_abstract.h)
ensures
- Creates a projection_hash suitable for hashing the feature vectors produced by
fe and then configures scanner to use this hash function.
- The hash function will map vectors into integers in the range [0, pow(2,bits))
- The hash function will be setup so that it hashes a random sample of num_samples
vectors from fe such that each bin ends up with roughly the same number of
elements in it.
throws
- image_hash_construction_failure
This exception is thrown if there is a problem creating the projection_hash.
This should only happen the images are so small they contain less than 2
feature vectors.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
int
bits
,
unsigned
long
num_samples
=
200000
);
/*!
requires
- 0 < bits <= 32
- num_samples > 1
- images.size() > 0
- it must be valid to pass images[0] into scanner.load().
(also, image_array must be an implementation of dlib/array/array_kernel_abstract.h)
ensures
- performs: setup_hashed_features(scanner, images, feature_extractor(), bits, num_samples)
throws
- image_hash_construction_failure
This exception is thrown if there is a problem creating the projection_hash.
This should only happen the images are so small they contain less than 2
feature vectors.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
@@ -179,6 +105,9 @@ namespace dlib
...
@@ -179,6 +105,9 @@ namespace dlib
- this function is identical to setup_grid_detection_templates() except
- this function is identical to setup_grid_detection_templates() except
that it also outputs the selected detection templates to standard out.
that it also outputs the selected detection templates to standard out.
!*/
!*/
// ----------------------------------------------------------------------------------------
}
}
#endif // DLIB_SCAN_IMaGE_PYRAMID_TOOLS_ABSTRACT_H__
#endif // DLIB_SCAN_IMaGE_PYRAMID_TOOLS_ABSTRACT_H__
...
...
dlib/image_processing/setup_hashed_features.h
0 → 100644
View file @
85a226b0
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_SETUP_HAShED_FEATURES_H__
#define DLIB_SETUP_HAShED_FEATURES_H__
#include "setup_hashed_features_abstract.h"
#include "scan_image_pyramid.h"
#include "scan_image_boxes.h"
#include "../lsh.h"
#include "../statistics.h"
#include "../image_keypoint.h"
#include "../geometry.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
class
image_hash_construction_failure
:
public
error
{
public:
image_hash_construction_failure
(
const
std
::
string
&
a
)
:
error
(
a
)
{}
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
const
feature_extractor
&
fe
,
int
bits
,
unsigned
long
num_samples
=
200000
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<
bits
&&
bits
<=
32
&&
num_samples
>
1
&&
images
.
size
()
>
0
,
"
\t
void setup_hashed_features()"
<<
"
\n\t
Invalid inputs were given to this function. "
<<
"
\n\t
bits: "
<<
bits
<<
"
\n\t
num_samples: "
<<
num_samples
<<
"
\n\t
images.size(): "
<<
images
.
size
()
);
pyramid
pyr
;
const
random_subset_selector
<
typename
feature_extractor
::
descriptor_type
>&
samps
=
randomly_sample_image_features
(
images
,
pyr
,
fe
,
num_samples
);
if
(
samps
.
size
()
<=
1
)
throw
dlib
::
image_hash_construction_failure
(
"Images too small, not able to gather enough samples to make hash"
);
projection_hash
phash
=
create_random_projection_hash
(
samps
,
bits
);
hashed_feature_image
<
feature_extractor
,
projection_hash
>
hfe
;
hfe
.
set_hash
(
phash
);
hfe
.
copy_configuration
(
fe
);
scanner
.
copy_configuration
(
hfe
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
int
bits
,
unsigned
long
num_samples
=
200000
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<
bits
&&
bits
<=
32
&&
num_samples
>
1
&&
images
.
size
()
>
0
,
"
\t
void setup_hashed_features()"
<<
"
\n\t
Invalid inputs were given to this function. "
<<
"
\n\t
bits: "
<<
bits
<<
"
\n\t
num_samples: "
<<
num_samples
<<
"
\n\t
images.size(): "
<<
images
.
size
()
);
feature_extractor
fe
;
setup_hashed_features
(
scanner
,
images
,
fe
,
bits
,
num_samples
);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SETUP_HAShED_FEATURES_H__
dlib/image_processing/setup_hashed_features_abstract.h
0 → 100644
View file @
85a226b0
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_SETUP_HAShED_FEATURES_ABSTRACT_H__
#ifdef DLIB_SETUP_HAShED_FEATURES_ABSTRACT_H__
#include "scan_image_pyramid_abstract.h"
#include "scan_image_boxes_abstract.h"
#include "../lsh/projection_hash_abstract.h"
#include "../image_keypoint/hashed_feature_image_abstract.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
class
image_hash_construction_failure
:
public
error
{
/*!
WHAT THIS OBJECT REPRESENTS
This is the exception object used by the routines in this file.
!*/
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
const
feature_extractor
&
fe
,
int
bits
,
unsigned
long
num_samples
=
200000
);
/*!
requires
- 0 < bits <= 32
- num_samples > 1
- images.size() > 0
- it must be valid to pass images[0] into scanner.load().
(also, image_array must be an implementation of dlib/array/array_kernel_abstract.h)
ensures
- Creates a projection_hash suitable for hashing the feature vectors produced by
fe and then configures scanner to use this hash function.
- The hash function will map vectors into integers in the range [0, pow(2,bits))
- The hash function will be setup so that it hashes a random sample of num_samples
vectors from fe such that each bin ends up with roughly the same number of
elements in it.
throws
- image_hash_construction_failure
This exception is thrown if there is a problem creating the projection_hash.
This should only happen the images are so small they contain less than 2
feature vectors.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_array
,
typename
pyramid
,
typename
feature_extractor
>
void
setup_hashed_features
(
scan_image_pyramid
<
pyramid
,
hashed_feature_image
<
feature_extractor
,
projection_hash
>
>&
scanner
,
const
image_array
&
images
,
int
bits
,
unsigned
long
num_samples
=
200000
);
/*!
requires
- 0 < bits <= 32
- num_samples > 1
- images.size() > 0
- it must be valid to pass images[0] into scanner.load().
(also, image_array must be an implementation of dlib/array/array_kernel_abstract.h)
ensures
- performs: setup_hashed_features(scanner, images, feature_extractor(), bits, num_samples)
throws
- image_hash_construction_failure
This exception is thrown if there is a problem creating the projection_hash.
This should only happen the images are so small they contain less than 2
feature vectors.
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SETUP_HAShED_FEATURES_ABSTRACT_H__
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment