Skip to content

Commit 064ccfb

Browse files
committed
Cleanup the README.md
Signed-off-by: Chris Lalancette <[email protected]>
1 parent 77d03d8 commit 064ccfb

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed
Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
1+
## Image Tools Demo in Python
2+
13
This is a demonstration of the Quality of Service (QoS) features of ROS 2 using Python.
2-
There are two programs implemented here: cam2image_py, and showimage_py. Note that in
3-
order for these programs to work, an OpenCV binding for Python3 must be available. As
4-
of this writing (January 11, 2017), only OpenCV 3 or later supports Python3. Instructions
5-
for compiling OpenCV3 for Python3 are available here:
6-
7-
http://stackoverflow.com/questions/20953273/install-opencv-for-python-3-3
8-
9-
The condensed rundown that works on Ubuntu16.04 and will install to /usr/local is:
10-
$ sudo apt install python3 build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python3.5-dev libpython3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
11-
$ git clone https://github.com/opencv/opencv
12-
$ cd opencv
13-
$ git checkout 3.2.0
14-
$ mkdir release
15-
$ cd release
16-
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
17-
$ make -j8
18-
$ sudo make install
19-
20-
CAM2IMAGE_PY
21-
------------
4+
There are two programs implemented here: cam2image_py, and showimage_py.
5+
6+
### CAM2IMAGE_PY
227
This is a Python program that will take data from an attached camera, and publish the
23-
data to a topic called "image", with the type sensor_msgs::msg::Image. If a camera
8+
data to a topic called "image", with the type sensor_msgs/msg/Image. If a camera
249
isn't available, this program can also generate a default image and smoothly "move"
2510
it across the screen, simulating motion. The usage output from the program looks like
2611
this:
2712

28-
usage: cam2image_py.py [-h] [-b] [-d QUEUE_DEPTH] [-f FREQUENCY] [-k {0,1}]
29-
[-r {0,1}] [-s {0,1}] [-x WIDTH] [-y HEIGHT]
13+
```
14+
usage: cam2image_py [-h] [-b] [-d DEPTH] [-f FREQUENCY] [-k {0,1}] [-r {0,1}]
15+
[-s {0,1}] [-t TOPIC] [-x WIDTH] [-y HEIGHT]
3016
3117
optional arguments:
3218
-h, --help show this help message and exit
3319
-b, --burger Produce images of burgers rather than connecting to a
3420
camera (default: False)
35-
-d QUEUE_DEPTH, --depth QUEUE_DEPTH
21+
-d DEPTH, --depth DEPTH
3622
Queue depth (default: 10)
3723
-f FREQUENCY, --frequency FREQUENCY
3824
Publish frequency in Hz (default: 30)
@@ -42,18 +28,22 @@ optional arguments:
4228
-r {0,1}, --reliability {0,1}
4329
Reliability QoS setting, 0 - best effort, 1 - reliable
4430
(default: 1)
31+
-t TOPIC, --topic TOPIC
32+
Topic to publish on (default: image)
33+
4534
-s {0,1}, --show {0,1}
4635
Show the camera stream (default: 0)
4736
-x WIDTH, --width WIDTH
4837
Image width (default: 320)
4938
-y HEIGHT, --height HEIGHT
5039
Image height (default: 240)
40+
```
5141

5242
The -d, -k, and -r parameters control various aspects of the QoS implementation, and
5343
are the most interesting to play with when testing out QoS.
5444

5545
Note that this program also subscribes to a topic called "flip_image" of type
56-
std_msgs::msg::Bool. If flip_image is set to False, the data coming out of the camera
46+
std_msgs/msg/Bool. If flip_image is set to False, the data coming out of the camera
5747
is sent as usual. If flip_image is set to True, the data coming out of the camera is
5848
flipped around the Y axis.
5949

@@ -63,13 +53,13 @@ the ROS 2 pub/sub model, so this window cannot show off the QoS parameters (it i
6353
useful for debugging). See SHOWIMAGE_PY below for a program that can show QoS over the
6454
pub/sub model.
6555

66-
SHOWIMAGE_PY
67-
------------
56+
### SHOWIMAGE_PY
6857
This is a Python program that subscribes to the "image" topic, waiting for data. As
6958
new data comes in, this program accepts the data and can optionally render it to
7059
the screen. The usage output from the program looks like this:
7160

72-
usage: showimage_py.py [-h] [-d QUEUE_DEPTH] [-k {0,1}] [-r {0,1}] [-s {0,1}]
61+
usage: showimage_py [-h] [-d QUEUE_DEPTH] [-k {0,1}] [-r {0,1}] [-s {0,1}]
62+
[-t TOPIC]
7363

7464
optional arguments:
7565
-h, --help show this help message and exit
@@ -82,28 +72,35 @@ optional arguments:
8272
Reliability QoS setting, 0 - best effort, 1 - reliable
8373
(default: 1)
8474
-s {0,1}, --show {0,1}
85-
Show the camera stream (default: 0)
75+
Show the camera stream (default: 1)
76+
-t TOPIC, --topic TOPIC
77+
use topic TOPIC instead of the default (default: image)
8678

8779
The -d, -k, and -r parameters control various aspects of the QoS implementation, and
8880
are the most interesting to play with when testing out QoS.
8981

9082
If the -s parameter is set to 1, then this program opens up a window to show the images
9183
that have been received over the ROS 2 pub/sub model. This program should be used
92-
in conjunction with CAM2IMAGE_PY to demonstrate the ROS 2 QoS capabilities over lossy/slow
84+
in conjunction with cam2image_py to demonstrate the ROS 2 QoS capabilities over lossy/slow
9385
links.
9486

95-
EXAMPLE USAGE
96-
-------------
87+
### EXAMPLE USAGE
9788
To use the above programs, you would run them something like the following:
9889

9990
# In the first terminal, run the data publisher. This will connect to the 1st camera
10091
# available, and print out "Publishing image #" for each image it publishes.
101-
$ python3 cam2image_py.py
102-
103-
# In a second terminal, run the data subscriber. This will subscribe to the "image"
104-
# topic and render any frames it receives.
105-
$ python3 showimage_py.py -s 1
92+
```
93+
$ ros2 run image_tools_py cam2image_py
94+
```
10695

10796
# If you don't have a local camera, you can use the -b parameter to generate data on
10897
# the fly rather than get data from a camera:
109-
$ python3 cam2image_py.py -b
98+
```
99+
$ ros2 run image_tools_py cam2image_py -b
100+
```
101+
102+
# In a second terminal, run the data subscriber. This will subscribe to the "image"
103+
# topic and render any frames it receives.
104+
```
105+
$ ros2 run image_tools_py showimage_py
106+
```

0 commit comments

Comments
 (0)