Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
64e26c7a
Commit
64e26c7a
authored
Sep 02, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ability to put overlay circles into the image_display and
image_window widgets.
parent
d6d1ab85
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
203 additions
and
0 deletions
+203
-0
widgets.cpp
dlib/gui_widgets/widgets.cpp
+74
-0
widgets.h
dlib/gui_widgets/widgets.h
+37
-0
widgets_abstract.h
dlib/gui_widgets/widgets_abstract.h
+92
-0
No files found.
dlib/gui_widgets/widgets.cpp
View file @
64e26c7a
...
...
@@ -5800,6 +5800,22 @@ namespace dlib
parent
.
invalidate_rectangle
(
rectangle
(
overlay
.
p1
+
origin
,
overlay
.
p2
+
origin
));
}
// ----------------------------------------------------------------------------------------
void
image_display
::
add_overlay
(
const
overlay_circle
&
overlay
)
{
auto_mutex
M
(
m
);
// push this new overlay into our overlay vector
overlay_circles
.
push_back
(
overlay
);
// make the parent window redraw us now that we changed the overlay
parent
.
invalidate_rectangle
(
rect
);
}
// ----------------------------------------------------------------------------------------
void
image_display
::
...
...
@@ -5832,6 +5848,22 @@ namespace dlib
parent
.
invalidate_rectangle
(
rect
);
}
// ----------------------------------------------------------------------------------------
void
image_display
::
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
)
{
auto_mutex
M
(
m
);
// push this new overlay into our overlay vector
overlay_circles
.
insert
(
overlay_circles
.
end
(),
overlay
.
begin
(),
overlay
.
end
());
// make the parent window redraw us now that we changed the overlay
parent
.
invalidate_rectangle
(
rect
);
}
// ----------------------------------------------------------------------------------------
void
image_display
::
...
...
@@ -5841,6 +5873,7 @@ namespace dlib
auto_mutex
M
(
m
);
overlay_rects
.
clear
();
overlay_lines
.
clear
();
overlay_circles
.
clear
();
parent
.
invalidate_rectangle
(
rect
);
}
...
...
@@ -5957,6 +5990,27 @@ namespace dlib
overlay_lines
[
i
].
color
,
area
);
}
// now draw all the overlay circles
for
(
unsigned
long
i
=
0
;
i
<
overlay_circles
.
size
();
++
i
)
{
const
point
center
=
zoom_in_scale
*
overlay_circles
[
i
].
center
/
zoom_out_scale
+
origin
;
const
int
radius
=
zoom_in_scale
*
overlay_circles
[
i
].
radius
/
zoom_out_scale
;
draw_circle
(
c
,
center
,
radius
,
overlay_circles
[
i
].
color
,
area
);
if
(
overlay_circles
[
i
].
label
.
size
()
!=
0
)
{
const
point
temp
=
center
+
point
(
0
,
radius
);
// make a rectangle that is at the spot we want to draw our string
rectangle
r
(
temp
,
temp
+
point
(
10000
,
10000
));
mfont
->
draw_string
(
c
,
r
,
overlay_circles
[
i
].
label
,
overlay_circles
[
i
].
color
,
0
,
std
::
string
::
npos
,
area
);
}
}
if
(
drawing_rect
)
draw_rectangle
(
c
,
rect_to_draw
,
invert_pixel
(
default_rect_color
),
area
);
}
...
...
@@ -6417,6 +6471,16 @@ namespace dlib
gui_img
.
add_overlay
(
overlay
);
}
// ----------------------------------------------------------------------------------------
void
image_window
::
add_overlay
(
const
overlay_circle
&
overlay
)
{
gui_img
.
add_overlay
(
overlay
);
}
// ----------------------------------------------------------------------------------------
void
image_window
::
...
...
@@ -6437,6 +6501,16 @@ namespace dlib
gui_img
.
add_overlay
(
overlay
);
}
// ----------------------------------------------------------------------------------------
void
image_window
::
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
)
{
gui_img
.
add_overlay
(
overlay
);
}
// ----------------------------------------------------------------------------------------
void
image_window
::
...
...
dlib/gui_widgets/widgets.h
View file @
64e26c7a
...
...
@@ -27,6 +27,7 @@
#include <vector>
#include "../any.h"
#include <set>
#include "../image_processing/full_object_detection.h"
#ifdef _MSC_VER
// This #pragma directive is also located in the algs.h file but for whatever
...
...
@@ -3323,6 +3324,24 @@ namespace dlib
rgb_alpha_pixel
color
;
};
struct
overlay_circle
{
overlay_circle
()
:
radius
(
0
)
{
assign_pixel
(
color
,
0
);}
template
<
typename
pixel_type
>
overlay_circle
(
const
point
&
center_
,
const
int
radius_
,
pixel_type
p
)
:
center
(
center_
),
radius
(
radius_
)
{
assign_pixel
(
color
,
p
);
}
template
<
typename
pixel_type
>
overlay_circle
(
const
point
&
center_
,
const
int
radius_
,
pixel_type
p
,
const
std
::
string
&
l
)
:
center
(
center_
),
radius
(
radius_
),
label
(
l
)
{
assign_pixel
(
color
,
p
);
}
point
center
;
int
radius
;
rgb_alpha_pixel
color
;
std
::
string
label
;
};
void
add_overlay
(
const
overlay_rect
&
overlay
);
...
...
@@ -3331,6 +3350,10 @@ namespace dlib
const
overlay_line
&
overlay
);
void
add_overlay
(
const
overlay_circle
&
overlay
);
void
add_overlay
(
const
std
::
vector
<
overlay_rect
>&
overlay
);
...
...
@@ -3339,6 +3362,10 @@ namespace dlib
const
std
::
vector
<
overlay_line
>&
overlay
);
void
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
);
void
clear_overlay
(
);
...
...
@@ -3470,6 +3497,7 @@ namespace dlib
std
::
vector
<
overlay_rect
>
overlay_rects
;
std
::
vector
<
overlay_line
>
overlay_lines
;
std
::
vector
<
overlay_circle
>
overlay_circles
;
long
zoom_in_scale
;
long
zoom_out_scale
;
...
...
@@ -3501,6 +3529,7 @@ namespace dlib
typedef
image_display
::
overlay_rect
overlay_rect
;
typedef
image_display
::
overlay_line
overlay_line
;
typedef
image_display
::
overlay_circle
overlay_circle
;
image_window
(
);
...
...
@@ -3562,6 +3591,10 @@ namespace dlib
const
overlay_line
&
overlay
);
void
add_overlay
(
const
overlay_circle
&
overlay
);
template
<
typename
pixel_type
>
void
add_overlay
(
const
point
&
p1
,
const
point
&
p2
,
pixel_type
p
)
{
add_overlay
(
image_display
::
overlay_line
(
p1
,
p2
,
p
));
}
...
...
@@ -3574,6 +3607,10 @@ namespace dlib
const
std
::
vector
<
overlay_line
>&
overlay
);
void
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
);
void
clear_overlay
(
);
...
...
dlib/gui_widgets/widgets_abstract.h
View file @
64e26c7a
...
...
@@ -2487,6 +2487,61 @@ namespace dlib
};
struct
overlay_circle
{
/*!
WHAT THIS OBJECT REPRESENTS
This object represents a circle that is drawn on top of the
image shown by this object. Each circle is represented by
its center, radius, and color. It can also have an optional
text label which will appear below the circle.
!*/
point
center
;
int
radius
;
rgb_alpha_pixel
color
;
std
::
string
label
;
overlay_circle
(
);
/*!
ensures
- #center == point(0,0)
- #radius == 0
- #color == rgb_alpha_pixel(0,0,0,0)
- #label.size() == 0
!*/
template
<
typename
pixel_type
>
overlay_circle
(
const
point
&
center_
,
const
int
radius_
,
pixel_type
p
);
/*!
ensures
- performs assign_pixel(color, p)
- #center == center_
- #radius == radius_
!*/
template
<
typename
pixel_type
>
overlay_circle
(
const
point
&
center_
,
const
int
radius_
,
pixel_type
p
,
const
std
::
string
&
label_
);
/*!
ensures
- performs assign_pixel(color, p)
- #center == center_
- #radius == radius_
- #label == label_
!*/
};
void
add_overlay
(
const
overlay_rect
&
overlay
);
...
...
@@ -2505,6 +2560,15 @@ namespace dlib
that it will be displayed.
!*/
void
add_overlay
(
const
overlay_circle
&
overlay
);
/*!
ensures
- adds the given overlay circle into this object such
that it will be displayed.
!*/
void
add_overlay
(
const
std
::
vector
<
overlay_rect
>&
overlay
);
...
...
@@ -2523,6 +2587,15 @@ namespace dlib
that they will be displayed.
!*/
void
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
);
/*!
ensures
- adds the given set of overlay circles into this object such
that they will be displayed.
!*/
void
clear_overlay
(
);
/*!
...
...
@@ -2700,6 +2773,7 @@ namespace dlib
typedef
image_display
::
overlay_rect
overlay_rect
;
typedef
image_display
::
overlay_line
overlay_line
;
typedef
image_display
::
overlay_circle
overlay_circle
;
image_window
(
);
...
...
@@ -2791,6 +2865,15 @@ namespace dlib
that it will be displayed.
!*/
void
add_overlay
(
const
overlay_circle
&
overlay
);
/*!
ensures
- adds the given overlay circle into this object such
that it will be displayed.
!*/
template
<
typename
pixel_type
>
void
add_overlay
(
const
point
&
p1
,
...
...
@@ -2820,6 +2903,15 @@ namespace dlib
that they will be displayed.
!*/
void
add_overlay
(
const
std
::
vector
<
overlay_circle
>&
overlay
);
/*!
ensures
- adds the given set of overlay circles into this object such
that they will be displayed.
!*/
void
clear_overlay
(
);
/*!
...
...
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