11## Image Tools Demo in Python
22
3- This is a demonstration of the Quality of Service (QoS) features of ROS 2 using Python.
3+ This is a demonstration of the Quality of Service (QoS) features of ROS 2 using
4+ Python.
45There are two programs implemented here: cam2image_py, and showimage_py.
56
67### CAM2IMAGE_PY
7- This is a Python program that will take data from an attached camera, and publish the
8- data to a topic called "image", with the type sensor_msgs/msg/Image. If a camera
9- isn't available, this program can also generate a default image and smoothly "move"
10- it across the screen, simulating motion. The usage output from the program looks like
11- this:
8+ This is a Python program that will take data from an attached camera, and
9+ publish the data to a topic called "image", with the type
10+ ` sensor_msgs/msg/Image ` .
11+ If a camera isn't available, this program can also generate a default image and
12+ smoothly "move" it across the screen, simulating motion. The usage output from
13+ the program looks like this:
1214
1315```
1416usage: cam2image_py [-h] [-b] [-d DEPTH] [-f FREQUENCY] [-k {0,1}] [-r {0,1}]
@@ -39,25 +41,30 @@ optional arguments:
3941 Image height (default: 240)
4042```
4143
42- The -d, -k , and -r parameters control various aspects of the QoS implementation, and
43- are the most interesting to play with when testing out QoS.
44+ The ` -d ` , ` -k ` , and ` -r ` parameters control various aspects of the QoS
45+ implementation, and are the most interesting to play with when testing out QoS.
4446
4547Note that this program also subscribes to a topic called "flip_image" of type
46- std_msgs/msg/Bool. If flip_image is set to False, the data coming out of the camera
47- is sent as usual. If flip_image is set to True, the data coming out of the camera is
48- flipped around the Y axis.
49-
50- If the -s parameter is set to 1, then this program opens up a (local) window to show
51- the images that are being published. However, these images are * not* coming in through
52- the ROS 2 pub/sub model, so this window cannot show off the QoS parameters (it is mostly
53- useful for debugging). See SHOWIMAGE_PY below for a program that can show QoS over the
54- pub/sub model.
48+ ` std_msgs/msg/Bool ` .
49+ If "flip_image" is set to ` False ` , the data coming out of the camera is sent as
50+ usual.
51+ If "flip_image" is set to ` True ` , the data coming out of the camera is flipped
52+ around the Y axis.
53+
54+ If the ` -s ` parameter is set to 1, then this program opens up a (local) window
55+ to show the images that are being published.
56+ However, these images are * not* coming in through the ROS 2 pub/sub model, so
57+ this window cannot show off the QoS parameters (it is mostly useful for
58+ debugging).
59+ See SHOWIMAGE_PY below for a program that can show QoS over the pub/sub model.
5560
5661### SHOWIMAGE_PY
57- This is a Python program that subscribes to the "image" topic, waiting for data. As
58- new data comes in, this program accepts the data and can optionally render it to
59- the screen. The usage output from the program looks like this:
62+ This is a Python program that subscribes to the "image" topic, waiting for data.
63+ As new data comes in, this program accepts the data and can optionally render
64+ it to the screen.
65+ The usage output from the program looks like this:
6066
67+ ```
6168usage: showimage_py [-h] [-d QUEUE_DEPTH] [-k {0,1}] [-r {0,1}] [-s {0,1}]
6269 [-t TOPIC]
6370
@@ -75,32 +82,34 @@ optional arguments:
7582 Show the camera stream (default: 1)
7683 -t TOPIC, --topic TOPIC
7784 use topic TOPIC instead of the default (default: image)
85+ ```
7886
79- The -d, -k , and -r parameters control various aspects of the QoS implementation, and
80- are the most interesting to play with when testing out QoS.
87+ The ` -d ` , ` -k ` , and ` -r ` parameters control various aspects of the QoS
88+ implementation, and are the most interesting to play with when testing out QoS.
8189
82- If the -s parameter is set to 1, then this program opens up a window to show the images
83- that have been received over the ROS 2 pub/sub model. This program should be used
84- in conjunction with cam2image_py to demonstrate the ROS 2 QoS capabilities over lossy/slow
85- links.
90+ If the ` -s ` parameter is set to 1, then this program opens up a window to show
91+ the images that have been received over the ROS 2 pub/sub model.
92+ This program should be used in conjunction with cam2image_py to demonstrate the
93+ ROS 2 QoS capabilities over lossy/slow links.
8694
8795### EXAMPLE USAGE
8896To use the above programs, you would run them something like the following:
8997
90- # In the first terminal, run the data publisher. This will connect to the 1st camera
91- # available, and print out "Publishing image #" for each image it publishes.
98+ In the first terminal, run the data publisher.
99+ This will connect to the first camera available, and print out
100+ "Publishing image #" for each image it publishes.
92101```
93102$ ros2 run image_tools_py cam2image_py
94103```
95104
96- # If you don't have a local camera, you can use the -b parameter to generate data on
97- # the fly rather than get data from a camera:
105+ If you don't have a local camera, you can use the ` -b ` parameter to generate
106+ data on the fly rather than get data from a camera:
98107```
99108$ ros2 run image_tools_py cam2image_py -b
100109```
101110
102- # In a second terminal, run the data subscriber. This will subscribe to the "image"
103- # topic and render any frames it receives.
111+ In a second terminal, run the data subscriber.
112+ This will subscribe to the "image" topic and render any frames it receives.
104113```
105114$ ros2 run image_tools_py showimage_py
106115```
0 commit comments