How to publish images quickly
ROS Indigo, Python, OpenCV (cv_bridge)
I wrote a node that does differential imaging on the webcam feed from a Kinect, but when I publish the final images and try to view them in image_view, the frame rate is really slow. If I instead use cv2.imshow() at the same place I'm publishing, the frame rate is fine. What is causing the the frame rate to be so slow when publishing and viewing with image_view, rather than just viewing through OpenCV?
Here's my publisher setup:
...other code...
image_pub = rospy.Publisher("/motion_image", Image, queue_size=10)
...other code...
try:
img = bridge.cv2_to_imgmsg(motion_img, "bgr8")
image_pub.publish(img)
except CvBridgeError, e:
print e
And my subscriber if helpful:
image_sub = rospy.Subscriber("/camera/rgb/image_color", Image, callback, queue_size=10)
I just want to be able to grab one image at a time so I unregister at each call, when I want another image I resubscribe
def callback(data):
global camera_img, image_sub
try:
bridge = CvBridge()
camera_img = bridge.imgmsg_to_cv2(data, "bgr8")
image_sub.unregister()
except CvBridgeError, e:
print e
Update: Here's the rest of my code, feel free to comment on other things as well. I'm new to Python and ROS and I want to get better. Sorry it's not posted direct, I was having trouble getting it to format correctly.