# ros-image-transport-py
**Repository Path**: linuxfly/ros-image-transport-py
## Basic Information
- **Project Name**: ros-image-transport-py
- **Description**: ROS Image Transport Python
- **Primary Language**: Python
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-04-04
- **Last Updated**: 2024-11-15
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# ROS Image Transport Python


This ROS package aim to give the same facility of use of image topic as [image_transport](http://wiki.ros.org/image_transport) can does in c++. Moreover, this package is compatible with [image_transport](http://wiki.ros.org/image_transport) and [message_filter](http://wiki.ros.org/message_filters), that mean that you can communicate to existing node that use image transport in c++. (Like [rqt](http://wiki.ros.org/rqt) or [RViz](http://wiki.ros.org/rviz))
## :rocket: Getting Started
### :gear: Compilation
```shell
git clone https://github.com/alexandrefch/ros-image-transport-py.git
catkin build image_transport_py
```
> **Warning**
> The catkin compilation might lead to some dependencies errors, do not hesitate to report them so they can be corrected.
### :computer: How to use
**Publisher**
```py
# Publisher example
import rospy
import image_transport
rospy.init_node("my_node_publisher")
publisher = image_transport.Publisher("my_topic/image")
publisher.publish(image)
```
Instantiation of a publisher object by calling `image_transport.Publisher()` that will automaticly generate all supported transport type topic as below. (eg: rostopic list using `ImageTransport.advertise("my_topic/image")`)
```txt
my_topic/image
my_topic/image/compressed
```
**Subscriber**
Now if you want to subscribe you simply need create call `image_transport.Subscriber` and choose your desire format topic, the library will detect what type is it using topic name and pick the correct image decoder.
(eg : if you want to subscribe to a compressed topic simply use `image_transport.Subscriber("my_topic/image/compressed",callback)`)
```py
# Subscriber example
import rospy
import image_transport
def callback(image):
print(f"receive image of shape {image.shape}")
rospy.init_node("my_node_subscriber")
image_transport.Subscriber("my_topic/image/compressed",callback)
```
## :books: Supported transport type
- `image_raw`
- `compressed` (using jpeg compression)
> **Note**
> If you want to help and add new transport type feel free to fork this project and make a merge request.
## Compatibility with message_filter
```python
import rospy
import message_filters
import image_transport
from sensor_msgs.msg import PointCloud2
def _callback(self,pcl,image):
print("Success !")
rospy.init_node('Kitti')
subscribers = [
message_filters.Subscriber('/pointcloud',PointCloud2),
image_transport.Subscriber('/my_camera_topic/image_raw')
]
mf = message_filters.ApproximateTimeSynchronizer(
subscribers,
queue_size=10,
slop=0.1
)
mf.registerCallback(self._callback)
rospy.spin()
```