Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AAU NAV
development
camera_streaming
Commits
f7b13fc8
Commit
f7b13fc8
authored
May 23, 2020
by
Barcis, Michal
Browse files
displaying GUI with no incomming messages
parent
bcba197a
Changes
1
Hide whitespace changes
Inline
Side-by-side
camera_streaming/camera_subscriber.py
View file @
f7b13fc8
...
@@ -34,6 +34,9 @@ CUSTOM_QOS = QoSProfile(
...
@@ -34,6 +34,9 @@ CUSTOM_QOS = QoSProfile(
)
)
SAVE_IMAGES
=
False
class
CameraSubscriber
(
Node
,
MissionExecutor
):
class
CameraSubscriber
(
Node
,
MissionExecutor
):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
(
'camera_subscriber'
)
super
().
__init__
(
'camera_subscriber'
)
...
@@ -78,7 +81,8 @@ class CameraSubscriber(Node, MissionExecutor):
...
@@ -78,7 +81,8 @@ class CameraSubscriber(Node, MissionExecutor):
int
(
np
.
ceil
(
hosts_num
/
int
(
np
.
sqrt
(
hosts_num
))))
int
(
np
.
ceil
(
hosts_num
/
int
(
np
.
sqrt
(
hosts_num
))))
)
)
self
.
images
=
np
.
zeros
(
self
.
shape
+
self
.
resolution
)
self
.
images
=
np
.
zeros
(
self
.
shape
+
self
.
resolution
)
self
.
display_streams
()
self
.
create_timer
(
1
,
self
.
display_streams
)
self
.
camera_subscriptions
=
[
self
.
camera_subscriptions
=
[
self
.
create_subscription
(
self
.
create_subscription
(
...
@@ -209,7 +213,7 @@ class CameraSubscriber(Node, MissionExecutor):
...
@@ -209,7 +213,7 @@ class CameraSubscriber(Node, MissionExecutor):
value
=
(
0
,
0
,
2
*
red
[
r
,
c
]))
value
=
(
0
,
0
,
2
*
red
[
r
,
c
]))
h
,
w
,
_
=
img
.
shape
h
,
w
,
_
=
img
.
shape
y0
=
r
*
(
sp_height
+
pad_top
)
+
title_pad
y0
=
r
*
(
sp_height
+
pad_top
)
+
title_pad
x0
=
c
*
(
sp_width
+
pad
)
# + pad//2
x0
=
c
*
(
sp_width
+
pad
)
# + pad//2
frame
[
y0
:
y0
+
h
,
x0
:
x0
+
w
]
=
img
frame
[
y0
:
y0
+
h
,
x0
:
x0
+
w
]
=
img
frame
=
cv2
.
putText
(
frame
=
cv2
.
putText
(
...
@@ -232,15 +236,18 @@ class CameraSubscriber(Node, MissionExecutor):
...
@@ -232,15 +236,18 @@ class CameraSubscriber(Node, MissionExecutor):
f
'
{
fps
[
r
,
c
]
}
FPS'
,
f
'
{
fps
[
r
,
c
]
}
FPS'
,
(
x0
,
y0
+
sp_height
-
10
),
(
x0
,
y0
+
sp_height
-
10
),
cv2
.
FONT_HERSHEY_DUPLEX
,
cv2
.
FONT_HERSHEY_DUPLEX
,
3
,
((
1
-
2
*
red
[
r
,
c
]),
(
1
-
3
*
red
[
r
,
c
]),
1
),
3
,
((
1
-
2
*
red
[
r
,
c
]),
(
1
-
3
*
red
[
r
,
c
]),
1
),
thickness
=
3
,
thickness
=
3
,
)
)
now
=
datetime
.
now
().
timestamp
()
now
=
datetime
.
now
().
timestamp
()
if
now
-
self
.
last_saved
>
5
:
if
now
-
self
.
last_saved
>
5
and
SAVE_IMAGES
:
print
(
'saving'
)
print
(
'saving'
)
frame2
=
frame
.
copy
()
*
255
frame2
=
frame
.
copy
()
*
255
cv2
.
imwrite
(
f
'/home/agniewek/longTemp/infdist/img
{
datetime
.
now
()
}
.jpg'
,
frame2
)
cv2
.
imwrite
(
f
'/home/agniewek/longTemp/infdist/img
{
datetime
.
now
()
}
.jpg'
,
frame2
)
self
.
saved
+=
1
self
.
saved
+=
1
self
.
last_saved
=
now
self
.
last_saved
=
now
frame
=
cv2
.
resize
(
frame
,
(
frame
.
shape
[
1
]
//
2
,
frame
.
shape
[
0
]
//
2
))
frame
=
cv2
.
resize
(
frame
,
(
frame
.
shape
[
1
]
//
2
,
frame
.
shape
[
0
]
//
2
))
...
...
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