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
9a336696
Commit
9a336696
authored
Feb 29, 2020
by
Davis King
Browse files
A little bit of cleanup and docs. Also added missing mutex lock.
parent
4ff365a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
dlib/gui_widgets/widgets.cpp
dlib/gui_widgets/widgets.cpp
+2
-0
dlib/gui_widgets/widgets_abstract.h
dlib/gui_widgets/widgets_abstract.h
+14
-0
tools/imglab/src/cluster.cpp
tools/imglab/src/cluster.cpp
+15
-18
No files found.
dlib/gui_widgets/widgets.cpp
View file @
9a336696
...
@@ -7068,6 +7068,7 @@ namespace dlib
...
@@ -7068,6 +7068,7 @@ namespace dlib
zoom_in
(
zoom_in
(
)
)
{
{
auto_mutex
M
(
m
);
if
(
zoom_in_scale
<
100
&&
zoom_out_scale
==
1
)
if
(
zoom_in_scale
<
100
&&
zoom_out_scale
==
1
)
{
{
const
point
mouse_loc
(
lastx
,
lasty
);
const
point
mouse_loc
(
lastx
,
lasty
);
...
@@ -7130,6 +7131,7 @@ namespace dlib
...
@@ -7130,6 +7131,7 @@ namespace dlib
zoom_out
(
zoom_out
(
)
)
{
{
auto_mutex
M
(
m
);
if
(
zoom_in_scale
!=
1
)
if
(
zoom_in_scale
!=
1
)
{
{
const
point
mouse_loc
(
lastx
,
lasty
);
const
point
mouse_loc
(
lastx
,
lasty
);
...
...
dlib/gui_widgets/widgets_abstract.h
View file @
9a336696
...
@@ -2732,6 +2732,20 @@ namespace dlib
...
@@ -2732,6 +2732,20 @@ namespace dlib
If it returns false then the overlay is not user editable.
If it returns false then the overlay is not user editable.
!*/
!*/
void
zoom_in
(
);
/*!
ensures
- performs a zoom in as if the user tried to zoom by scrolling the mouse wheel.
!*/
void
zoom_out
(
);
/*!
ensures
- performs a zoom out as if the user tried to zoom by scrolling the mouse wheel.
!*/
template
<
template
<
typename
T
typename
T
>
>
...
...
tools/imglab/src/cluster.cpp
View file @
9a336696
...
@@ -41,19 +41,13 @@ std::vector<assignment> angular_cluster (
...
@@ -41,19 +41,13 @@ std::vector<assignment> angular_cluster (
}
}
// find the centroid of feats
// find the centroid of feats
matrix
<
double
,
0
,
1
>
m
;
const
matrix
<
double
,
0
,
1
>
m
=
mean
(
mat
(
feats
));
for
(
unsigned
long
i
=
0
;
i
<
feats
.
size
();
++
i
)
m
+=
feats
[
i
];
m
/=
feats
.
size
();
// Now center feats and then project onto the unit sphere. The reason for projecting
// Now center feats and then project onto the unit sphere. The reason for projecting
// onto the unit sphere is so pick_initial_centers() works in a sensible way.
// onto the unit sphere is so pick_initial_centers() works in a sensible way.
for
(
unsigned
long
i
=
0
;
i
<
feats
.
size
();
++
i
)
for
(
auto
&
f
:
feats
)
{
{
feats
[
i
]
-=
m
;
f
=
normalize
(
f
-
m
);
double
len
=
length
(
feats
[
i
]);
if
(
len
!=
0
)
feats
[
i
]
/=
len
;
}
}
// now do angular clustering of the points
// now do angular clustering of the points
...
@@ -78,20 +72,23 @@ std::vector<assignment> chinese_cluster (
...
@@ -78,20 +72,23 @@ std::vector<assignment> chinese_cluster (
unsigned
long
&
num_clusters
unsigned
long
&
num_clusters
)
)
{
{
// try to find a good value to select if we should add a vertex in the graph
DLIB_CASSERT
(
feats
.
size
()
!=
0
,
"The dataset can't be empty"
);
matrix
<
double
,
0
,
1
>
m
;
for
(
unsigned
long
i
=
0
;
i
<
feats
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
feats
.
size
();
++
i
)
m
+=
feats
[
i
];
{
m
/=
feats
.
size
();
DLIB_CASSERT
(
feats
[
i
].
size
()
==
feats
[
0
].
size
(),
"All feature vectors must have the same length."
);
}
for
(
unsigned
long
i
=
0
;
i
<
feats
.
size
();
++
i
)
// Try to find a good value to select if we should add a vertex in the graph. First we
// normalize the features.
const
matrix
<
double
,
0
,
1
>
m
=
mean
(
mat
(
feats
));
for
(
auto
&
f
:
feats
)
{
{
feats
[
i
]
-=
m
;
f
=
normalize
(
f
-
m
);
double
len
=
length
(
feats
[
i
]);
if
(
len
!=
0
)
feats
[
i
]
/=
len
;
}
}
// Then we find the average distance between them, that average will be a good threshold to
// decide if pairs are connected.
running_stats
<
double
>
rs
;
running_stats
<
double
>
rs
;
for
(
size_t
i
=
0
;
i
<
feats
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
feats
.
size
();
++
i
)
{
for
(
size_t
j
=
i
;
j
<
feats
.
size
();
++
j
)
{
for
(
size_t
j
=
i
;
j
<
feats
.
size
();
++
j
)
{
...
...
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