-
Notifications
You must be signed in to change notification settings - Fork 0
/
recibir_imagen.py
executable file
·45 lines (33 loc) · 1019 Bytes
/
recibir_imagen.py
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
40
41
42
43
44
45
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Image
from sensor_msgs.msg import CompressedImage
from cv_bridge import CvBridge
import cv2
import numpy as np
# known pump geometry
# - units are pixels (of half-size image)
def start_node():
rospy.init_node('camera_subscriber_hd1')
rospy.loginfo('camera_subscriber_hd1 started')
rospy.Subscriber("image", Image , process_image)
rospy.spin()
def process_image(msg):
#Image
showImage(CvBridge().imgmsg_to_cv2(msg))
#CompressedImage
#np_arr = np.fromstring(msg.data, np.uint8)
#image_np = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
#cv2.imshow('cv_img', image_np)
# key = cv2.waitKey(1) & 0xFF
# if key == ord('q'):
# cap.release()
# cv2.destroyAllWindows()
def showImage(img):
cv2.imshow('image', img)
cv2.waitKey(10)
if __name__ == '__main__':
try:
start_node()
except rospy.ROSInterruptException:
pass