JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Tweet
Loading...
Searching...
No Matches
PyPostDepth.py
Go to the documentation of this file.
1
import
pyjevois
2
if
pyjevois.pro:
import
libjevoispro
as
jevois
3
else
:
import
libjevois
as
jevois
4
5
import
numpy
as
np
6
7
## Python DNN post-processor for depth map
8
#
9
# Renders a depth map as a semi-transparent overlay over the input frames.
10
#
11
# @author Laurent Itti
12
#
13
# @email itti\@usc.edu
14
# @address University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA
15
# @copyright Copyright (C) 2023 by Laurent Itti, iLab and the University of Southern California
16
# @mainurl http://jevois.org
17
# @supporturl http://jevois.org/doc
18
# @otherurl http://iLab.usc.edu
19
# @license GPL v3
20
# @distribution Unrestricted
21
# @restrictions None
22
# @ingroup pydnn
23
class
PyPostDepth
:
24
# ###################################################################################################
25
## Constructor
26
def
__init__
(self):
27
self.
depthmap
=
None
28
29
# ###################################################################################################
30
## JeVois parameters initialization
31
def
init
(self):
32
pc =
jevois.ParameterCategory
(
"DNN Post-Processing Options"
,
""
)
33
34
self.
alpha
= jevois.Parameter(self,
'alpha'
,
'byte'
,
35
"Alpha value for depth overlay"
,
36
200, pc)
37
38
self.
dfac
= jevois.Parameter(self,
'dfac'
,
'float'
,
39
"Depth conversion factor to bring values to [0..255]"
,
40
50, pc)
41
42
# ###################################################################################################
43
## Get network outputs
44
def
process
(self, outs, preproc):
45
if
len(outs) != 1: jevois.LERROR(f
"Received {len(outs)} network outputs -- USING FIRST ONE"
)
46
dmap = (np.squeeze(outs[0]) * self.
dfac
.get()).clip(0, 255).astype(
'uint8'
)
47
48
# Compute overlay corner coords within the input image, for use in report():
49
self.
tlx
, self.
tly
, self.
cw
, self.
ch
= preproc.getUnscaledCropRect(0)
50
51
# Save RGBA depth map for later display:
52
alphamap = np.full_like(dmap, self.
alpha
.get())
53
self.
depthmap
= np.dstack( (dmap, dmap, dmap, alphamap) )
# RGBA
54
55
# ###################################################################################################
56
## Report the latest results obtained by process() by drawing them
57
def
report
(self, outimg, helper, overlay, idle):
58
59
if
helper
is
not
None
and
overlay
and
self.
depthmap
is
not
None
:
60
# Convert box coords from input image to display ("c" is the displayed camera image):
61
tl = helper.i2d(self.
tlx
, self.
tly
,
"c"
)
62
wh = helper.i2ds(self.
cw
, self.
ch
,
"c"
)
63
64
# Draw as a semi-transparent overlay. OpenGL will do scaling/stretching/blending as needed:
65
helper.drawImage(
"depthmap"
, self.
depthmap
,
True
, int(tl.x), int(tl.y), int(wh.x), int(wh.y),
False
,
True
)
PyPostDepth.PyPostDepth
Python DNN post-processor for depth map.
Definition
PyPostDepth.py:23
PyPostDepth.PyPostDepth.__init__
__init__(self)
Constructor.
Definition
PyPostDepth.py:26
PyPostDepth.PyPostDepth.tly
tly
Definition
PyPostDepth.py:49
PyPostDepth.PyPostDepth.dfac
dfac
Definition
PyPostDepth.py:38
PyPostDepth.PyPostDepth.tlx
tlx
Definition
PyPostDepth.py:49
PyPostDepth.PyPostDepth.process
process(self, outs, preproc)
Get network outputs.
Definition
PyPostDepth.py:44
PyPostDepth.PyPostDepth.cw
cw
Definition
PyPostDepth.py:49
PyPostDepth.PyPostDepth.report
report(self, outimg, helper, overlay, idle)
Report the latest results obtained by process() by drawing them.
Definition
PyPostDepth.py:57
PyPostDepth.PyPostDepth.depthmap
depthmap
Definition
PyPostDepth.py:27
PyPostDepth.PyPostDepth.alpha
alpha
Definition
PyPostDepth.py:34
PyPostDepth.PyPostDepth.ch
ch
Definition
PyPostDepth.py:49
PyPostDepth.PyPostDepth.init
init(self)
JeVois parameters initialization.
Definition
PyPostDepth.py:31
jevois::ParameterCategory
share-jevoispro
pydnn
post
PyPostDepth.py
Please help us improve this page: Edit it on
GitHub
or
email us your edits and suggestions.
Generated by
1.9.8