Robotics StackExchange | Archived questions

I am doing a project in which I need to display series of images in Baxter robot's screen.

I tried to launch it on ./baxter. sh, but it kept saying that the input type is a not numpy array. I do know that gray scale images are not acceptable, and I have checked that. However, I am encountering the same problem again and again. Can you help me on this?

Traceback (most recent call last): File "/home/baxter/rosws/src/baxterexamples/scripts/xdisplayimage.py", line 63, in msg = cvbridge.CvBridge().cv2toimgmsg(img, encoding="passthrough") File "/opt/ros/indigo/lib/python2.7/dist-packages/cvbridge/core.py", line 246, in cv2to_imgmsg raise TypeError('Your input type is not a numpy array') TypeError: Your input type is not a numpy array This is the code that I used

! usr/bin/python2

if name == 'main' :

rospy.init_node('rsdk_xdisplay_image', anonymous=True) #added to follow the format of publishing a message
pub = rospy.Publisher('/robot/xdisplay', Image, latch=True, queue_size=1)
images=["r.png","l.png","f.png"] #added list of imgages found in /xdisplayImages
while not rospy.is_shutdown():

      for path in images:  # loop to iterate images
          img = cv2.imread(path)
          msg = cv_bridge.CvBridge().cv2_to_imgmsg(img, encoding="bgr8")
          pub.publish(msg)
# Sleep to allow for image to be published.
          rospy.sleep(1)

Asked by Biruk22 on 2017-06-30 15:41:53 UTC

Comments

Answers