-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathview_images.py
More file actions
executable file
·39 lines (28 loc) · 1.07 KB
/
view_images.py
File metadata and controls
executable file
·39 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
from cv_bridge import CvBridge, CvBridgeError
from sensor_msgs.msg import CompressedImage
import cv2
import numpy as np
class MinimalSubscriber(Node):
def __init__(self, ):
super().__init__('minimal_subscriber')
self.subscription = self.create_subscription(CompressedImage, 'freertos_picture_publisher', self.listener_callback, 10)
self.subscription # prevent unused variable warning
self.bridge = CvBridge()
def listener_callback(self, image_message):
self.get_logger().info('recieved an image')
self.cv_image = self.bridge.compressed_imgmsg_to_cv2(image_message,'8UC3')
#recieve image and co nvert to cv2 image
cv2.imshow('esp32_image', self.cv_image)
cv2.waitKey(3)
def main(args=None):
rclpy.init(args=args)
minimal_subscriber = MinimalSubscriber()
rclpy.spin(minimal_subscriber)
minimal_subscriber.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()