Listener does not update [closed]
Good afternoon friends
I can get an image of the camera from the gazebo: /camera/image_raw. But if you change the qr code, the listener does not update.
Can anyone help me with this?
#! /usr/bin/python
import rospy
import numpy as np
import cv2
import cv
import zbar
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
bridge = CvBridge()
def callback(msg):
cv2_img = bridge.imgmsg_to_cv2(msg, "bgr8")
scanner = zbar.ImageScanner()
scanner.parse_config('enable')
while not rospy.is_shutdown():
gray = cv2.cvtColor(cv2_img, cv2.COLOR_BGR2GRAY, dstCn=0)
frame = np.array(gray)
width, height = frame.shape[1], frame.shape[0]
raw = frame.tostring()
image = zbar.Image(width, height, 'Y800', raw)
scanner.scan(image)
qrc = None
for symbol in image:
qrc = symbol.data
if qrc != None:
qr_str = qrc
rospy.loginfo(qr_str)
def qr_main():
rospy.init_node('qr_listener')
rospy.Subscriber("/camera/image_raw", Image, callback)
rospy.spin()
if __name__ == '__main__':
qr_main()