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
3044fff8
"...git@developer.sourcefind.cn:OpenDAS/pytorch-encoding.git" did not exist on "07f25381fa94738de086f4b56169497545a554ef"
Commit
3044fff8
authored
Jun 03, 2015
by
Davis King
Browse files
Improved the depth testing for the perspective_display.
parent
acca22a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
57 deletions
+16
-57
dlib/gui_widgets/widgets.cpp
dlib/gui_widgets/widgets.cpp
+14
-47
dlib/gui_widgets/widgets.h
dlib/gui_widgets/widgets.h
+2
-10
No files found.
dlib/gui_widgets/widgets.cpp
View file @
3044fff8
...
@@ -5722,14 +5722,12 @@ namespace dlib
...
@@ -5722,14 +5722,12 @@ namespace dlib
max_pts
.
z
()
=
std
::
max
(
overlay
[
i
].
p2
.
z
(),
max_pts
.
z
());
max_pts
.
z
()
=
std
::
max
(
overlay
[
i
].
p2
.
z
(),
max_pts
.
z
());
}
}
dot_sorting_is_stale
=
true
;
tform
=
camera_transform
(
max_pts
,
tform
=
camera_transform
(
max_pts
,
sum_pts
/
(
overlay_lines
.
size
()
*
2
+
overlay_dots
.
size
()),
sum_pts
/
(
overlay_lines
.
size
()
*
2
+
overlay_dots
.
size
()),
vector
<
double
>
(
0
,
0
,
1
),
vector
<
double
>
(
0
,
0
,
1
),
tform
.
get_camera_field_of_view
(),
tform
.
get_camera_field_of_view
(),
std
::
min
(
rect
.
width
(),
rect
.
height
()));
std
::
min
(
rect
.
width
(),
rect
.
height
()));
sort_dots
();
// make the parent window redraw us now that we changed the overlay
// make the parent window redraw us now that we changed the overlay
parent
.
invalidate_rectangle
(
rect
);
parent
.
invalidate_rectangle
(
rect
);
...
@@ -5748,7 +5746,7 @@ namespace dlib
...
@@ -5748,7 +5746,7 @@ namespace dlib
for
(
unsigned
long
i
=
0
;
i
<
overlay
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
overlay
.
size
();
++
i
)
{
{
overlay_dots
.
push_back
(
std
::
make_pair
(
overlay
[
i
]
,
0
)
);
overlay_dots
.
push_back
(
overlay
[
i
]);
sum_pts
+=
overlay
[
i
].
p
;
sum_pts
+=
overlay
[
i
].
p
;
max_pts
.
x
()
=
std
::
max
(
overlay
[
i
].
p
.
x
(),
max_pts
.
x
());
max_pts
.
x
()
=
std
::
max
(
overlay
[
i
].
p
.
x
(),
max_pts
.
x
());
...
@@ -5756,7 +5754,6 @@ namespace dlib
...
@@ -5756,7 +5754,6 @@ namespace dlib
max_pts
.
z
()
=
std
::
max
(
overlay
[
i
].
p
.
z
(),
max_pts
.
z
());
max_pts
.
z
()
=
std
::
max
(
overlay
[
i
].
p
.
z
(),
max_pts
.
z
());
}
}
dot_sorting_is_stale
=
true
;
tform
=
camera_transform
(
max_pts
,
tform
=
camera_transform
(
max_pts
,
sum_pts
/
(
overlay_lines
.
size
()
*
2
+
overlay_dots
.
size
()),
sum_pts
/
(
overlay_lines
.
size
()
*
2
+
overlay_dots
.
size
()),
vector
<
double
>
(
0
,
0
,
1
),
vector
<
double
>
(
0
,
0
,
1
),
...
@@ -5803,6 +5800,10 @@ namespace dlib
...
@@ -5803,6 +5800,10 @@ namespace dlib
const
canvas
&
c
const
canvas
&
c
)
const
)
const
{
{
if
(
depth
.
nr
()
<
c
.
height
()
||
depth
.
nc
()
<
c
.
width
())
depth
.
set_size
(
c
.
height
(),
c
.
width
());
assign_all_pixels
(
depth
,
std
::
numeric_limits
<
float
>::
infinity
());
rectangle
area
=
rect
.
intersect
(
c
);
rectangle
area
=
rect
.
intersect
(
c
);
fill_rect
(
c
,
area
,
0
);
fill_rect
(
c
,
area
,
0
);
for
(
unsigned
long
i
=
0
;
i
<
overlay_lines
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
overlay_lines
.
size
();
++
i
)
...
@@ -5814,9 +5815,13 @@ namespace dlib
...
@@ -5814,9 +5815,13 @@ namespace dlib
}
}
for
(
unsigned
long
i
=
0
;
i
<
overlay_dots
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
overlay_dots
.
size
();
++
i
)
{
{
point
p
=
tform
(
overlay_dots
[
i
].
first
.
p
)
+
rect
.
tl_corner
();
double
scale
,
distance
;
if
(
area
.
contains
(
p
))
point
p
=
tform
(
overlay_dots
[
i
].
p
,
scale
,
distance
)
+
rect
.
tl_corner
();
assign_pixel
(
c
[
p
.
y
()
-
c
.
top
()][
p
.
x
()
-
c
.
left
()],
overlay_dots
[
i
].
first
.
color
);
if
(
area
.
contains
(
p
)
&&
depth
[
p
.
y
()
-
c
.
top
()][
p
.
x
()
-
c
.
left
()]
>
distance
)
{
depth
[
p
.
y
()
-
c
.
top
()][
p
.
x
()
-
c
.
left
()]
=
distance
;
assign_pixel
(
c
[
p
.
y
()
-
c
.
top
()][
p
.
x
()
-
c
.
left
()],
overlay_dots
[
i
].
color
);
}
}
}
}
}
...
@@ -5885,7 +5890,7 @@ namespace dlib
...
@@ -5885,7 +5890,7 @@ namespace dlib
const
dpoint
pp
(
x
,
y
);
const
dpoint
pp
(
x
,
y
);
for
(
unsigned
long
i
=
0
;
i
<
overlay_dots
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
overlay_dots
.
size
();
++
i
)
{
{
dpoint
p
=
tform
(
overlay_dots
[
i
].
first
.
p
)
+
rect
.
tl_corner
();
dpoint
p
=
tform
(
overlay_dots
[
i
].
p
)
+
rect
.
tl_corner
();
double
dist
=
length_squared
(
p
-
pp
);
double
dist
=
length_squared
(
p
-
pp
);
if
(
dist
<
best_dist
)
if
(
dist
<
best_dist
)
{
{
...
@@ -5894,43 +5899,7 @@ namespace dlib
...
@@ -5894,43 +5899,7 @@ namespace dlib
}
}
}
}
if
(
dot_clicked_event_handler
.
is_set
())
if
(
dot_clicked_event_handler
.
is_set
())
dot_clicked_event_handler
(
overlay_dots
[
best_idx
].
first
.
p
);
dot_clicked_event_handler
(
overlay_dots
[
best_idx
].
p
);
}
}
// ----------------------------------------------------------------------------------------
void
perspective_display
::
sort_dots
(
)
{
if
(
dot_sorting_is_stale
)
{
// sort the dots so that the dots farthest from the camera are drawn first.
// We begin by updating the distance from each dot to the camera.
const
vector
<
double
>
cam
=
tform
.
get_camera_pos
();
for
(
unsigned
long
i
=
0
;
i
<
overlay_dots
.
size
();
++
i
)
overlay_dots
[
i
].
second
=
length_squared
(
overlay_dots
[
i
].
first
.
p
-
cam
);
std
::
sort
(
overlay_dots
.
rbegin
(),
overlay_dots
.
rend
(),
compare_second
);
dot_sorting_is_stale
=
false
;
parent
.
invalidate_rectangle
(
rect
);
}
}
// ----------------------------------------------------------------------------------------
void
perspective_display
::
on_mouse_up
(
unsigned
long
,
// btn,
unsigned
long
,
// state,
long
,
// x,
long
// y
)
{
if
(
!
hidden
&&
enabled
&&
overlay_dots
.
size
()
!=
0
)
{
sort_dots
();
}
}
}
}
...
@@ -5961,7 +5930,6 @@ namespace dlib
...
@@ -5961,7 +5930,6 @@ namespace dlib
// now make it have the correct radius relative to the looking at point.
// now make it have the correct radius relative to the looking at point.
new_pos
=
(
new_pos
-
tform
.
get_camera_looking_at
()).
normalize
()
*
length
(
radius
)
+
tform
.
get_camera_looking_at
();
new_pos
=
(
new_pos
-
tform
.
get_camera_looking_at
()).
normalize
()
*
length
(
radius
)
+
tform
.
get_camera_looking_at
();
dot_sorting_is_stale
=
true
;
tform
=
camera_transform
(
new_pos
,
tform
=
camera_transform
(
new_pos
,
tform
.
get_camera_looking_at
(),
tform
.
get_camera_looking_at
(),
tangent_y
,
tangent_y
,
...
@@ -5984,7 +5952,6 @@ namespace dlib
...
@@ -5984,7 +5952,6 @@ namespace dlib
vector
<
double
>
offset
=
tangent_x
*
delta
.
x
()
+
tangent_y
*-
delta
.
y
();
vector
<
double
>
offset
=
tangent_x
*
delta
.
x
()
+
tangent_y
*-
delta
.
y
();
dot_sorting_is_stale
=
true
;
tform
=
camera_transform
(
tform
=
camera_transform
(
tform
.
get_camera_pos
()
+
offset
,
tform
.
get_camera_pos
()
+
offset
,
tform
.
get_camera_looking_at
()
+
offset
,
tform
.
get_camera_looking_at
()
+
offset
,
...
...
dlib/gui_widgets/widgets.h
View file @
3044fff8
...
@@ -3706,13 +3706,6 @@ namespace dlib
...
@@ -3706,13 +3706,6 @@ namespace dlib
bool
is_double_click
bool
is_double_click
);
);
void
on_mouse_up
(
unsigned
long
btn
,
unsigned
long
state
,
long
x
,
long
y
);
void
on_mouse_move
(
void
on_mouse_move
(
unsigned
long
state
,
unsigned
long
state
,
long
x
,
long
x
,
...
@@ -3724,17 +3717,16 @@ namespace dlib
...
@@ -3724,17 +3717,16 @@ namespace dlib
const
std
::
pair
<
overlay_dot
,
float
>&
b
const
std
::
pair
<
overlay_dot
,
float
>&
b
)
{
return
a
.
second
<
b
.
second
;
}
)
{
return
a
.
second
<
b
.
second
;
}
void
sort_dots
();
point
last
;
point
last
;
std
::
vector
<
overlay_line
>
overlay_lines
;
std
::
vector
<
overlay_line
>
overlay_lines
;
std
::
vector
<
std
::
pair
<
overlay_dot
,
float
>
>
overlay_dots
;
std
::
vector
<
overlay_dot
>
overlay_dots
;
camera_transform
tform
;
camera_transform
tform
;
vector
<
double
>
sum_pts
;
vector
<
double
>
sum_pts
;
vector
<
double
>
max_pts
;
vector
<
double
>
max_pts
;
any_function
<
void
(
const
vector
<
double
>&
)
>
dot_clicked_event_handler
;
any_function
<
void
(
const
vector
<
double
>&
)
>
dot_clicked_event_handler
;
bool
dot_sorting_is_stale
;
mutable
array2d
<
float
>
depth
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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