Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting webcam images using ROS and openCV in python

Hi everyone, I am able to get webcam images using ROS and openCV and manipulate the image using C++ however I want to achieve the same for python.

I am using cv_bridge to convert images from ROS to openCV and vice versa so I looked at the code from the tutorials. I want to convert the following C++ code into python:

int main(int argc, char** argv)
{
ros::init(argc, argv, "image_converter");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
cv::namedWindow(WINDOW, CV_WINDOW_AUTOSIZE);
image_transport::Subscriber sub = it.subscribe("camera/image_raw", 1, imageCb);
cv::destroyWindow(WINDOW);
image_pub_ = it.advertise("camera/image_processed", 1);
ros::spin();

return 0;
}

I am trying to get the camera feed from my webcam and also publish this over ROS. I have achieved this using C++ but want to do the same all in python. I learnt this from: link:text

I am converting between ROS and openCV images using the cv_bridge. This is using cv and not cv2. If anyone has a tutorial on doing this for cv2 do let me know.

Thanks :)

click to hide/show revision 2
retagged

updated 2013-09-17 13:21:25 -0600

berak gravatar image

Getting webcam images using ROS and openCV in python

Hi everyone, I am able to get webcam images using ROS and openCV and manipulate the image using C++ however I want to achieve the same for python.

I am using cv_bridge to convert images from ROS to openCV and vice versa so I looked at the code from the tutorials. I want to convert the following C++ code into python:

int main(int argc, char** argv)
{
ros::init(argc, argv, "image_converter");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
cv::namedWindow(WINDOW, CV_WINDOW_AUTOSIZE);
image_transport::Subscriber sub = it.subscribe("camera/image_raw", 1, imageCb);
cv::destroyWindow(WINDOW);
image_pub_ = it.advertise("camera/image_processed", 1);
ros::spin();

return 0;
}

I am trying to get the camera feed from my webcam and also publish this over ROS. I have achieved this using C++ but want to do the same all in python. I learnt this from: link:text

I am converting between ROS and openCV images using the cv_bridge. This is using cv and not cv2. If anyone has a tutorial on doing this for cv2 do let me know.

Thanks :)

click to hide/show revision 3
retagged

updated 2013-09-17 13:22:54 -0600

berak gravatar image

Getting webcam images using ROS and openCV in python

Hi everyone, I am able to get webcam images using ROS and openCV and manipulate the image using C++ however I want to achieve the same for python.

I am using cv_bridge to convert images from ROS to openCV and vice versa so I looked at the code from the tutorials. I want to convert the following C++ code into python:

int main(int argc, char** argv)
{
ros::init(argc, argv, "image_converter");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
cv::namedWindow(WINDOW, CV_WINDOW_AUTOSIZE);
image_transport::Subscriber sub = it.subscribe("camera/image_raw", 1, imageCb);
cv::destroyWindow(WINDOW);
image_pub_ = it.advertise("camera/image_processed", 1);
ros::spin();

return 0;
}

I am trying to get the camera feed from my webcam and also publish this over ROS. I have achieved this using C++ but want to do the same all in python. I learnt this from: link:text

I am converting between ROS and openCV images using the cv_bridge. This is using cv and not cv2. If anyone has a tutorial on doing this for cv2 do let me know.

Thanks :)