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

how to write subscriber and publisher for webcam?

asked 2015-06-22 13:38:52 -0600

Prashant Kumar gravatar image

Actually, I am new to ROS and its features. I want to know the code for subscriber and publisher for taking picture from my integrated laptop webcam and store in the hard drive. I am familiar with gscam feature to take pictures from my webcam. But i want to use it as subscriber and publisher. please help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-06-22 14:52:46 -0600

duck-development gravatar image

updated 2015-06-28 15:02:32 -0600

See there http://wiki.ros.org/usb_cam

is an v4l driver

install the packet

  • sudo apt-get install ros-indigo-usb-cam

  • source PATH_TO_YOUR_WS/devel/setub.bash

    • rosrun usb_cam usb_cam_node ~video_device "/dev/video0"

and you have a video publisher

and some more code https://rosstitchernode.wordpress.com...

Install UVC

  • sudo apt-get install install ros-indigo-libuvc ros-indigo-libuvc-camera

  • sudo echo '# UVC cameras SUBSYSTEMS=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="04f2", ATTRS{idProduct}=="b2eb", MODE="0666"' > /etc/udev/rules.d/99-uvc.rules

    where the ID (idvendor and idProduct from you wabcam)

  • sudo rmmod snd-usb-audio

  • sudo rmmod uvcvide
  • sudo udevadm trigger

Test

  • source PATH_TO_YOUR_WS/devel/setub.bash
  • roscore &
  • rosrun libuvc_camera camera_node &
  • rosrun image_view image_view image:=/image_raw
edit flag offensive delete link more

Comments

doesn't help.. can you give me a sample code for it?

Prashant Kumar gravatar image Prashant Kumar  ( 2015-06-23 12:44:48 -0600 )edit

http://pharos.ece.utexas.edu/wiki/ind...

there is some exampel code for the usage ov usb_cam

duck-development gravatar image duck-development  ( 2015-06-23 12:50:56 -0600 )edit

if you are talking about image transport then I know it..and I can use gscam for taing snaps but not as subscriber and publisher. Rather, I want to take snaps from my webcam by subscriber and publisher. which is getting me in trouble.

Prashant Kumar gravatar image Prashant Kumar  ( 2015-06-24 14:13:46 -0600 )edit

in the link that you gave in the above comment, "rosmake --rosdep-install" is not working. secondly, it's not the code for subscriber and publisher, it's just a launch file code.

Prashant Kumar gravatar image Prashant Kumar  ( 2015-06-26 13:34:24 -0600 )edit

Say exactly what you like to have. A Program wicht publish picture. Write your self a Program witch read the camera and publish the picture.

subscriber: you like only to see the pricture you like to work with the picture

you like to trigger a photo with you subscriber and then compute the picture

duck-development gravatar image duck-development  ( 2015-06-26 15:46:28 -0600 )edit

thanks for updated answer..but I am getting error as follows when I run the launch file:- "[ERROR] [1435430293.861984376]: Webcam: expected picture but didn't get it..." I can see my camera gets activated but no image is shown in the pop up window..its just full black.. any suggestions?

Prashant Kumar gravatar image Prashant Kumar  ( 2015-06-27 13:40:47 -0600 )edit

Oh I got it. I just had to change the pixel format. thanks for the help. can you please tell me how to do the same using uvc_cam/libuvc_cam. In this case also my camera gets activated but no image is there in the window.

Prashant Kumar gravatar image Prashant Kumar  ( 2015-06-27 14:37:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-22 13:38:52 -0600

Seen: 4,583 times

Last updated: Jun 28 '15