Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ROS_human_detection
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
Service Desk
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
mobile_robotics
raadical_project
ROS_human_detection
Commits
7d02185b
Commit
7d02185b
authored
4 years ago
by
Eetu Silvennoinen
Browse files
Options
Downloads
Patches
Plain Diff
Fix loggin
parent
a2e788e2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
human_detection/src/webcam.py
+17
-31
17 additions, 31 deletions
human_detection/src/webcam.py
with
17 additions
and
31 deletions
human_detection/src/webcam.py
+
17
−
31
View file @
7d02185b
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
import
rospy
import
rospy
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
from
std_srvs.srv
import
Trigger
,
TriggerResponse
sys
.
path
.
append
(
os
.
getcwd
())
sys
.
path
.
append
(
os
.
getcwd
())
...
@@ -20,11 +21,11 @@ from object_detection.utils import label_map_util
...
@@ -20,11 +21,11 @@ from object_detection.utils import label_map_util
from
object_detection.utils
import
visualization_utils
as
vis_util
from
object_detection.utils
import
visualization_utils
as
vis_util
# Defining Paths
# Defining Paths
CWD
_PATH
=
os
.
getcwd
(
)
SRC
_PATH
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)
)
LABEL_MAPS
=
[
'
human_label_map.pbtxt
'
,
'
mscoco_label_map.pbtxt
'
]
LABEL_MAPS
=
[
'
human_label_map.pbtxt
'
,
'
mscoco_label_map.pbtxt
'
]
MODEL_NAME
=
'
ssd_mobilenet_v1_coco_2017_11_17
'
MODEL_NAME
=
'
ssd_mobilenet_v1_coco_2017_11_17
'
PATH_TO_CKPT
=
os
.
path
.
join
(
CWD
_PATH
,
MODEL_NAME
,
'
frozen_inference_graph.pb
'
)
PATH_TO_CKPT
=
os
.
path
.
join
(
SRC
_PATH
,
MODEL_NAME
,
'
frozen_inference_graph.pb
'
)
PATH_TO_LABELS
=
os
.
path
.
join
(
CWD
_PATH
+
'
/data
'
,
LABEL_MAPS
[
0
])
PATH_TO_LABELS
=
os
.
path
.
join
(
SRC
_PATH
+
'
/data
'
,
LABEL_MAPS
[
0
])
# Load the label map.
# Load the label map.
label_map
=
label_map_util
.
load_labelmap
(
PATH_TO_LABELS
)
label_map
=
label_map_util
.
load_labelmap
(
PATH_TO_LABELS
)
...
@@ -127,6 +128,7 @@ class human_detector:
...
@@ -127,6 +128,7 @@ class human_detector:
list_length
=
0
list_length
=
0
bbx_list
=
box_list
()
bbx_list
=
box_list
()
bbx_list
.
header
.
stamp
=
data
.
header
.
stamp
bbx_list
.
header
.
stamp
=
data
.
header
.
stamp
spotted
=
False
for
score
in
scores
[
0
]:
for
score
in
scores
[
0
]:
if
score
>
0.6
:
if
score
>
0.6
:
...
@@ -137,6 +139,18 @@ class human_detector:
...
@@ -137,6 +139,18 @@ class human_detector:
coordinates
.
ymax
=
int
(
boxes
[
0
,
counter
,
2
]
*
screen_height
)
coordinates
.
ymax
=
int
(
boxes
[
0
,
counter
,
2
]
*
screen_height
)
coordinates
.
xmax
=
int
(
boxes
[
0
,
counter
,
3
]
*
screen_width
)
coordinates
.
xmax
=
int
(
boxes
[
0
,
counter
,
3
]
*
screen_width
)
bbx_list
.
people_list
.
append
(
coordinates
)
bbx_list
.
people_list
.
append
(
coordinates
)
rospy
.
wait_for_service
(
'
return_to_home
'
)
try
:
if
spotted
is
False
:
rospy
.
loginfo
(
"
Human spotted! Returning home
"
)
return_to_home
=
rospy
.
ServiceProxy
(
'
return_to_home
'
,
Trigger
)
status
=
return_to_home
()
rospy
.
loginfo
(
status
.
message
)
spotted
=
True
except
:
print
(
"
Service call failed: %s
"
)
counter
+=
1
counter
+=
1
# print(list_length)
# print(list_length)
...
@@ -166,31 +180,3 @@ if __name__ == '__main__':
...
@@ -166,31 +180,3 @@ if __name__ == '__main__':
print
(
'
Current Tensorflow Version:
'
+
str
(
tf
.
__version__
))
print
(
'
Current Tensorflow Version:
'
+
str
(
tf
.
__version__
))
rospy
.
set_param
(
'
use_sim_time
'
,
'
True
'
)
rospy
.
set_param
(
'
use_sim_time
'
,
'
True
'
)
main
()
main
()
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