Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Minibot Vision
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Institut für Informatik
stair
Minibot Vision
Commits
540f83ee
Commit
540f83ee
authored
1 year ago
by
User expired
Browse files
Options
Downloads
Patches
Plain Diff
fixed camera res update and some nicer visualizations
parent
c29b04a8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
minibot_vision/scripts/SegmentSign.py
+31
-25
31 additions, 25 deletions
minibot_vision/scripts/SegmentSign.py
minibot_vision/scripts/SignDetector.py
+3
-1
3 additions, 1 deletion
minibot_vision/scripts/SignDetector.py
with
34 additions
and
26 deletions
minibot_vision/scripts/SegmentSign.py
+
31
−
25
View file @
540f83ee
...
...
@@ -79,7 +79,7 @@ def fetch_rosparams():
def
image_color_callback
(
data
):
global
img_rgb_stream
,
cv_bridge
global
img_rgb_stream
,
cv_bridge
,
IMG_RES
try
:
img_rgb_stream
=
cv_bridge
.
imgmsg_to_cv2
(
data
,
"
bgr8
"
)
...
...
@@ -89,7 +89,7 @@ def image_color_callback(data):
def
image_depth_callback
(
data
):
global
img_depth_stream
,
cv_bridge
global
img_depth_stream
,
cv_bridge
,
DEPTH_RES
try
:
img_depth_stream
=
cv_bridge
.
imgmsg_to_cv2
(
data
,
"
16UC1
"
)
...
...
@@ -119,7 +119,7 @@ def circular_mean(p, r, arr : np.array):
return
sum_px_values
/
count_px
def
do_hough_circle_detection
(
img_rgb
,
img_depth
,
VISUALIZE
=
False
):
def
do_hough_circle_detection
(
img_rgb
,
img_depth
,
VISUALIZE
=
False
,
pub_all
=
False
):
global
canny
,
accum_thresh
gray
=
cv2
.
cvtColor
(
img_rgb
,
cv2
.
COLOR_BGR2GRAY
)
...
...
@@ -134,25 +134,32 @@ def do_hough_circle_detection(img_rgb, img_depth, VISUALIZE=False):
minRadius
=
MIN_RADIUS
,
maxRadius
=
MAX_RADIUS
)
keypoint
=
[]
if
circles
is
not
None
:
circles
=
np
.
uint16
(
np
.
around
(
circles
))
i
=
circles
[
0
,
0
]
center
=
(
i
[
0
],
i
[
1
])
radius
=
i
[
2
]
# get depth in [m] (was radius * 0.4 in real world)
d
=
circular_mean
(
center
,
radius
*
0.2
,
copy
(
img_depth
))
/
1000
# todo this is a slow implementation. You might want to speedup
# filter if sign to close (circle detector will struggle) or to far (background)
# was 0.2 and 1.0
if
d
<
MIN_DEPTH
or
d
>
MAX_DEPTH
:
return
[]
keypoint
.
append
({
"
center
"
:
center
,
"
radius
"
:
radius
,
"
depth
"
:
d
})
# circle center
if
VISUALIZE
:
cv2
.
putText
(
img_rgb
,
"
d:{:1.3f} r:{:1.0f}
"
.
format
(
d
,
radius
),
(
center
[
0
],
center
[
1
]
-
radius
-
5
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
255
,
255
,
255
),
thickness
=
1
)
cv2
.
circle
(
img_rgb
,
center
,
1
,
(
0
,
100
,
100
),
3
)
# circle outline
cv2
.
circle
(
img_rgb
,
center
,
radius
,
(
255
,
0
,
255
),
3
)
for
k
in
range
(
circles
.
shape
[
1
]):
circles
=
np
.
uint16
(
np
.
around
(
circles
))
i
=
circles
[
0
,
k
]
center
=
(
i
[
0
],
i
[
1
])
radius
=
i
[
2
]
# get depth in [m] (was radius * 0.4 in real world)
d
=
circular_mean
(
center
,
radius
*
0.2
,
copy
(
img_depth
))
/
1000
# todo this is a slow implementation. You might want to speedup
# filter if sign to close (circle detector will struggle) or to far (background)
# was 0.2 and 1.0
if
(
d
<
MIN_DEPTH
or
d
>
MAX_DEPTH
)
and
not
pub_all
:
return
[]
keypoint
.
append
({
"
center
"
:
center
,
"
radius
"
:
radius
,
"
depth
"
:
d
})
# circle center
if
VISUALIZE
:
cv2
.
putText
(
img_rgb
,
"
d:{:1.3f} r:{:1.0f}
"
.
format
(
d
,
radius
),
(
center
[
0
],
center
[
1
]
-
radius
-
5
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
255
,
255
,
255
),
thickness
=
1
)
cv2
.
circle
(
img_rgb
,
center
,
1
,
(
0
,
100
,
100
),
3
)
# circle outline
color
=
(
255
,
0
,
255
)
if
k
==
0
:
color
=
(
0
,
255
,
0
)
cv2
.
circle
(
img_rgb
,
center
,
radius
,
color
,
3
)
if
not
pub_all
:
break
return
keypoint
...
...
@@ -355,7 +362,7 @@ def publish_image(img, pub_cmpr_img):
if
__name__
==
"
__main__
"
:
rospy
.
init_node
(
"
hough_
detection
"
)
rospy
.
init_node
(
"
hough_
transform
"
)
ros_pack
=
rospkg
.
RosPack
()
ns
=
rospy
.
get_namespace
()
segment_rate
=
rospy
.
Rate
(
5
)
...
...
@@ -382,8 +389,7 @@ if __name__=="__main__":
accum_thresh
=
rospy
.
get_param
(
"
sign_detector/canny_param2
"
)
#30
img_processed
=
copy
(
img_rgb_stream
)
rospy
.
loginfo
(
"
img_processed: {}
"
.
format
(
img_processed
))
keypoints
=
do_hough_circle_detection
(
img_processed
,
copy
(
img_depth_stream
),
VISUALIZE
=
True
)
keypoints
=
do_hough_circle_detection
(
img_processed
,
copy
(
img_depth_stream
),
VISUALIZE
=
True
,
pub_all
=
not
toggle_patch_visualization
)
if
toggle_patch_visualization
:
img_processed
=
copy
(
img_rgb_stream
)
...
...
This diff is collapsed.
Click to expand it.
minibot_vision/scripts/SignDetector.py
+
3
−
1
View file @
540f83ee
...
...
@@ -51,6 +51,7 @@ def image_color_callback(data):
try
:
img_rgb_stream
=
bridge
.
imgmsg_to_cv2
(
data
,
"
bgr8
"
)
img_rgb_timestamp
=
rospy
.
Time
.
now
()
SegmentSign
.
IMG_RES
=
(
data
.
height
,
data
.
width
)
except
CvBridgeError
as
e
:
print
(
e
)
...
...
@@ -60,6 +61,7 @@ def image_depth_callback(data):
try
:
img_depth_stream
=
bridge
.
imgmsg_to_cv2
(
data
,
"
16UC1
"
)
SegmentSign
.
DEPTH_RES
=
(
data
.
height
,
data
.
width
)
except
CvBridgeError
as
e
:
print
(
e
)
...
...
@@ -289,7 +291,7 @@ if __name__ == "__main__":
pub_raw_img
=
rospy
.
Publisher
(
"
capture_imgs/result_image
"
,
Image
,
queue_size
=
10
)
# TODO migrate service uri to this node!
pub_cmpr_img
=
rospy
.
Publisher
(
"
capture_imgs/result_image/compressed
"
,
CompressedImage
,
queue_size
=
10
)
# TODO migrate service uri to this node!
SegmentSign
.
update_camera_params
()
#
SegmentSign.update_camera_params()
rospy
.
loginfo
(
"
({}) Sign classification running with params fps: {}, visualization_compression_factor: {}
"
.
format
(
rospy
.
get_name
(),
fps
,
visualization_compression_factor
))
call_rvr_color_event
(
event_id
=
TriggerLedEventRequest
.
VISION_STARTUP
,
stop_current_event
=
False
)
...
...
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