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
46681570
Commit
46681570
authored
Dec 29, 2011
by
Davis King
Browse files
Made this code a little more efficient.
parent
70aaa13a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
dlib/image_keypoint/hashed_feature_image.h
dlib/image_keypoint/hashed_feature_image.h
+20
-17
dlib/image_keypoint/hashed_feature_image_abstract.h
dlib/image_keypoint/hashed_feature_image_abstract.h
+0
-3
No files found.
dlib/image_keypoint/hashed_feature_image.h
View file @
46681570
...
@@ -108,6 +108,7 @@ namespace dlib
...
@@ -108,6 +108,7 @@ namespace dlib
private:
private:
array2d
<
unsigned
long
>
feats
;
feature_extractor
fe
;
feature_extractor
fe
;
hash_function_type
phash
;
hash_function_type
phash
;
...
@@ -126,6 +127,7 @@ namespace dlib
...
@@ -126,6 +127,7 @@ namespace dlib
std
::
ostream
&
out
std
::
ostream
&
out
)
)
{
{
serialize
(
item
.
feats
,
out
);
serialize
(
item
.
fe
,
out
);
serialize
(
item
.
fe
,
out
);
serialize
(
item
.
phash
,
out
);
serialize
(
item
.
phash
,
out
);
}
}
...
@@ -136,6 +138,7 @@ namespace dlib
...
@@ -136,6 +138,7 @@ namespace dlib
std
::
istream
&
in
std
::
istream
&
in
)
)
{
{
deserialize
(
item
.
feats
,
in
);
deserialize
(
item
.
fe
,
in
);
deserialize
(
item
.
fe
,
in
);
deserialize
(
item
.
phash
,
in
);
deserialize
(
item
.
phash
,
in
);
}
}
...
@@ -169,6 +172,7 @@ namespace dlib
...
@@ -169,6 +172,7 @@ namespace dlib
{
{
fe
.
clear
();
fe
.
clear
();
phash
=
hash_function_type
();
phash
=
hash_function_type
();
feats
.
clear
();
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -241,7 +245,18 @@ namespace dlib
...
@@ -241,7 +245,18 @@ namespace dlib
const
image_type
&
img
const
image_type
&
img
)
)
{
{
fe
.
load
(
img
);
feature_extractor
fe_temp
;
fe_temp
.
copy_configuration
(
fe
);
fe_temp
.
load
(
img
);
feats
.
set_size
(
fe_temp
.
nr
(),
fe_temp
.
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
));
}
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -254,7 +269,7 @@ namespace dlib
...
@@ -254,7 +269,7 @@ namespace dlib
size
(
size
(
)
const
)
const
{
{
return
fe
.
size
();
return
fe
ats
.
size
();
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -267,7 +282,7 @@ namespace dlib
...
@@ -267,7 +282,7 @@ namespace dlib
nr
(
nr
(
)
const
)
const
{
{
return
fe
.
nr
();
return
fe
ats
.
nr
();
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -280,7 +295,7 @@ namespace dlib
...
@@ -280,7 +295,7 @@ namespace dlib
nc
(
nc
(
)
const
)
const
{
{
return
fe
.
nc
();
return
fe
ats
.
nc
();
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -320,7 +335,7 @@ namespace dlib
...
@@ -320,7 +335,7 @@ namespace dlib
<<
"
\n\t
this: "
<<
this
<<
"
\n\t
this: "
<<
this
);
);
hash_feats
[
0
]
=
std
::
make_pair
(
phash
(
fe
(
row
,
col
))
,
1
);
hash_feats
[
0
]
=
std
::
make_pair
(
feats
[
row
][
col
]
,
1
);
return
hash_feats
;
return
hash_feats
;
}
}
...
@@ -336,18 +351,6 @@ namespace dlib
...
@@ -336,18 +351,6 @@ namespace dlib
long
col
long
col
)
const
)
const
{
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<=
row
&&
row
<
nr
()
&&
0
<=
col
&&
col
<
nc
(),
"
\t
rectangle hashed_feature_image::get_block_rect(row,col)"
<<
"
\n\t
Invalid inputs were given to this function"
<<
"
\n\t
row: "
<<
row
<<
"
\n\t
col: "
<<
col
<<
"
\n\t
nr(): "
<<
nr
()
<<
"
\n\t
nc(): "
<<
nc
()
<<
"
\n\t
this: "
<<
this
);
return
fe
.
get_block_rect
(
row
,
col
);
return
fe
.
get_block_rect
(
row
,
col
);
}
}
...
...
dlib/image_keypoint/hashed_feature_image_abstract.h
View file @
46681570
...
@@ -176,9 +176,6 @@ namespace dlib
...
@@ -176,9 +176,6 @@ namespace dlib
long
col
long
col
)
const
;
)
const
;
/*!
/*!
requires
- 0 <= row < nr()
- 0 <= col < nc()
ensures
ensures
- returns BASE_FE.get_block_rect(row,col)
- returns BASE_FE.get_block_rect(row,col)
I.e. returns a rectangle that tells you what part of the original image is associated
I.e. returns a rectangle that tells you what part of the original image is associated
...
...
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