Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ar_sandbox_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AR_Sandbox
ar_sandbox_python
Commits
a46ff806
Commit
a46ff806
authored
3 years ago
by
Alexis Durgnat
Browse files
Options
Downloads
Patches
Plain Diff
Document functions
parent
77ccc2c0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ar_sandbox/examples/examples.py
+31
-2
31 additions, 2 deletions
src/ar_sandbox/examples/examples.py
with
31 additions
and
2 deletions
src/ar_sandbox/examples/examples.py
+
31
−
2
View file @
a46ff806
...
...
@@ -9,10 +9,26 @@ COLORS = [
]
class
LevelDisplay
():
colormap
=
COLORS
@staticmethod
def
get_color
(
depth_matrix
,
frame
,
draw_lines
=
True
,
colormap
=
COLORS
):
"""
Given a depth matrix between 0-1, return a color from a given colormap.
The colormap is a list of tuples containing the depth value, and the
color for this level :
(depth_value, [RedVal, GreenVal, BlueVal])
The colormap should at least contain a color for the depths 0 and 1.
See COLORS for an example colormap.
Arguments:
depth_matrix : Normalized 1 channel numpy matrix
frame: Unused. The frame captured by the camera
draw_line: Should line be drawn between levels ?
colormap: Override the default colormap.
Return:
A 3 channel matrix in BGR frame of the same size as depth_matrix.
"""
points
=
np
.
array
([
c
[
0
]
for
c
in
colormap
])
r
=
[
c
[
1
][
2
]
for
c
in
colormap
]
g
=
[
c
[
1
][
1
]
for
c
in
colormap
]
...
...
@@ -30,6 +46,19 @@ class LevelDisplay():
@staticmethod
def
draw_lines
(
depth
,
points
,
width
=
0.025
,
between_levels
=
False
):
"""
Given the depth matrix and a list of points, return a mask for every
value near the points. If between_levels is set to True, mask in
between the point instead of on the point.
Arguments:
depth: A depth matrix
points: A list of float values
width: The
'
width
'
of the lines to be drawn. Will mask
width/2
Return:
A mask representing the lines.
"""
lines
=
[]
mask
=
np
.
ma
.
make_mask
(
np
.
zeros
(
depth
.
shape
),
shrink
=
False
)
if
between_levels
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment