ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

python subscriber to a uvc_camera non-compressed Image?

asked 2014-05-02 14:29:31 -0600

lucasw gravatar image

updated 2020-11-21 11:39:24 -0600

I've previously used this tutorial to get a CompressImage from a web camera: http://wiki.ros.org/rospy_tutorials/T...

Now I'm using a webcamera through uvc_camera, and it isn't publishing a compressed image. If I substitute Image for CompressedImage in the python code the cv_image comes out as None.

  ...
     # subscribed Topic
     self.subscriber = rospy.Subscriber("/camera/image_raw",
         Image, self.callback,  queue_size = 1)
  ....
  def callback(self, ros_data):
  ...

      #### direct conversion to CV2 ####
      np_arr = np.fromstring(ros_data.data, np.uint8)
      image_np = cv2.imdecode(np_arr, cv2.CV_LOAD_IMAGE_COLOR)

np_arr at this point is a (widthheight3, ) array, but image_np comes out None.

The camera otherwise works fine in rqt_image_view. Is there any way to get uvc_camera to compress, another node to add that will compress for me, or get the np/cv2 commands to process the non-compressed data properly?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-06 12:46:00 -0600

lucasw gravatar image

Installing the compressed image ros packages solved my problems, though I'm still curious about subscribing to an uncompressed image.

This caused the uvc_camera to publish a compressed image instead of just a raw uncompressed:

sudo apt-get install ros-hydro-compressed-image-transport

image_transport republish may also work but I have not tried it. http://wiki.ros.org/image_transport#r...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-05-02 14:29:31 -0600

Seen: 610 times

Last updated: May 06 '14