ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You might want to convert the sensor_msgs/Image datatype to an OpenCV image. The cv_bridge tutorial for Python shows how to do so: http://www.ros.org/wiki/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
2 | No.2 Revision |
You might want to convert the sensor_msgs/Image datatype to an OpenCV image. The cv_bridge tutorial for Python shows how to do so: http://www.ros.org/wiki/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
OpenCV then has a function "imshow" which would allow you to display the image.
3 | No.3 Revision |
You might want to convert the sensor_msgs/Image datatype to an OpenCV image. The cv_bridge tutorial for Python shows how to do so: http://www.ros.org/wiki/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
Our group has also has some sample code in SVN: http://code.google.com/p/albany-ros-pkg/source/browse/branches/seminar2011/ex_vision/src/capture.py which shows how to capture an image, and display it using OpenCV then has a function "imshow" which would allow you to display the image. and cv_bridge.
4 | No.4 Revision |
You might want to convert the sensor_msgs/Image datatype to an OpenCV image. The cv_bridge tutorial for Python shows how to do so: http://www.ros.org/wiki/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
Our group has also has some sample The below code in SVN: http://code.google.com/p/albany-ros-pkg/source/browse/branches/seminar2011/ex_vision/src/capture.py which shows how to capture is an example from our SVN ( http://code.google.com/p/albany-ros-pkg ) that captures an image, blurs it, and displays it:
""" Example code of how to convert ROS images to OpenCV's cv::Mat This is the solution to HW2, using Python.
See also cv_bridge tutorials: http://www.ros.org/wiki/cv_bridge """
import roslib; roslib.load_manifest('ex_vision') import rospy
import cv from cv_bridge import CvBridge, CvBridgeError
from std_msgs.msg import String from sensor_msgs.msg import Image
class image_blur:
def __init__(self): # initialize a node called hw2 rospy.init_node("hw2")
# create a window to display it results in
cv.NamedWindow("image_view", 1)
# part 2.1 of hw2 -- subscribe to a topic called image
self.image_sub = rospy.Subscriber("image", Image, self.callback)
def callback(self,data): """ This is a callback which recieves images and processes them. """ # convert image into openCV format bridge = CvBridge() try: # bgr8 is the pixel encoding -- 8 bits per color, organized as blue/green/red cv_image = bridge.imgmsg_to_cv(data, "bgr8") except CvBridgeError, e: # all print statements should use a rospy.log_ form, don't print! rospy.loginfo("Conversion failed")
# we could do anything we want with the image here
# for now, we'll blur using OpenCV and cv_bridge. a median blur
cv.Smooth(cv_image, cv_image, smoothtype=cv.CV_MEDIAN, param1=31, param2=0, param3=0, param4=0)
# show the image
cv.ShowImage("image_view", cv_image)
cv.WaitKey(3)
if __name__ == '__main__':
image_blur()
try:
rospy.spin()
except KeyboardInterrupt:
print "Shutting down"
cv.DestroyAllWindows()
5 | No.5 Revision |
You might want to convert the sensor_msgs/Image datatype to an OpenCV image. The cv_bridge tutorial for Python shows how to do so: http://www.ros.org/wiki/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython
The below code is an example from our SVN ( http://code.google.com/p/albany-ros-pkg ) that captures an image, blurs it, and displays it:
#!/usr/bin/env python
"""
Example code of how to convert ROS images to OpenCV's cv::Mat
This is the solution to HW2, using